HTML div Tag

Advertisements


Description

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.

The difference between the div tag and the span tag is that the div tag is used with block-level elements whilst the span tag is used with inline elements.

Example

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

Here is the csss file style2.css

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

This will produce following result:

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <div> tag also supports following additional attributes:

AttributeValueDescription
autofocus html-5autofocusSpecifies

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm

Advertisements