Description and Basic Syntax

HTML (HyperText Markup Language) is the standard markup language for creating web pages and web applications. It provides the semantic structure and content of web documents, serving as the foundation upon which CSS and JavaScript build.

  • Declarative Language: Describes what should be displayed, not how to compute it

  • Semantic Markup: Elements convey meaning about their content

  • Tree Structure: Nested elements form a Document Object Model (DOM)

  • Fault-Tolerant: Browsers attempt to render even malformed HTML

HTML terminology

Tags

Tags are the building blocks of HTML that define how content should be structured and displayed. They are keywords wrapped in angle brackets < >.

<!-- Opening and closing tags -->
<p>This is a paragraph</p>

<!-- Self-closing tags (void elements) -->
<img src="image.jpg" alt="Description">
<br>
<hr>
<input type="text">
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">

Common tags by category:

  • Structural: <html>, <head>, <body>

  • Text: <p>, <h1>...<h6>, <span>, <strong>, <em>

  • Container: <div>, <section>, <article>, <main>

  • Lists: <ul>, <ol>, <li>, <dl>, <dt>, <dd>

  • Media: <img>, <video>, <audio>, <picture>

  • Interactive: <a>, <button>, <form>, <input>

Elements

Elements are complete HTML components consisting of:

  • Opening tag

  • Content (optional)

  • Closing tag (unless self-closing)

Elements can be nested to create complex document structures:

Attributes

Attributes provide additional information about elements. They appear in the opening tag as name/value pairs:

Essential Global Attributes:

  • id - Unique identifier

  • class - CSS styling hooks (space-separated list)

  • data-* - Custom data attributes for JavaScript

  • style - Inline CSS (use sparingly)

  • title - Tooltip text

  • lang - Language specification

  • dir - Text direction (ltr/rtl)

  • hidden - Hide element

  • tabindex - Tab order for keyboard navigation

  • contenteditable - Make content editable

HTML Terminology

The complete HTML5 document structure

Important Meta tags for modern web apps:

Divisions and Spans

Container elements that have no semantic meaning on their own, used primarily for styling and JavaScript manipulation:

Linking Between Pages and Resources

The <a> (anchor) element creates hyperlinks to other pages, files, locations within the same page, email addresses, or any other URL:

  • Use descriptive link text (avoid "click here")

  • Include rel="noopener noreferrer" for target="_blank" links (security)

  • Use relative URLs for internal links (maintainability)

  • Consider adding title attributes for additional context

Adding Media

Images

Video and Audio

Background Images (CSS)

While not HTML, background images are commonly set via CSS:

Display Types: Block vs. Inline vs. Inline-block

Understanding how elements display is crucial for layout control:

Block Elements

Characteristics:

  • Start on a new line

  • Occupy full width available

  • Stack vertically

  • Respect all margin and padding values

  • Can contain other block and inline elements

Inline Elements

Characteristics:

  • Flow within text content

  • Only occupy necessary width

  • Don't force line breaks

  • Ignore top/bottom margins

  • Vertical padding may overlap other lines

  • Cannot contain block elements

Inline-block Elements

Characteristics:

  • Flow inline like text

  • Respect width and height

  • Respect all margins and paddings

  • Don't force line breaks

Display Types Diagram

HTML5 Semantic Elements

Semantic elements clearly describe their meaning to both the browser and developer, improving:

  • SEO: Search engines better understand content structure

  • Accessibility: Screen readers can navigate more effectively

  • Maintainability: Code is self-documenting

  • Styling: More specific CSS targeting

Common Semantic Elements

Additional Semantic Elements

Forms and Input Elements

Forms are crucial for user interaction in web applications:

Modern Input Types (HTML5)

Best Practices for Modern HTML

1. Semantic HTML First

2. Accessibility (a11y)

3. Performance Optimization

4. SEO Optimization

5. Mobile-First Design

6. Progressive Enhancement

HTML Validation and Testing

Validation Tools

  • W3C Validator: validator.w3.org

  • HTML5 Validator: Browser developer tools

  • Accessibility: WAVE, axe DevTools

Common Validation Errors

Integration with Modern Frameworks

When working with Vue.js (which you'll study later), HTML becomes templated:

This foundation in semantic HTML will be essential when you build dynamic applications with Express, Firebase, and Vue.js, as these frameworks ultimately generate and manipulate HTML in the browser.

Summary

HTML provides the structural foundation of web applications. While frameworks like Vue.js abstract much of the HTML writing, understanding these fundamentals is crucial for:

  • Debugging rendered output

  • Optimizing performance

  • Ensuring accessibility

  • Improving SEO

  • Creating maintainable applications

Remember: Good HTML is semantic, accessible, and performant - principles that apply whether you're writing HTML directly or through a framework.

Last updated

Was this helpful?