HTML Document Features
HTML Document Features
1. Doctype Declaration
<!DOCTYPE html>
Defines the version of HTML being used.
In modern web development, <!DOCTYPE html> specifies HTML5.
Helps browsers render the document correctly.
3. Head Section
<head>
Contains metadata and information about the document.
Common elements include:
<title>: Specifies the title of the document (shown in browser tabs).
<meta>: Provides metadata (e.g., character set, viewport settings, descriptions).
Example:
html
Copy code
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link>: Links to external resources like stylesheets.
Example:
html
Copy code
<link rel="stylesheet" href="styles.css">
<style>: Embeds CSS directly in the document.
<script>: Embeds or links JavaScript for dynamic functionality.
<base>: Specifies the base URL for relative links.
4. Body Section
<body>
Contains the content displayed on the webpage.
Includes various elements:
Text and Structure:
<h1> to <h6>: Headings of varying levels.
<p>: Paragraphs.
<br>: Line breaks.
<hr>: Horizontal rules.
Links and Media:
<a>: Hyperlinks.
<img>: Images.
<audio>: Audio content.
<video>: Video content.
Lists:
<ul>: Unordered lists.
<ol>: Ordered lists.
<li>: List items.
Tables:
<table>, <tr>, <td>, and other related elements.
Forms:
<form>, <input>, <textarea>, <button>, <select>, etc.
5. Attributes
6. Semantic Elements
Introduced in HTML5 for better document structure and accessibility.
Examples:
<header>: Defines introductory content or navigation links.
<footer>: Defines footer content.
<article>: Self-contained content (e.g., blog post).
<section>: Thematic grouping of content.
<aside>: Content aside from the main content (e.g., sidebars).
<nav>: Navigation links.
<main>: Main content of the document.
7. Media Features
9. Scripting
<script>
Embeds or links JavaScript to make the page dynamic.
Inline:
html
Copy code
<script> console.log("Hello, World!"); </script>
External:
html
Copy code
<script src="script.js"></script>
10. Styling
12. Comments