All TalkersCode Topics

Follow TalkersCode On Social Media

How To Use Div Tag In HTML To Divide The Page

Last Updated : Jan 1, 2023

How To Use Div Tag In HTML To Divide The Page

In this tutorial we will show you the solution of how to use div tag in HTML to divide the page, all of us know that every element in html, acts like an element.

As like others, the div elements is different and it cover the full line of website it not matters weather the content or text is short or long, but here our concept is to divide the page into two portions.

So, here in this article we covers how to divide page vertically as well as horizontally using div tags.

Step By Step Guide On How To Use Div Tag In HTML To Divide The Page :-

As, div tags covers full line. So, we first create two div tags with some height and in first we use two more division tags to page vertically and in second tag, we use two other division tags to show you how to divide the page horizontally.

You can also use more than two division vertically and horizontally to make more than two sections of page or screen.

<!DOCTYPE html>
          <title> Title of the document<title>
   <div style="height: 350px;width: 100%;">
        <div style="background-color: blue; height: 350px; width: 50%;float: left;">
            div one
        <div style="background-color: red; height: 350px; width: 50%;float: left;">
            div two
    <div style="height: 400px; width: 100%;">
        <div style="background-color: green;height: 200px; width: 100%;">
            div three
        <div style="background-color: yellow;height: 200px; width: 100%;">
            div four
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  4. Thirdly, <body> tag is used to define the webpage body. All the contents to show on website are written here. In the body tag, we create six division.
  5. First we create two divisions and in both of them two more divisions, as a result the division that are created under a particular div, occupies the area and covers the division the under this known as parent div.
  6. In code we use different background colors to show you the area that a particular division covers.
  7. In first div, two more div are created with half the width of parent div and to divide the page vertically whereas in other section of div, we create div with half the height of parent div to divide the page horizontally.
  8. You are able to customize the height and width according to your choice.
  9. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

In conclusion, we can say with the help of this article we are able to divide the html page vertically and horizontally.

This is only done with the help of height and width concept with parent division.

In further session we will also help you to make a creative webpage with the help of division tags only that divide the page vertically and horizontally.

I hope this tutorial on how to use div tag in HTML to divide the page helps you and the steps and method mentioned above are easy to follow and implement.

Latest Tutorials