We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Software

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What are DIV Tags?

By Lynne William
Updated: May 17, 2024

DIV tags are codes that define a section in an HTML (HyperText Markup Language) document. A section in HTML can also be described as a "division," which is the origin of the abbreviation used for the name of the DIV tag.

DIV tags, like SPAN tags, do not apply meaning to content as is the case with most HTML For instance, "P" creates a paragraph, "B" creates boldface, and "H" creates a heading. DIV doesn't actually do anything at all by itself; it simply defines a block of content on the page to which other attributes can be globally applied. DIV tags indicate that a block of code belongs together.

A beginning DIV tag specifies that "this section of code starts here" and the ending DIV tag states, "this section of code ends here." In defining sections of a web page into clearly delineated sections, it makes it much easier to manage and manipulate the code. DIV tags can be used in conjunction with other codes, such as the STYLE code, in order to apply an attribute to an entire section. For example:

***
This is some black text, which comes before the following burgundy text DIV tag section.
<div style="color:#610B0B;">
<h1>This is the header in this div section, which will show up in burgundy text.</h1>
<p><b>This is a paragraph in this div section, which will not only show up in burgundy text but in boldface as well. </b></p>
</div>
This is some more black text, which appears after the section in burgundy text.
***

Another common usage of the DIV tag is to align entire blocks of content on a web page left, right, or in the center of the page. In addition to "align," other frequently used attributes assigned by a DIV tag are: id, class, title, style, dir, and lang. For novice web page authors, it's important to remember that the DIV tag is not to be used as a replacement for the P (paragraph) tag. The P tag should only be used for individual paragraphs, while the DIV tag should be used to define larger, more general sections or divisions of a document.

DIV tags can be nested, meaning that you can have a beginning and ending set of DIV tags inside of another set. Care must be taken to ensure that any coding added is placed inside the correct set of DIV tags. It is also important to note that web browsers will usually place a line break before and after a DIV element when it displays a web page that contains it. This needs to be taken into consideration when designing the surrounding code.

Experienced website authors recommend the judicious used of the DIV tag when coding HTML, or else it has a tendency to cause a loss of the very thing the tag was meant to create: clarity. Care should be taken not to let "divitis," as experienced coders call the overuse of DIV tags, muddle up and over-complicate the web page coding.

WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
Share
https://www.wisegeek.net/what-are-div-tags.htm
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.