HTML: Your First Web Page (And Why Tables Aren't for Layouts!)

Welcome to your first step in web development! In this guide, we'll explore the fundamental building blocks of web pages and learn how to create properly structured HTML documents. Let's dive into the world of semantic markup and modern layout practices.

What is HTML?

HTML (HyperText Markup Language) is the backbone of every web page you see. It's not a programming language, but rather a markup language that tells browsers how to structure the content they display.

HTML was created by Sir Tim Berners-Lee in the early 1990s as part of his vision for the World Wide Web. His goal was to create a system where academic documents could be easily shared and linked together across the internet. What began as a simple solution for document sharing has evolved into the complex and powerful language we use today to build everything from simple blogs to sophisticated web applications.

The beauty of HTML lies in its simplicity and flexibility. At its core, HTML uses a system of elements and tags to define different parts of a web page. Each element serves a specific purpose, whether it's displaying a paragraph of text, an image, a form for user input, or creating a link to another page. By combining these elements in meaningful ways, you can create rich, interactive experiences for your users.

Getting Started

Let's create your first HTML document:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First Web Page</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is my first web page.</p>
</body>
</html>

Save this code in a file with a .html extension (e.g., index.html), and open it in a web browser. Congratulations! You've just created your first web page.

When you open this file in a browser, the browser reads the HTML code and interprets it to render the visual elements on your screen. This transformation from code to visual representation is what makes the web accessible to everyone—technical experts and casual users alike. The browser acts as an intermediary, translating your HTML instructions into a user-friendly interface that anyone can interact with.

Creating your first HTML page is a significant milestone. This simple document contains all the essential elements that every HTML page needs, establishing a foundation upon which you can build increasingly complex and feature-rich websites. As you continue your journey in web development, you'll discover that mastering these fundamentals is crucial for creating effective, accessible, and professional web experiences.

Understanding the Basic Structure

Let's break down the key elements of an HTML document:

  1. <!DOCTYPE html>: Tells the browser that this is an HTML5 document. This declaration isn't an HTML tag itself but an instruction to the browser about what version of HTML the page is written in. Before HTML5, DOCTYPEs were more complex and required references to DTDs (Document Type Definitions), but HTML5 simplified this to a clean, easy-to-remember declaration.

  2. <html>: The root element that contains all other HTML elements. The lang="en" attribute specifies that the content is in English, which helps screen readers and search engines better understand your content. For multilingual sites, you might use different language codes like fr for French or es for Spanish in specific sections of your site.

  3. <head>: Contains meta-information about the document that isn't displayed. This section acts as the "brain" of your document, containing information that helps browsers and search engines understand what your page is about and how to process it. It's also where you'll link external resources like CSS stylesheets and JavaScript files that enhance your page's appearance and functionality.

  4. <meta>: Provides metadata about the HTML document. The charset="UTF-8" declaration ensures your document can display special characters and symbols from most human languages. The viewport meta tag is crucial for responsive design, telling mobile browsers how to control the page's dimensions and scaling. Without this tag, mobile devices might display your page as it would appear on a desktop, requiring users to zoom in to read content.

  5. <title>: Sets the title of the page (shown in the browser tab). An effective title is crucial for both user experience and search engine optimization. It should be descriptive yet concise, accurately representing the page's content while including relevant keywords when appropriate.

  6. <body>: Contains all the content that is displayed on the page. Everything your visitors will see and interact with—text, images, links, forms, and more—goes inside this element. The body is where the visual structure of your page takes shape.

The careful organization of these elements creates a clear separation between the document's metadata and its content. This separation is a fundamental principle in web development, allowing browsers to efficiently process and render your pages. As you become more experienced, you'll appreciate how this structure facilitates maintenance and scalability, making it easier to update and expand your websites over time.

Semantic HTML Elements

HTML5 introduced semantic elements that clearly describe their meaning to both the browser and the developer. Here are some common ones:

<header>Website or section header</header>
<nav>Navigation links</nav>
<main>Main content of the page</main>
<article>Self-contained content</article>
<section>Thematic grouping of content</section>
<aside>Related but tangential content</aside>
<footer>Website or section footer</footer>

Using semantic elements makes your HTML more:

Before HTML5, developers relied heavily on generic <div> elements with class or ID attributes to structure pages. For example, instead of <header>, you might have seen <div class="header">. While this approach worked visually when styled with CSS, it didn't convey any inherent meaning about the content's purpose.

Semantic HTML represents a philosophical shift in web development—from focusing solely on how pages look to considering what the content means. This shift aligns with the web's evolution from static documents to rich, interactive applications that need to be accessible across a wide range of devices and to users with diverse abilities.

Consider a blog post page: using <article> for the post itself, <header> for the title and metadata, <section> elements for major divisions within the content, and <aside> for related links or advertisements creates a logical structure that benefits everyone—users, developers, and search engines alike.

Why Tables Aren't for Layouts

In the early days of the web, developers used <table> elements to create complex layouts. This was a misuse of tables, which were designed for tabular data, not page structure. Here's why we don't use tables for layouts anymore:

Problems with Table Layouts:

  1. Accessibility Issues: Screen readers interpret tables as data tables, making table layouts confusing for users with disabilities. When a screen reader encounters a table, it announces the number of rows and columns and provides navigation features specific to tabular data. When tables are used for layout, this creates a disorienting experience where content is announced in ways that don't make logical sense to the listener.

  2. Poor Performance: Tables render slower than CSS-based layouts because browsers need to calculate the entire table before displaying it. This is known as "table blocking render," where the browser must receive all the table data and calculate all cell dimensions before it can display any part of the table. With CSS layouts, browsers can render content progressively as it loads, creating a faster perceived loading experience for users.

  3. Maintenance Nightmare: Table layouts are difficult to update and maintain as they mix content with presentation. Even simple changes like adjusting the width of a sidebar might require modifying dozens of table cells across multiple pages. This tight coupling between content and presentation violates the principle of separation of concerns, making websites brittle and resistant to change.

  4. Responsive Design Limitations: Tables don't adapt well to different screen sizes. In our mobile-first world, this is perhaps the most critical limitation. Table layouts often break or require horizontal scrolling on small screens, creating a frustrating user experience. While there are workarounds like setting display: block on table elements with CSS, these solutions introduce their own complications and defeat the purpose of using tables in the first place.

Table layouts emerged in the late 1990s as a solution to the limited layout capabilities of early CSS. Designers, particularly those transitioning from print media, wanted precise control over positioning that early CSS standards couldn't provide. Tables offered a grid-based approach that allowed for complex multi-column layouts with fixed dimensions—something revolutionary at the time.

The web development community's move away from table layouts wasn't immediate. It took years of CSS advancement, browser standardization, and advocacy from web standards proponents to shift industry practices. The transition was accelerated by the rise of mobile browsing, which made responsive design a necessity rather than a luxury.

Today, using tables for layout is considered an outdated practice that creates unnecessary technical debt. Modern developers have a rich toolkit of CSS technologies—flexbox, grid, and more—that provide all the layout power of tables without the drawbacks.

What to Use Instead:

<div className="container">
  <header>
    <h1>My Website</h1>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
  </header>
  <main>
    <article>
      <h2>Main Content</h2>
      <p>This is where your primary content goes.</p>
    </article>
    <aside>
      <h3>Related Info</h3>
      <p>Additional information goes here.</p>
    </aside>
  </main>
  <footer>
    <p>&copy; 2023 My Website</p>
  </footer>
</div>

Paired with CSS for styling:

.container {
  display: grid;
  grid-template-columns: 3fr 1fr;
  grid-template-areas:
    "header header"
    "main sidebar"
    "footer footer";
  gap: 20px;
}

The modern approach separates content (HTML) from presentation (CSS), allowing each to evolve independently. With just a few lines of CSS Grid code, we can create sophisticated layouts that automatically adapt to different screen sizes. The same HTML structure can be completely restyled for different devices or user preferences without changing the content itself.

CSS Grid, introduced as a standard in 2017, represents the culmination of decades of web layout evolution. It was specifically designed to handle two-dimensional layouts (rows and columns) in a way that's both powerful for developers and performant for users. Combined with CSS Flexbox, which excels at one-dimensional layouts, modern developers have tools that far surpass the capabilities of table layouts while avoiding all their drawbacks.

For complex applications, these CSS technologies are often complemented by responsive design frameworks and component-based architecture, further enhancing maintainability and scalability. This layered approach—semantic HTML for structure, powerful CSS for presentation, and JavaScript for behavior—has become the foundation of professional web development.

Basic HTML Elements

Let's explore some common HTML elements you'll use regularly:

Text Elements

<h1>Heading Level 1</h1>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<p>This is a paragraph.</p>
<strong>Bold text</strong>
<em>Italic text</em>
<a href="https://example.com">Link to website</a>

Text elements form the foundation of web content, allowing you to organize information in a hierarchy that guides users through your page. Headings (<h1> through <h6>) establish the structure of your content, with <h1> representing the most important heading (typically the page title) and subsequent levels indicating subsections of decreasing importance.

Proper heading structure is not just about visual styling—it creates an outline of your page that helps users with screen readers navigate efficiently. A well-structured document should have only one <h1> heading and should not skip levels (e.g., jumping from <h2> to <h4> without an <h3> in between).

Paragraphs (<p>) are the workhorses of web content, containing the bulk of your text. Browsers automatically add margin space before and after paragraphs, creating visual separation that improves readability. Within paragraphs and other text elements, you can use inline elements like <strong> (for importance) and <em> (for emphasis) to highlight key points. These semantic elements are preferable to their presentational counterparts (<b> and <i>), as they convey meaning rather than just visual styling.

Links (<a>) are what make the web a web—they connect pages and resources together. The href attribute specifies the destination, which can be an absolute URL (starting with http:// or https://), a relative URL (pointing to another page on your site), an anchor (starting with # to jump to a specific part of the page), or even a protocol like mailto: for email links. Modern best practices suggest making link text descriptive of the destination rather than using generic phrases like "click here."

Lists

<ul>
  <li>Unordered list item 1</li>
  <li>Unordered list item 2</li>
</ul>

<ol>
  <li>Ordered list item 1</li>
  <li>Ordered list item 2</li>
</ol>

Lists are powerful organizational tools that help structure information in a scannable format. Unordered lists (<ul>) are perfect for groups of items where the sequence doesn't matter, such as navigation menus, product features, or categorized information. By default, browsers display unordered list items with bullet points, though this can be customized with CSS.

Ordered lists (<ol>) are ideal for sequences where the order is meaningful, such as step-by-step instructions, rankings, or chronological events. Browsers automatically number the items, which makes ordered lists particularly valuable for content that might be updated later—add or remove an item, and the numbering adjusts automatically.

Lists can be nested inside each other to create hierarchical structures, and they can contain more than just text—images, links, and even block elements like paragraphs can be placed inside list items. This flexibility makes lists one of the most versatile organizing tools in HTML.

In many modern designs, lists are styled to remove their default markers (bullets or numbers) and spacing, creating custom navigation menus, card layouts, or grid systems. Despite this visual transformation, maintaining the semantic list structure is important for accessibility, as screen readers will announce the list and the number of items it contains.

Images

<img src="image.jpg" alt="Description of the image" />

Images bring visual interest and information to web pages, making content more engaging and easier to understand. The <img> element is a self-closing tag that requires two key attributes: src (the image file path) and alt (alternative text describing the image).

The alt attribute serves multiple critical purposes: it provides a text alternative for screen readers, displays when an image fails to load, and contributes to SEO by helping search engines understand image content. Writing effective alt text is both an art and a science—it should be concise yet descriptive, conveying the image's purpose rather than just literally describing what's visible.

Modern responsive web design often requires images that adapt to different screen sizes. While basic HTML doesn't handle this automatically, you can use additional attributes like width and height to control dimensions, or more advanced solutions like the <picture> element and srcset attribute to provide different image versions for different devices.

Beyond basic images, HTML5 introduced <figure> and <figcaption> elements to semantically associate images with their captions—a common pattern in articles, scientific publications, and photo galleries:

<figure>
  <img src="chart.jpg" alt="Bar chart showing quarterly sales data" />
  <figcaption>Fig. 1: Q1-Q4 Sales Performance (2023)</figcaption>
</figure>

This approach enhances accessibility and provides more context to both users and search engines about the relationship between images and their explanatory text.

Forms

<form action="/submit" method="post">
  <label htmlFor="name">Name:</label>
  <input type="text" id="name" name="name" />
  
  <label htmlFor="email">Email:</label>
  <input type="email" id="email" name="email" />
  
  <button type="submit">Submit</button>
</form>

Forms transform the web from a passive reading experience to an interactive communication channel. They allow users to input data, make selections, and trigger actions—enabling everything from simple contact forms to complex applications.

The <form> element acts as a container for form controls, with the action attribute specifying where the data will be sent and the method attribute determining how (typically get for retrieving data or post for submitting data). Within forms, a variety of input types serve different data collection needs:

Properly labeling form controls with the <label> element is essential for accessibility. Labels provide context about what information is expected and are linked to their corresponding inputs using matching htmlFor and id attributes. This association allows users to click the label to focus the input—a subtle but significant usability enhancement, especially on touch devices.

Modern HTML5 form features include built-in validation attributes like required, min, max, and pattern, which help ensure data quality before submission. These client-side validations provide immediate feedback to users without requiring a round trip to the server, though they should always be complemented by server-side validation for security.

Forms often benefit from thoughtful organization using elements like <fieldset> and <legend> to group related inputs, especially in longer forms where visual chunking improves user comprehension and completion rates:

<fieldset>
  <legend>Contact Information</legend>
  {/* Contact-related inputs here */}
</fieldset>

<fieldset>
  <legend>Shipping Preferences</legend>
  {/* Shipping-related inputs here */}
</fieldset>

This structured approach creates a more navigable experience for all users, including those using assistive technologies.

When to Actually Use Tables

Tables should be used exclusively for tabular data. Here's a proper use case:

<table>
  <caption>Monthly Budget</caption>
  <thead>
    <tr>
      <th>Category</th>
      <th>Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Rent</td>
      <td>$1,200</td>
    </tr>
    <tr>
      <td>Utilities</td>
      <td>$150</td>
    </tr>
    <tr>
      <td>Groceries</td>
      <td>$400</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th>Total</th>
      <td>$1,750</td>
    </tr>
  </tfoot>
</table>

While tables should never be used for page layout, they remain the perfect solution for their intended purpose: displaying tabular data where information needs to be compared across rows and columns. Financial statements, statistical data, comparison charts, schedules, and product specifications are all examples of content that benefits from tabular presentation.

A proper HTML table includes several specialized elements that enhance both its visual organization and accessibility:

For complex tables with hierarchical headers or data that spans multiple rows or columns, additional attributes like colspan and rowspan allow cells to stretch across boundaries:

<table>
  <caption>Product Availability by Region</caption>
  <thead>
    <tr>
      <th rowSpan="2">Product</th>
      <th colSpan="3">Region</th>
    </tr>
    <tr>
      <th>North</th>
      <th>East</th>
      <th>West</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Widget A</td>
      <td>In Stock</td>
      <td>Out of Stock</td>
      <td>In Stock</td>
    </tr>
    {/* More rows... */}
  </tbody>
</table>

Accessible tables should include proper headers and relationships that make the data comprehensible when read linearly by assistive technologies. For especially complex tables, additional attributes like headers and id can explicitly associate data cells with their corresponding headers.

While tables have fallen out of favor for layout, modern CSS has actually enhanced their capabilities for their intended purpose. Properties like border-collapse, table-layout, and even Grid-inspired features like grid-template-columns (which can be applied to tables in many browsers) make it possible to create elegant, responsive tables that present data clearly across different devices.

For extremely complex data sets, tables can be enhanced with JavaScript to add sorting, filtering, pagination, and other interactive features, transforming static data presentation into dynamic, user-controlled experiences.

Conclusion

By using semantic HTML and modern CSS layout techniques, you'll create web pages that are accessible, maintainable, and responsive. Remember that HTML is about structure and meaning, while CSS handles presentation. Keep this separation of concerns in mind as you continue your web development journey!

The evolution of HTML from a simple document markup language to the foundation of the modern web represents one of the most significant technological progressions of our time. What began as a way to link academic papers has become the backbone of a global platform for communication, commerce, education, and entertainment.

As you develop your HTML skills, remember that the best web developers prioritize the needs of their users over technical convenience or flashy effects. This means creating pages that load quickly, work reliably across devices, and are accessible to everyone—including those with disabilities or using assistive technologies.

The principles outlined in this guide—semantic structure, proper element usage, and separation of content from presentation—are not merely technical best practices but ethical guidelines for creating an inclusive web. By following these principles, you contribute to a web that serves everyone, regardless of their abilities, devices, or connection speeds.

The web development landscape will continue to evolve, with new HTML features, CSS capabilities, and JavaScript APIs regularly expanding what's possible in the browser. However, the fundamental concepts explored here will remain relevant. No matter how sophisticated web applications become, they will always be built upon the foundation of well-structured HTML documents.

As you move forward from this introduction, explore the rich ecosystem of web development resources available online—from interactive tutorials and developer documentation to community forums and open-source projects. Remember that every expert was once a beginner, and each website you visit represents an opportunity to inspect its code, learn from its implementation, and gain inspiration for your own creations.

Next up: Learn how to style your HTML with CSS to create visually appealing layouts that adapt beautifully to any screen size and device.