InterviewSolution
| 1. |
What are semantic elements in HTML? |
|
Answer» Semantic elements are the TAGS which have both meaning to the browser and developer. In other words, semantic elements are the tags in plain English which says what it does. EXAMPLE CONSIDER <div> and <span> which says nothing about what they do or what they are to a normal person. They are non-semantic elements. On the other hand, elements like <form> and <table> tells what they are and do exactly the same thing. They are semantic elements. Some of the Semantic elements with their brief descriptions are -
Below is an example of a website created using semantic elements. <!DOCTYPE html> <html> <style> nav{ background: yellow; padding: 2%; font-size:1.2rem; } footer{ background: yellow; padding: 1%; font-size:1rem; } main, header{ text-align: center; } </style> <body> <nav> <a href="https://en.wikipedia.org/wiki/Google_Chrome">Chrome</a> | <a href="https://en.wikipedia.org/wiki/Firefox">Firefox</a> | <a href="https://en.wikipedia.org/wiki/Safari_(web_browser)">Safari</a> | <a href="https://en.wikipedia.org/wiki/Internet_Explorer">Internet Explorer</a> </nav> <header> <h1>Web Browsers</h1> <p>Google Chrome and Firefox are the most used browsers today.</p> <hr> </header> <main> <article> <section> <h1>Google Chrome</h1> <p>Google Chrome is a free, open-source web browser developed by Google, released in 2008.</p> <figure> <img src="https://source.unsplash.com/900x600/?nature" width="100%" alt="Nature"> <figcaption>Random Nature image</figcaption> </figure> </section> <section> <h2>More Information</h2> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde consequatur doloremque reiciendis saepe! Iure dicta harum molestias laborum accusantium reprehenderit SUNT, repudiandae eos aut itaque dolores et repellendus. Dignissimos, voluptate. </p> <hr> </section> </article> <article> <section> <h1>Mozilla Firefox</h1> <p>Firefox is a free, open-source web browser from Mozilla, released in 2004.</p> <figure> <img src="https://source.unsplash.com/900x600/?water" width="100%" alt="Water"> <figcaption>Random Water image.</figcaption> </figure> </section> <section> <h2>More Information</h2> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde consequatur doloremque reiciendis saepe! Iure dicta harum molestias laborum accusantium reprehenderit sunt, repudiandae eos aut itaque dolores et repellendus. Dignissimos, voluptate. </p> </section> </article> </main> <footer> <p>Posted by: Sam Paul</p> <p>Contact information: <a href="mailto:someone@example.com"> someone@example.com</a>.</p> </footer> </body> </html>Save the above code as demo.html and open in any browser. |
|