Your Coding Journey

Understanding HTML Basics: The Building Blocks of the Web

Welcome to the foundational stone of the internet! HTML, or HyperText Markup Language, is the standard markup language for documents designed to be displayed in a web browser. It defines the structure and content of web pages. Think of it as the skeleton of your website.

Key Takeaway: HTML uses tags to mark up content, telling the browser how to display it.

What are HTML Tags?

HTML elements are the building blocks of HTML pages. An HTML element is defined by a start tag. Some elements have a content inside, and some are empty. An element usually consists of a start tag and an end tag. The content goes between the start and end tags.

The basic syntax for an HTML tag is:

<tagname>Content goes here</tagname>

Some tags are self-closing (void elements) and don't require an end tag, like <img> or <br>.

Common HTML Tags You'll Use

Structure Tags

Content Tags

HTML Attributes

Attributes provide additional information about HTML elements. They are always specified in the start tag and usually come in name/value pairs like: name="value".

Example of an Attribute

The <a> tag commonly uses the href attribute to specify the URL of the page the link goes to:

<a href="https://www.example.com">Visit Example.com</a>

The <img> tag uses src for the image source and alt for alternative text:

<img src="image.jpg" alt="A descriptive image">

A Simple HTML Document Structure

Here's a basic example of an HTML page:

<!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>
    <link rel="stylesheet" href="style.css"> <!-- Link to an external CSS file -->
</head>
<body>

    <header>
        <h1>Welcome to My Website!</h1>
        <nav>
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <article>
            <h2>An Interesting Article</h2>
            <p>This is the first paragraph of my article. It's exciting to learn HTML!</p>
            <img src="article-image.png" alt="An illustrative image">
            <p>Here is another paragraph with a <strong>bold</strong> word and an <em>emphasized</em> one.</p>
        </article>
    </main>

    <footer>
        <p>© 2023 My Website. All rights reserved.</p>
    </footer>

</body>
</html>

This structure is fundamental. As you progress, you'll learn about semantic HTML5 elements like <header>, <nav>, <main>, <article>, <section>, and <footer>, which provide more meaning to your content and improve accessibility and SEO.


Next Steps

HTML provides the structure. To make your web pages visually appealing, you'll need to learn CSS (Cascading Style Sheets). And for interactivity, you'll explore JavaScript.

Keep practicing, and don't hesitate to experiment with different tags and attributes. Happy coding!