What is the <div> tag in HTML?

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

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved