Inline CSS
We can directly use CSS in div also. This method does not require class. Div in HTML coding is used as a container tag also because it is the one that can contain all other tags.
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Div Tag</title>
</head>
<body>
<center>
<div style="height:300px;
width:500px; color:white;
border:1px solid;
background-color: 009900;">
<!--open tag of Div!-->
<caption>
<h1>w3wiki</h1>
</caption>
<h1>Inline CSS is USED in THIS method.
In this div no class is used.
</h1>
</div>
<!--closing tag of Div!-->
</center>
</body>
</html>
Output:
HTML Div Tag
The HTML <div> tag defines sections in HTML documents, serving as containers styled with CSS or controlled with JavaScript. It’s easily customized using class or id attributes and can contain various content.
Note: Browsers add line breaks before and after <div> elements by default.