HTML Basics

Master the foundational markup language that powers every website on the internet.

Why HTML Matters for Developers

Industry-Standard Foundation

Learn exactly how professional developers structure HTML documents

Debugging Skills

Understand common mistakes and how to fix them early in your learning

Semantic Understanding

Grasp why proper HTML structure matters for accessibility and SEO

Anatomy of an HTML Document

Every valid HTML document follows a specific structure that browsers use to render content correctly:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document Title</title>
</head>
<body>
  <!-- Visible content goes here -->
</body>
</html>

Critical Components:

  • lang="en" - Specifies language for accessibility
  • charset="UTF-8" - Ensures proper character encoding
  • Viewport meta tag - Makes site mobile-friendly
  • Semantic structure - Helps search engines understand content

Essential HTML Tags Cheat Sheet

These are the building blocks you'll use in nearly every project:

TagDescriptionImportance
<!DOCTYPE html>Defines the document type and HTML version (HTML5)Required
<html>Root element that wraps the entire HTML documentRequired
<head>Contains page info like title, styles, and meta dataRequired
<title>Shows text on browser tab (used in SEO)Required
<meta>Sets character encoding, responsive settings, and page infoHighly Recommended
<link>Links external files like CSSHighly Recommended
<style>Writes internal CSS stylesHighly Recommended
<script>Adds JavaScript for interactive featuresHighly Recommended
<body>Holds everything visible on the pageRequired
<div>Block-level container for layout or grouping contentLayout
<span>Inline container for text and stylingStyling
<section>Groups related content into sectionsSemantic Value
<article>Used for independent pieces like blog postsSemantic Value
<header>Defines the top part (e.g., logo, nav)Semantic Value
<footer>Defines the bottom part (e.g., copyright)Semantic Value
<main>Marks the main content areaSemantic Value
<nav>Contains navigation linksSemantic Value
<aside>Holds side content like ads or tipsSemantic Value
<h1>-<h6>Headings (h1 = most important)Semantic Value
<p>Creates a paragraph of textStructural
<br>Line break (new line)Structural
<hr>Horizontal line for content separationStructural
<strong>Bold text to show importanceStyling
<em>Italic text for emphasisStyling
<b>Bold text (no special meaning)Styling
<i>Italic text (no special meaning)Styling
<u>Underlined textStyling
<mark>Highlights the textStyling
<small>Smaller textStyling
<del>Strikethrough (deleted) textStyling
<ins>Inserted text (usually underlined)Styling
<sub>Subscript text (below)Styling
<sup>Superscript text (above)Styling
<a>Adds a link (use href)Fundamental
<img>Displays an image (needs src)Visual Content
<figure>Groups an image and captionSemantic Value
<figcaption>Caption for a <figure>Semantic Value
<audio>Plays audio filesMedia
<video>Plays video filesMedia
<source>Provides media source for <video>/<audio>Media
<iframe>Displays external page in a boxMedia
<ul>Unordered (bullet point) listStructural
<ol>Ordered (numbered) listStructural
<li>List item inside ul or olStructural
<table>Starts a tableStructural
<tr>Adds a row to a tableStructural
<td>Adds data cellStructural
<th>Adds table header cell (bold)Structural
<thead>Groups header rowsSemantic Value
<tbody>Groups body rowsSemantic Value
<tfoot>Groups footer rowsSemantic Value
<form>Creates a form to collect user inputFundamental
<input>Creates an input fieldFundamental
<textarea>Multi-line input fieldFundamental
<button>Clickable buttonFundamental
<select>Drop-down menuForm Element
<option>Options for drop-downForm Element
<label>Label for form elementsAccessibility
<details>Expandable section of contentSemantic Value
<summary>Title for <details>Semantic Value
<canvas>Drawing area using JavaScriptVisual/Graphics
<svg>Draw shapes and icons using codeGraphics
<noscript>Fallback if JavaScript is disabledAccessibility
<template>Hidden HTML for future useAdvanced

Common Beginner Mistakes to Avoid

1. Missing Closing Tags

Always close your tags. Missing tags can break layout and cause rendering issues.

2. Improper Nesting

Tags must be closed in the correct order. Nest properly.

3. Missing alt on Images

Alt text helps screen readers and SEO. Always use it for <img>.

4. Block Inside Inline

Never place block elements like <div> inside inline tags like <span>.

5. Missing Viewport Meta

Missing this tag causes mobile scaling issues.

6. Too Much Inline Styling

Keep your styles in CSS. Avoid inline styles for reusable and clean code.

Hands-On Practice

Apply responsive design concepts in our interactive playground:

  • Experiment with media queries and breakpoints
  • Test flexbox and grid layouts
  • See real-time responsive preview
  • Save your responsive designs
<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    /* Mobile-first base styles */
    .container {
      width: 100%;
      padding: 1rem;
    }
    
    /* Tablet breakpoint */
    @media (min-width: 768px) {
      .container {
        max-width: 720px;
        margin: 0 auto;
      }
    }
    
    /* Desktop breakpoint */
    @media (min-width: 1024px) {
      .container {
        max-width: 960px;
      }
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Responsive Practice</h1>
    <p>Try adding your own responsive elements</p>
  </div>
</body>
</html>

Continue Your Learning Path