HTML <div> Element: Generic Block Container

The HTML <div> element is a generic block container. It is useful for grouping content for CSS layout or JavaScript when no more meaningful semantic element describes the group.

<div class="notice">
  <p>Shipping closes at 5 PM.</p>
</div>

class and id Top ↑

Use class for reusable styling/hooks and id for a unique element identifier when needed. Avoid using IDs only because older examples did so.

Prefer semantic elements when they fit Top ↑

If the region is navigation, main content, an article, aside, header or footer, the corresponding semantic element usually communicates more meaning than a generic <div>.

Do not use the old align attribute Top ↑

The historical align attribute on <div> is obsolete. Use CSS such as text-align, flexbox or grid.

<div class="centered">Centered text</div>

.centered { text-align: center; }

Position a div with CSS · Show supporting content from an interaction · Toggle a div on click

DIV alignment demo Show/hide with JavaScript Message layer





plus2net.com







krish

05-07-2013

pls give us some more exaples
Sendyona daniel

31-05-2016

how can i fit well the length of the menu from the extreme end to the extreme end of the compter monitor and to fit on all screens
chethan

03-03-2017

provided information is good one and easy to understand



✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer