How to use the div tag in HTML

YT_Xaos

I am new to HTML and I was wondering how to use div tag, because every time I use it it doesn't do anything. What does it do and how do I use it?

AGE

The div tag works as a block element, meaning it allows you to insert into it content and other elements. It is a basic building block of any HTML page. Below is a simple example and you can follow this link to the official documentation for further insight.

.title {
  background-color: gray;
  font-weight: bold;
}
.body {
  background-color: black;
  color: white;
}
.something {
  color: black;
  background-color: white;
}
<div class="title">
  Hello world! I can be the title of your web page
</div>
<div class="body">
    <div>I can be the main body of your web page</div>
    <div class="something"> with lots of other div elements comprising</div>
    <div> the look and feel of the web page.</div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related