HTML Examples
HTML examples help you understand how different HTML tags work by showing you how they are used in real-world applications. Below are some basic examples you can try out yourself.
1. HTML Heading Example
Headings are used to define the headings of a webpage. HTML supports six levels of headings, from <h1>
(the largest) to <h6>
(the smallest).
<h1>This is an H1 Heading</h1>
<h2>This is an H2 Heading</h2>
<h3>This is an H3 Heading</h3>
<h4>This is an H4 Heading</h4>
<h5>This is an H5 Heading</h5>
<h6>This is an H6 Heading</h6>
2. HTML Paragraph Example
Paragraphs in HTML are defined using the <p>
tag. The text inside this tag is displayed as a block of text on the webpage.
<p>This is a simple paragraph of text.</p>
<p>This is another paragraph of text.</p>
3. HTML Link Example
Links are created using the <a>
tag. The href
attribute specifies the destination URL for the link.
<a href="https://www.lunalearn24.com">Visit lunalearn24.com</a>
4. HTML Image Example
Images are added to a webpage using the <img>
tag. The src
attribute specifies the URL of the image, and the alt
attribute provides alternative text in case the image cannot be displayed.
<img src="https://www.example.com/image.jpg" alt="Example Image" width="300">
Exercise: Multiple Choice Questions (MCQs)
1. Which tag is used to define a paragraph in HTML?
a) <heading>b) <link>
c) <p>
d) <img>
2. Which attribute is used to specify the destination URL for a link?
a) hrefb) src
c) alt
d) link
Solutions:
1. c) <p>
2. a) href
Assignment
Create an HTML document that includes the following:
- A heading with the title "My HTML Example Page".
- A paragraph describing your favorite HTML element.
- A link to a website of your choice.
- An image of something related to your favorite HTML element.
Submit your HTML code for review.
0 Comments