1. Semantic HTML Elements

Semantic elements clearly describe their purpose, making your code more readable and accessible for assistive technologies. Here are some commonly used semantic elements:

Example:


<header>
    <h1>Welcome to My Website</h1>
</header>

<main>
    <section>
        <h2>About Us</h2>
        <p>We provide quality content for learning HTML.</p>
    </section>

    <aside>
        <p>Sidebar content, such as recent posts or links.</p>
    </aside>
</main>

<footer>
    <p>Copyright 2025.</p>
</footer>
            

2. HTML Attributes

Attributes provide additional information about an element, such as setting its behavior or styling. They are included inside the opening tag.

Common Attributes:

Example with Attributes:


<a href="https://example.com" title="Go to Example">Visit Example</a>

<img src="image.jpg" alt="A description of the image">
            

3. Linking External Resources

Webpages often use external resources like stylesheets, scripts, or images to enhance functionality. Here’s how to include them:

3.1 Linking a CSS File:

Use the `<link>` tag in the `<head>` section:


<link rel="stylesheet" href="styles.css">
            

3.2 Linking a JavaScript File:

Include the `<script>` tag, usually just before the closing `</body>` tag:


<script src="script.js"></script>
            

3.3 Adding Images:

Use the `<img>` tag to add images:


<img src="logo.png" alt="Company Logo" width="200" height="100">
            

4. Advanced Best Practices

Back