Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




HTML - Section Tag


The section tag or <section> tag in HTML is used to define a section for a webpage.


Why do we need Section Tag in HTML?


So far we have used <div> tags to represent sections in HTML. However, with Semantic tags, we got the section tag that defines a section for a webpage. The Section Tag usually has a heading and a paragraph.


What does the Section Tag contain?


The section tag usually contains introduction for a webpage, details about chapters for a webpage e.t.c.


Let us understand section tag with the below example.


Example :



<html>
<body>
	<section>
		<h1>First Paragraph</h1>
    	<p>This is the first paragraph</p>
    </section>	
</body>
</html>


Output :




So, if you look at the above code. The section tag represents a section in the HTML page.


<section>
	<h1>First Paragraph</h1>
	<p>This is the first paragraph</p>
</section>

Now, the section tag is not just restricted to one section tag in a webpage. In simple words we can have multiple section tags in an HTML file.


Using multiple section tags in an HTML page


Example :



<html>
<body>		
	<section>
		<h1>First Paragraph</h1>
    	<p>This is the first paragraph</p>
    </section>
    	
	<section>			
		<h1>Second Paragraph</h1>
    	<p>This is the second paragraph</p>
    </section>	
</body>
</html>


Output :




So, if you look the above code, we have two section tags in the HTML page.


<section>
	<h1>First Paragraph</h1>
	<p>This is the first paragraph</p>
</section>

<section>
	<h1>Second Paragraph</h1>
	<p>This is the second paragraph</p>
</section>