HTML Notes – Basic Structure & Text
Formatting
Types of HTML Tags
HTML tags are divided into two main types:
Container Tags
These tags have both a starting tag and an ending tag.
The closing tag contains a forward slash ( / ).
They contain content inside them.
Example:
<HTML> </HTML>
<P> Paragraph </P>
<B> Bold Text </B>
Structure:
<tagname> Content </tagname>
Empty Tags
These tags have only a starting tag.
They do not need a closing tag.
They do not contain any content.
Example:
<BR>
<HR>
Basic Structure of an HTML5 Document
Every HTML5 webpage must include the following basic building blocks:
1. <!DOCTYPE html>
This is a mandatory declaration.
It tells the browser that the document is written in HTML5.
It must be written at the top of the document.
2. <HTML>
This tag marks the start and end of the entire HTML document.
All other tags are written inside this tag.
Example:
<HTML>
Content
</HTML>
3. <HEAD>
This section contains descriptive information about the webpage.
It stores metadata like the title.
Content inside <HEAD> is not displayed on the webpage.
4. <TITLE>
The text inside this tag appears in the Title Bar or Tab of the web browser.
It is written inside the <HEAD> section.
Example:
<TITLE> My Webpage </TITLE>
5. <BODY>
This tag contains the main content of the webpage.
Everything visible on the page (text, images, graphics) is written inside the
<BODY> tag.
Modifying and Formatting Text
Paragraph Tag <P>
Used to start a new paragraph.
The browser automatically adds a blank line before and after a paragraph.
Example:
<P>This is a paragraph.</P>
Line Break <BR>
Used to move text to the next line.
It is an empty tag.
It does not add extra space.
Example:
First Line<BR>
Second Line
Horizontal Rule <HR>
Inserts a thin grey line across the page.
Used to separate sections of content.
It is an empty tag.
Attributes of <HR>:
SIZE → Changes thickness.
WIDTH → Changes length.
Example:
<HR SIZE="5" WIDTH="50%">
Heading Tags
HTML provides six levels of headings:
<H1> Largest </H1>
<H2>
<H3>
<H4>
<H5>
<H6> Smallest </H6>
<H1> is the largest heading.
<H6> is the smallest heading.
Visual Text Styles
You can highlight or emphasize important text using these tags:
Bold <B>
Makes text darker and thicker.
Example:
<B>Important Text</B>
Italic <I>
Makes text slanted.
Example:
<I>Italic Text</I>
Underline <U>
Draws a line under the text.
Example:
<U>Underlined Text</U>
Subscript <SUB>
Displays text slightly below the normal line.
Usually used in chemical formulas.
Example:
H<SUB>2</SUB>O
Superscript <SUP>
Displays text slightly above the normal line.
Usually used in mathematical powers.
Example:
2<SUP>3</SUP>