CSS Tutorial
Semantic HTML refers to using HTML elements to convey their intended meaning, making it easier for browsers, search engines, and assistive technologies to understand the structure and purpose of a webpage.
<header>
, <main>
, and <footer>
to semantically describe the page's structure.<header>
for a web page's header<nav>
for navigation menus<main>
for the main content<h1>
to <h6>
) to structure your content<p>
) and lists (<ul>
and <ol>
) to organize text<img>
): Describe the image's contents using the alt
attribute to aid screen reader users.role
and aria-label
to provide additional context to assistive technologies.By using HTML elements for their intended purpose, you can create more accessible and maintainable CSS code. For example:
header {
background-color: #333;
color: #fff;
}
main {
margin-top: 20px;
padding: 20px;
background-color: #fff;
}
footer {
background-color: #ccc;
color: #666;
}
This CSS leverages the semantic structure of the HTML to style the header, main content, and footer appropriately.