Semantic HTML elements are elements that clearly describe their meaning in a human- and machine-readable way. Examples of semantic HTML elements include <header>
, <footer>
, <article>
, <section>
, and <nav>
. Semantic elements are important because they improve accessibility, aid in search engine optimization (SEO), and make the code more readable and easier to maintain.
Example of using semantic elements:
<article> <header> <h1>Article Title</h1> <p>Published: May 30, 2024</p> </header> <section> <p>This is the content of the article. Semantic HTML elements help in better organizing the content.</p> </section> <footer> <p>Author: John Doe</p> </footer> </article>