Detailed Explanation of HTML Structure
- DOCTYPE Declaration
The DOCTYPE declaration must be the first line in any HTML document. It tells the browser which version of HTML is being used, ensuring consistent rendering across browsers. - HTML Tags
HTML tags are instructions that tell browsers how to display content. Tags are divided into:- Opening Tag:
<tag>
- Content: The content between the tags.
- Closing Tag:
</tag>
Example:
- Opening Tag:
- Head Tag (
<head>
)
The<head>
section contains metadata about the HTML document, including styles, links, and scripts. - Title Tag (
<title>
)
Inside the<head>
, the<title>
tag specifies the title displayed in the browser tab. - Body Tag (
<body>
)
The<body>
contains the main content of the web page, such as text, images, and links. Only one<body>
tag is allowed per HTML document.
More Details on Basic HTML Tags
- Paragraph Tag (
<p>
)
Used for paragraphs. Place text between the opening and closing tags. - Heading Tags (
<h1>
to<h6>
)
Define headings, from largest (<h1>
) to smallest (<h6>
). - Anchor Tag (
<a>
)
Creates hyperlinks. Thehref
attribute specifies the link’s destination. - Image Tag (
<img>
)
Embeds images. Thesrc
attribute specifies the image file.Note:
<img>
is a self-closing tag. - Div Tag (
<div>
)
Groups content into sections. Useful for organizing the page. - Header Tag (
<header>
)
Defines the header section of a webpage, which often includes navigation links. - Footer Tag (
<footer>
)
Defines the footer section, often containing copyright or contact information. - List Tags
Used for creating lists. There are two types:- Unordered List (
<ul>
): Items are marked with bullet points. - Ordered List (
<ol>
): Items are numbered.
Example of Unordered List:
Output:
- Item 1
- Item 2
- Item 3
- Unordered List (