As you know HTML is used to create the structure of a website. But you have to wonder to know about its categorization.
Most commonly HTML has two parts: semantic and non-semantic HTML.
And HTML elements are also divided into semantic and non-semantic elements.
In this post, we discuss HTML's semantic and non-semantic elements. Differences between them.
So let’s start.
First, understand the semantic HTML.
What is semantic HTML?
As the name suggests semantic HTML describes the meaning of its elements on a website or web page to both developers and other devices like (search engines, and browsers)
Semantic HTML includes those HTML elements which have meaning and structure.
What are semantic HTML elements?
Semantic HTML elements are elements that have proper meaning and define structure.
For example, element <p> </p> describes that the content in between is a paragraph.
The series of <h1></h1>…to.. <h6></h6> describes that content of these elements consider as a heading.
HTML 4 Semantic elements
✒ <h1> to <h6> elements :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <html> <head> <title>headings</title> <style> h1,h2,h3,h4,h5,h6{ color:red; background-color:orange;} </style> </head> <body> <h1>Most important heading</h1> <h2>Most important heading</h2> <h3>Most important heading</h3> <h4>Less important heading</h4> <h5>Less important heading</h5> <h6>Less important heading</h6> </body> </html> |
Output:-
✒ <blockquote> :
✒ <p>:
✒ <form>:
target: describes where you want to open the page, within a page or in a new tab.
method: contains a post and get methods.
action: an URL of the page where you want to redirect.
✒ <table>:
✒ <img>:
✒ <abbr>:
✒ <code>:
✒ <address>:
✒ <em>:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <!Doctype html> <html> <head> <title>semantic</title> </head> <body> <!--blockquote--> <h3>This is example of blockquote.</h3> <blockquote cite="https://www.healthathomes.com/"> <p>According to the www.healthathomes.com-"Health at Homes provides integrated healthcare services, by combining medical expertise with convenience and affordability with an aim to make professional services easily accessible to people on time."</p> </blockquote> <p>This is simple text.</p> <!--abbriviation--> <h3>This is an example abbrviation element. </h3> <p>This is <abbr title="world wide web">WWW</abbr> the accronym text.</p> <!--em tag--> <h3>This is an example emphasize element. </h3> <p>The <em>emphasize</em> text.</p> <h3>This is an example of address element. </h3> <h4>Contact Us</h4> <address> <p>B-5,city square,<br> lunkcikui,Vadodara.</p> </address> <h3>This is an example code element. </h3> <code> var a,b,c;<br> c=a+b; </code></br> <h3>This is image element example.</h3> <img src="/download (1).jpeg" height="100" width="200"></img> </body> </html> |
Output:-
Semantic HTML 5 elements
which are the HTML 5 semantic elements?
<header>
What <header> includes?
Where <header> element is not used?
- Some places like the footer of the page(<footer>) and in <address>.
- Can’t use in <h1> to <h6>.
<nav>
Which type of links includes in <nav>?
What can not be included in <nav>?
<section>
What <section> includes?
<article>
<aside>
<figure>
<figcaption>
<details>
<main>
What to include in <main> element?
- Navigation links
- Website logo
- Copyright information
- Sidebar
<mark>
<summary>
<footer>
What to include in <footer> tag?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | <!DOCTYPE html> <html> <head> <title>Structure of HTML5 </title> <style> body{ font-family:Arial; background-color:black; } h1{ border:4px inset blue; padding:20px; text-align:center; color:red; } #city{ border:4px inset blue; padding:15px; text-align:center; color:red; } nav{ color:green; } nav,article{ border:4px inset #e6fe4c; padding:4px; } ul li { display:inline; padding:3px; } a{ text-decoration:none; padding:2px; font-size:20pt; font-weight:bold; background-color:mediumseagreen;} section{ border:4px inset violet; padding:4px; color:red; } h2{ padding:4px; color:blue; } h3{ color:white; } section,article{ margin:30px; } footer{ border:4px inset blue; padding:4px; margin:10px; text-align:center; color:red; } main{ border:4px inset #3f3; margin:2px;} </style> </head> <body> <h2 id="city">Biggest cities of India</h2> <nav> <ul> <li> <a href="#">Mumbai</a> </li> <li><a href="#">Ahmedabad</a> </li> <li><a href="#">Banglore</a> </li> </ul> </nav> <main> <section> <h2>About Cities</h2> <article> <h3>Mumbai</h3> <p>Mumbai is capital of Maharastra.Entertainment indusrty is located here.Hotel Taj and gate way of india are the famous place for visiting. </p> </article> <article><h3>Ahmedabad</h3><p>Ahmedabad in capital of gujarat.Visiting places are Kakariya talav,sidi sayad jali.Navratri festival is celebrated here.</p></article> <article> <h3>Banglore</h3> <p>Banglore is the capital of the Indiaan southern state karnataka.The center of india's high-tech industry.</p> </article> </section> </main> <footer> <p>All copyrights are reserved.</p> </footer> </body> </html> |
Output:-
Example of structure of HTML 5 |
What is non-semantic HTML?
What are non-semantic elements?
List of non-semantic elements
<div>:-
<span>:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | <html> <head> <title>non-semantic</title> <style> #main{ background-color:slateblue; height:auto; width:auto; margin:50px;} .header{ text-align:center; color:slateblue; background-color:pink; margin:20px; padding:4px;} .navratri,.janmastami,.ganesh{ background-color:skyblue; color:slateblue; padding:5px; margin:40px;} span{ font-weight:bold;} </style> </head> <body> <div id="main"> <div class="header"> <h1>Festivals of india</h1> </div> <div class="navratri"> <h2>Navratri</h2> <p>Navratri festival is the festival of gujarati. During festival people pray godess Amba and play <span>garaba</span> in night. </p> </div> <div class="janmastami"> <h2>Janmastami</h2> <p>Janmastami festival is celebrated in memory of birth of <span>Lord Krishna.</span> </p> </div> <div class="ganesh"> <h2>Ganesh Chaturthy</h2> <p>Like navratri Ganesh chaurthi is biggest and main festival of maharastrian.The <span>lalbaug ka raja</span> is famous for biggest statue of Ganpati bapa. </p> </div> </div> </body> </html> |
Example of non-semantic html |
What is the difference between semantic elements and Non-semantic elements?
Semantic vs. Non-semantic html elements |
🔸While using non-semantic <div>, the developer uses either class or id attribute to create a structure.
The semantic elements don’t need any attribute to create structure.
🔸It’s easy to use semantic elements.
For example, for heading use <header>.
Using a non-semantic <div> tag you have to specify its purpose by defining the attribute name.
For example, for heading, when giving a class name, it is the difference from one developer to another. One developer gives the class name header, the second one gives the heading and another gives the head. So here attribute name is different from the person to person.
0 Comments