Guide to Writing HTML Code
Key Concepts
HTML (HyperText Markup Language) is the standard markup language used to create web pages. Here's a guide on how to write HTML code.
Structure
HTML documents are structured using various tags, such as <html>, <head>, <body>, and more.
Headings
Headings are defined using <h1> to <h6> tags. The <h1> tag represents the main heading, while <h6> is used for the smallest headings.
Paragraphs
Text within paragraphs is defined using the <p> tag.
Lists
HTML supports both ordered (numbered) and unordered (bulleted) lists. Unordered lists are created using the <ul> tag, while ordered lists are created using the <ol> tag.
Links
Links are created using the <a> tag. The href attribute specifies the URL of the linked page.
Images
Images are inserted using the <img> tag. The src attribute specifies the image's URL, while the alt attribute provides alternative text for screen readers.
Code Blocks
Code blocks can be created using the <code> tag. For programming code, you should use the <pre> tag with the <code> tag inside.
HTML Validation
It's essential to ensure your HTML code is valid to avoid issues with web browsers. You can validate your HTML using online tools like the W3C HTML Validator.
Example HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is a simple HTML page.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<img src="image.jpg" alt="A beautiful image">
<a href="https://www.example.com">Visit Example.com</a>
</body>
</html>
References
- Book: HTML & CSS: Design and Build Websites by Jon Duckett
- Article: "HTML5 Tutorial" by W3Schools
- Online Resource: "HTML Basics" by Mozilla Developer Network