element is a structural and semantic element that defines the main section of a page where the content appears. HTML div element is a generic container for holding other elements.. 2. The aptly named "main" element will change that. We use cookies to improve user experience, and analyze website traffic. This means that if you have separate ID and class-based style declarations that both declare the same property for the same html element, the value from the ID selector is the one that is going to be applied. I’d like to second Ed’s point (in post 15, above) that CSS does in fact care about the difference between IDs and classes, because an ID always has a higher specificity than a class.. Try Examples. It's where you typically put the role="main" attribute if you're working with accessibility . The
element defines a section in a document.. The following example will show you how to style a div tag with the ID attribute. On the other hand, the div class is used for a set of div blocks. Furthermore, the div id is used for a specific div block. Instead much emphasis on "div" as the container of choice is taught. A web page could normally be split into sections for introduction, content, and contact information. HTML5 introduces a lot of new tags, but none of them help you indicate the main point of a webpage. [role=main] {color: red;} which will match all HTML elements with a role attribute set to main or which will only match a main element with a role attribute set to main. In brief, div is a block-level element. The
element must occur only once on a page, and cannot be a child of an
,