HTML Fundamentals
What is HTML?
HTML (HyperText Markup Language) is the standard markup language for creating web pages. It describes the structure of a web page using elements or "tags".
Basic HTML Structure
Every HTML document follows this basic structure:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
Common HTML Elements
- Headings: <h1> to <h6> for different heading levels
- Paragraphs: <p> for text paragraphs
- Links: <a href="url">Link Text</a>
- Images: <img src="image.jpg" alt="description">
- Lists: <ul> (unordered) and <ol> (ordered) with <li> items
- Divisions: <div> for grouping elements
Example:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href="https://www.example.com">Visit Example.com</a>
<p>My first paragraph.</p>
<a href="https://www.example.com">Visit Example.com</a>
Tip: HTML tags usually come in pairs with an opening tag and a closing tag (e.g., <p> and </p>). Some tags are self-closing like <img> and <br>.
HTML Attributes
Attributes provide additional information about HTML elements. They are always specified in the opening tag.
<a href="https://www.example.com" target="_blank">Open in new tab</a>
<img src="photo.jpg" alt="A beautiful landscape" width="500">
<img src="photo.jpg" alt="A beautiful landscape" width="500">