Date First Published: 27th February 2023
Topic: Web Design & Development
Subtopic: Web Development
Article Type: Computer Terms & Definitions
Difficulty: MediumDifficulty Level: 5/10
Learn more about what the HTML <div> tag is in this article.
In HTML, the <div> tag is used to define a division in a document. This tag separates and groups data in a webpage, such as text, images, videos, headers, footers, and other types of content, and is used as a container for HTML elements. The <div> tag can then be styled by specifying a name on the class id or name attribute and then using CSS to apply the style to an element with that name or id. It can also be manipulated using client-side scripting, such as JavaScript and server-side scripting, such as PHP. This tag is supported by all major web browsers.
This tag is a non-semantic tag. Even though it is useful for styling and formatting webpages, it tells nothing about the purpose of the content. Website owners use id and class attributes to specify the meaning of the non-semantic elements and semantic tags, such as <article> and <footer> were introduced in HTML5. What these semantic tags define is very obvious.
Browsers automatically place a line break before and after the <div> element as <div> is a block-level element.
The <div> element cannot be placed within a <p> tag as this will cause the paragraph to break.
An example of the <div> tag that is styled with CSS along with the output can be seen below:
Output:
The <div> tag only contains one attribute that has been deprecated.
Attribute | Description |
---|---|
Align | Used to align the content in a div tag. Not supported in HTM5. Instead, the CSS text-align property should be used for alignment. |
If so, it is important that you tell me as soon as possible on this page.
Network Services Network Setups Network Standards Network Hardware Network Identifiers Network Software Internet Protocols Internet Organisations Data Transmission Technologies Web Development Web Design Web Advertising Web Applications Web Organisations Web Technologies Web Services SEO Threats To Systems, Data & Information Security Mechanisms & Technologies Computer Hardware Computer Software Ethics & Sustainability Legislation & User Data Protection