Trusted answers to developer questions

What is the <div> tag in HTML?

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

The <div> tag in HTML

The <div> tag is used as a container for other tags in an HTML page. The <div> tag can contain any element, and almost all browsers add line breaks before and after the <div> tag. The structure of the <div> tag is as follows:

<div>Text or Tags here</div>

Example usage of the <div> tag

The following code provides an example:

In the example above, 2 <div> tags are used, where the first one has class divA and the second one has class divB. These classes are defined in the CSS tab which results in the styling of the div. The <div> tag can contain any number of tags (even <div> tags as well).

Browser Support

Browser Support
Chrome Yes
Firefox Yes
Safari Yes
Edge Yes
Opera Yes

RELATED TAGS

html

CONTRIBUTOR

Hammad Nasir
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?