CSS — Div Tag
We have learned to apply styling to class and id. Now we will apply styling to group elements by dividing them into divisions. We use <div> tag (short for division) to divide elements in different groups. We have seen a div tag in the example.com
Div doesn’t do anything. It doesn’t give any styling to the content. You can give div tag a class or an id according to your need.
You should never use space in your class or id names because the space will separate them. Instead, you can use a hyphen “-”.
<div class=”first-div”>
<h1>This is some text.</h1>
<p>This is some text.</p>
</div>
Now let’s get the class of this div and style it.
.first-div {
color:green;
background-color:yellow;
width:100px;
}
With the div having a background color you can see the area covered by this div in the webpage. You can also define div width by using % or even the pixel (in this case).
Instructor TARUN KUMAR