Vs codeis a source code editor (7)
Vs codeis a source code editor (7)
The process of communication between the client, browser, and server is as follows:
When we want to access any information on the internet, we search for it using a
web browser. The web browser retrieves the content from web servers, where it is
stored in the form of HTML documents.
An HTML document is created by writing code with specific tags in a code editor
of your choice. The document is then saved with the '.html' extension. Once
saved, the browser interprets the HTML document, reads it, and renders the web
page.
The text editor has the HTML code of a website. This website can now be viewed
in a beautifully rendered format using a computer program known as a web
browser.
A browser is an application that reads HTML documents and displays them as web
pages.
What is an HTML Document?
An HTML document is a text document saved with the '.html' or '.htm' extension,
containing text and specific tags enclosed in '< >
1. Parsing – Converts raw data into characters, tokens, and nodes, organizing
them into a DOM (Document Object Model) tree.
2. Rendering – The DOM tree is processed, styled, and displayed on the
screen.
The Backend
The backend, handles behind-the-scenes operations like storing and processing
data when users interact with the frontend. It uses languages like Python, Ruby,
and Java.
The Frontend
• Frontend refers to the visible part of a website or app that users interact
with, like the tables, images, and buttons. It's built using languages like
HTML, CSS, and JavaScript.
• HTML: The structure of a webpage.
• CSS: The style and design of the page.
• JavaScript: Adds interactivity and dynamic content to the website.
In essence, frontend is what users see, while backend manages the functionality.
File Organization
• For HTML: index.html
• For CSS: style.css
• For JavaScript: script.js
<script src="script.js"></script>
HTML : Hyper Text Mark Up language : 'Hypertext' refers to the linking of text with
other documents, while 'markup language' denotes a language that utilizes a
specific set of tags.
In this example, the <b> element (child) is nested inside the <h1> element
(parent).
HTML Attributes
HTML attributes are used to define the characteristics of an HTML element
They are placed within the element's opening tag and consist of two
parts: the name and the value.
• Name: Specifies the property for that element.
• Value: Sets the value of that property for the element.
Core attributes are some of the most widely used attributes in HTML. There are
four main types:
• id
• class
• title
• Style
ID Attribute :
An ID is an attribute, a unique identifier assigned to only one HTML element within
a page. It is often used for unique styling and JavaScript manipulations.
Class Attribute :
The class attribute lets you give the same name to multiple HTML elements. That
way, you can easily change their look or behavior all at once. Classes are not
unique and can be assigned to multiple elements.
<head>
<style>
/* CSS rules go here */
p {
color: blue;
font-size: 18px;
}
. highlight {
background-color: yellow;
}
</style>
Title Attribute :
The title attribute shows a small text when you move the mouse over an element.
Style Attribute :
The style attribute applies CSS directly to an element for quick styling.
HTML Comments :
Comments in HTML are like little notes you leave in your code for yourself or other
people.
These notes help make the code easier to understand but don't show up on the
actual website. The web browser just skips over them!
Single-line Comments
Single-line comments are contained within one line. They are useful for short
annotations.
<!--
This is a multi-line comment.
It spans multiple lines.
-->
CSS (Cascading Style Sheets) – Styling: It controls the design and layout of a
webpage.
Skeletal Tags
<!DOCTYPE html>: "Specifies the document type
<html> </html>
The <html> tag is the root element that wraps all the content on the page. It
generally contains two main sections: the header (<head>...</head>) and the
body (<body>...</body>).
The <head> tag contains meta information and the title of the document. While
the title appears in the browser tab, meta information is often used for SEO
purposes.
The image below shows the skeletal tags and essential tags needed to define the
layout of a webpage
Heading Tags
In HTML, heading tags ranging from <h1> to <h6> are used to define the
structure and layout of text on a web page. These tags help create a hierarchical
organization of content, making it easier for both users and search engines to
understand the page's content.
Paragraph Tag
To create well-structured text in your HTML document, the <p> tag is essential for
defining paragraphs.
<p> </p>
<hr>
The <hr> tag is an empty or self-closing tag, meaning it doesn't require a closing
tag. It serves as a visual separator, dividing different sections of your document
with a horizontal line.
It's particularly useful in formatting textual content where line breaks are essential
for readability or visual layout. For instance, it can be used in addresses, poems, or
song lyrics to preserve the original line structure.
Anchor Tag
Links are fundamental to navigating the web. In HTML, links are created using the
<a> tag, also known as the Anchor tag.
Let's say you have a long webpage with multiple sections, and you want to create
a link at the top that, when clicked, takes the user directly to a specific section
further down the page. You can do this using HTML links that target specific
sections.
Image Tag
Images play a crucial role in enhancing web pages by providing a visual context
that complements textual content. In HTML, the <img> tag is used to embed
images into web pages.
Note: Styling dimensions and other properties are now more commonly managed
through CSS for better flexibility and maintainability.
Pre Tag
The <pre> tag serves as an indispensable tool in HTML for displaying
preformatted text, such as code snippets in various programming languages.
HTML elements are generally divided into two categories: Block-level and Inline
elements.
1. Do not start on a new line and are part of the flow of surrounding content.
2. Take up only as much width as needed based on their content.
3. Can contain other inline elements, but should not contain block-level
elements (like <div> or <p>).
List Tags
1. Unordered list.
<ul>
<li>Pen</li>
<li>Pencil</li>
<li>Eraser</li>
</ul>
2. ordered list.
<ol>
<li>Pen</li>
<li>Pencil</li>
<li>Eraser</li>
</ol>
Customizing Bullet Points with 'type' Attribute
You can specify the style of bullet points using the type attribute. It
supports three values:
• disc - default bullet style
• square
• circle
Definition list:
HTML Definition Lists
A Definition List in HTML is used to represent a list of terms along with their
corresponding descriptions or definitions. The Definition List is created using the
<dl> (Definition List) element, which wraps around one or more pairs of <dt>
(Definition Term) and <dd> (Definition Description) elements.
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
In this example:
• <dl> is the container for the list.
• <dt> defines the terms that you want to explain.
• <dd> contains the definitions or explanations for the terms.
HTML Tables
• HTML tables allow you to arrange data like text, images, and links in rows
and columns. You use the <table> tag to start and end a table.
Adding a Caption
To add a title to your table, you can use the <caption> element. This element
helps both in terms of SEO and accessibility.
<table>
<thead>
<!-- header content -->
</thead>
<tfoot>
<!-- footer content -->
</tfoot>
<tbody>
<!-- body content -->
</tbody>
</table>
Column Groups
You can use the <colgroup> and <col> elements to apply styles to an entire
column in an HTML table.
<table>
<colgroup>
<col style="background-color:yellow">
</colgroup>
<!-- rest of the table -->
</table>
Accessibility in Tables
To make your tables more accessible, you can use the scope attribute in <th>
elements to specify if they are headers for columns, rows, or groups of columns or
rows.
<th scope="col">Name</th>
<th scope="col">Age</th>
Tables
<TABLE>...</TABLE> → Table definition
<TABLE width="x%"> → Table width in percentage
<TABLE width=x> → Table width in pixels
<TABLE border=x> → Border thickness
<TABLE cellpadding=x> → Space between border and text
<TABLE cellspacing=x> → Space between cells
Table Rows & Cells
The "type" attribute specifies the type of input control (e.g., text, password,
checkbox).
The "name" attribute is used for identifying the control, especially when the data
is sent to the server.
The "value" attribute sets a default value for the control, which the user can
overwrite.
THyperlinks
• <A href="http://...">...</A> → External link to a webpage
• <A href="mailto:[email protected]">...</A> → Email link
• <A href="file.html">...</A> → Link to a local page in the same folder
• <A name="xyz">...</A> → Anchor definition
• <A href="#xyz">...</A> → Link to an anchor in the same file
• <A href="file.html#xyz">...</A> → Link to an anchor in another file
Images
• <IMG src="imageURL"> → Inserts an image (GIF, JPG, PNG)
• <IMG ... width=x height=y> → Scales the image (in pixels)
• <IMG ... border=x> → Defines the image border thickness
• <IMG ... alt="text"> → Alternative text when image is not displayed
• <IMG ... align=valign> → Aligns image relative to text line
• <IMG ... align=halign> → Aligns text around image (left, right)
• <IMG ... hspace=x> → Horizontal spacing around the image
• <IMG ... vspace=y> → Vertical spacing around the image
• <IMG ... usemap=#map> → Uses an image map
• Image Map
<MAP name="mapname">
<AREA href="url" shape="rect" coords="x1,y1,x2,y2" alt="text">
<AREA href="url" shape="circle" coords="x,y,radius" alt="text">
<AREA href="url" shape="poly" coords="x1,y1,x2,y2,...xn,yn"
alt="text">
<AREA href="url" shape="default" alt="text">
</MAP>
rect → Rectangle
circle → Circle
poly → Polygon