Semantic HTML elements:
These elements simply mean, elements with meaning. The reason being, there definition in the code tells the browser and the developer what they are supposed to do. Framing in simpler words, these elements describe the type of content they are supposed to contain.
Following is the list of some semantic elements :
- article
- aside
- details
- figcaption
- figure
- footer
- form
- header
- main
- mark
- nav
- table
- section
Example: The following program contains some semantic elements to explain the context better:
<!DOCTYPE html>
< html >
< head >
< title >my web page</ title >
< style type = "text/css" >
h1{
color: green;
font-weight: bold;
}
table, tr, td{
border: 1px solid black;
}
th{
font-weight: bold;
color: red;
}
</ style >
</ head >
< body >
< article >
< h1 >GeeksforGeeks</ h1 >
< p >A Computer Science Portal for Geeks</ p >
</ article >
< table >
< tr >
< th >head1</ th >
< th >head2</ th >
</ tr >
< tr >
< td >A</ td >
< td >0</ td >
</ tr >
< tr >
< td >B</ td >
< td >1</ td >
</ tr >
</ table >
</ body >
</ html >
|
Output:

Non-Semantic elements: Unlike, semantic elements they don’t have any meaning. They don’t tell anything about the content they contain. They can be used with different attributes to mark up semantics common to a group.
Following is the list of some non-semantic elements:
Example:
The following code depicts how non-semantic elements work:
<!DOCTYPE html>
< html >
< head >
< title >my web page</ title >
< style type = "text/css" >
span{
color: green;
font-size: 40px ;
font-weight: bold;
}
</ style >
</ head >
< body >
< div >
< span >GeeksForGeeks</ span > < br >
A computer science portal for geeks
</ div >
</ body >
</ html >
|
Output:

Difference between semantic and non-semantic elements:
Semantic elements |
Non-Semantic elements |
they have meaning |
they don’t have meaning |
they describe how the content within them is supposed to behave |
they can contain anything |
they have specific attributes for their structure |
‘class’ attribute can be used to work with their structure |
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
11 Sep, 2020
Like Article
Save Article
Vote for difficulty
Current difficulty :
Easy