What is HTML?
HTML provides the foundation of every website by organizing content into a structured format that browsers can understand and display. Think of HTML as the skeleton of a webpage - it gives structure to text, images, forms, and other content.Key Characteristics
- Markup Language: Uses tags to annotate and structure content
- Platform Independent: Works across all browsers and devices
- Human Readable: Easy to learn and understand
- Semantic: Modern HTML5 provides meaningful tags that describe content
HTML Document Example
Here’s a basic HTML5 document structure:Breaking Down the Structure
DOCTYPE Declaration
DOCTYPE Declaration
htmlwithout a version number means HTML5 (current version)- Required and must be the first line of the document
- Not case-sensitive, but lowercase is conventional
HTML Root Element
HTML Root Element
<html> element is the root element containing all other elements:lang="es"attribute indicates the content language"es"= Spanish"en"= English"pt"= Portuguese
- Important for SEO and screen readers (accessibility)
Head Section
Head Section
<head> contains metadata - information about the document that isn’t directly visible:- Character encoding settings
- Viewport configuration for responsive design
- Page title, meta descriptions
- Links to stylesheets and scripts
- SEO and social media metadata
Body Section
Body Section
<body> contains all visible content:- Text, images, videos, forms
- Semantic structure (header, main, footer)
- Interactive elements (buttons, links)
Types of HTML Elements
HTML elements are categorized by their display behavior and semantic meaning:1. Block-Level Elements
Block-level elements occupy the full width available and always start on a new line.<div>, <p>, <h1>-<h6>, <header>, <main>, <footer>, <section>, <article>, <nav>
2. Inline Elements
Inline elements only occupy the space they need and don’t start on a new line.<span>, <a>, <img>, <strong>, <em>, <button>, <input>
3. Semantic Elements (HTML5)
Semantic elements give meaning to the content, improving SEO and accessibility.- Better SEO (search engines understand structure)
- Improved accessibility (screen readers navigate better)
- More maintainable code (easier to read and understand)
4. Void/Self-Closing Elements
Void elements have no content and don’t need a closing tag.<img>, <br>, <hr>, <input>, <meta>, <link>
Comparing Approaches
- Before HTML5
- HTML5 (Modern)
<div> elements with IDs to indicate purpose.Next Steps
Now that you understand the basics of HTML, you’re ready to dive deeper into:- Document Structure: Learn about the
<head>and metadata - Semantic Elements: Master HTML5 semantic tags
- Tags and Attributes: Understand how to configure elements
- Forms and Inputs: Create interactive user input forms
- Best Practices: Write clean, accessible, maintainable HTML
Try It Yourself
Create a simple HTML file with:
- A proper DOCTYPE declaration
- A title in the head section
- A heading and paragraph in the body
- At least one link to another page