Basic HTML Syntax and Structure
๐งฑ Basic Structure of an HTML Document
An HTML document begins with a declaration and follows a structured format using tags and elements.
๐๏ธ Document Layout
1. <!DOCTYPE html>
Declares the HTML5 document type.
2. <html>
The root element that wraps the entire page content.
3. <head>
Contains metadata like:
- ๐ท๏ธ Page title (
<title>
) - ๐งต Links to stylesheets
- ๐ก Scripts and other resources
4. <body>
Holds the visible content such as:
- ๐ข Headings
- ๐ Paragraphs
- ๐ Links
- ๐งฉ Interactive elements
๐ท๏ธ Tags, Elements & Attributes
- Elements consist of an opening
<tag>
and a closing</tag>
. - Attributes (like
id
,class
,href
) provide additional information about elements.
โ Proper nesting and indentation improve readability and maintainability.
๐ก Example: Basic HTML Structure
<!DOCTYPE html>
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<h1>Welcome to HTML Tutorial</h1>
<p>This is a paragraph explaining HTML basics.</p>
</body>
</html>