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">
circle-check

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:

circle-check

Attributes

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

circle-check

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

circle-check

Important Meta tags for modern web apps:

circle-check

Divisions and Spans

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

circle-check

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:

circle-check
  • 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

circle-check

Video and Audio

circle-check

Background Images (CSS)

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

circle-check

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

circle-check
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

circle-check

Additional Semantic Elements

circle-check

Forms and Input Elements

Forms are crucial for user interaction in web applications:

circle-check

Modern Input Types (HTML5)

circle-check

Best Practices for Modern HTML

1. Semantic HTML First

circle-check

2. Accessibility (a11y)

circle-check

3. Performance Optimization

circle-check

4. SEO Optimization

circle-check

5. Mobile-First Design

circle-check

6. Progressive Enhancement

circle-check

HTML Validation and Testing

Validation Tools

Common Validation Errors

circle-check

Integration with Modern Frameworks

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

circle-check

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