HTML Formatting, Images and Links – Notes with Examples
1. Paragraph Tag (<p>)
Defines a paragraph in HTML. A paragraph always starts on a new line.
Example:
<p>This is paragraph one.</p>
<p>This is paragraph two.</p>
2. Line Break and Horizontal Rule
<br> creates a new line without starting a new paragraph. <hr> creates a horizontal line
used to separate sections.
Example:
<p>This is a paragraph<br>with a line break.</p>
<hr>
<p>This is another paragraph.</p>
3. Extra Space
is used to add extra spaces between words in HTML.
Example:
<p>Extra space inside paragraph</p>
4. Heading Tags
HTML has six headings from <h1> to <h6>. <h1> is the largest and most important heading.
Example:
<h1>Main Heading</h1>
<h2>Sub Heading</h2>
<h3>Small Heading</h3>
5. Text Formatting Tags
Formatting tags are used to highlight or emphasize text.
Example:
<b>Bold text</b>
<i>Italic text</i>
<u>Underlined text</u>
<strong>Important text</strong>
Water is H<sub>2</sub>O
y = x<sup>2</sup>
6. Font Tag
The <font> tag is used to change font size, color and style of text.
Example:
<font size="5" color="red" face="Arial">Welcome to HTML</font>
7. Nested Elements
Nesting means placing one HTML element inside another element.
Example:
<p><b><u>Nested formatting example</u></b></p>
8. Image Tag
The <img> tag is used to insert images in a web page.
Example:
<img src="[Link]" alt="sample image" width="300" height="200">
9. Marquee Tag
<marquee> creates scrolling text or images on a webpage.
Example:
<marquee direction="left">Welcome to HTML</marquee>
10. HTML Links (Anchor Tag)
The <a> tag is used to create hyperlinks to other pages or resources.
Example:
<a href="[Link] Google</a>
11. Image as a Link
An image can also be used as a hyperlink.
Example:
<a href="[Link]
<img src="[Link]" alt="YouTube">
</a>
12. Email Link
A mailto link opens the default email client to send an email.
Example:
<a href="[Link] Email</a>
13. Target Attribute
The target attribute defines where the linked document will open.
Example:
<a href="[Link] target="_blank">Open Google in
new tab</a>
14. Relative and Absolute Links
Relative links connect pages within the same website. Absolute links connect to external
websites.
Example Relative Link:
<a href="[Link]">Go to Page 2</a>
Example Absolute Link:
<a href="[Link] W3Schools</a>