How to create a section in a document in HTML?

Use the <div> tag to add a section in a document. The HTML <div> tag is used for defining a section of your document. With the div tag, you can group large sections of HTML elements together and format them with CSS.


You can try the following code to create a section −

<!DOCTYPE html>
      <title>HTML div Tag</title>
   <link rel = "stylesheet" href = "style2.css">
      <div id = "contentinfo">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>

The following is the css file style2.css

#contentinfo p {
   line-height: 20px;
   margin: 30px;
   padding-bottom: 20px;
   text-align: justify;
   width: 140px;
   color: red;