HTML Summary for Beginners
HTML (Hypertext Markup Language) is the foundation of all web pages. It structures content and defines the
relationships between elements on a webpage.
1. Basic Structure of an HTML Document:
An HTML file starts with <!DOCTYPE html> to define the version. The <html> tag wraps the whole content.
The <head> tag contains meta information, title, and links to external resources. The <body> tag includes the
visible content such as text, images, and other elements.
Example structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
2. Comments:
Comments are added using <!-- comment here -->. They do not display on the browser and are useful for
notes or explanations within the code.
3. Tags and Elements:
- Tags define elements and are written in angle brackets. Most have opening and closing pairs, e.g., <p></p>.
Some are self-closing like <br> or <img />.
Examples:
<h1> to <h6>: Headings, from most important (h1) to least (h6)
<p>: Paragraphs, used to group and display blocks of text
1|Page
<br>: Line break, moves text to the next line without creating a new paragraph
4. Div Element:
<div>: A block-level container used to group elements for styling or scripting.
Example:
<div>
<p>This is inside a div.</p>
<ul><li>Item 1</li><li>Item 2</li></ul>
</div>
Best Practice: Use <div> and CSS for layout instead of excessive <br> tags.
2|Page