Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (20.3k points)

What is the difference between <section> and <div> in HTML? Aren't we defining sections in both cases?

1 Answer

0 votes
by (40.7k points)

<section> 

This means that the content inside will be grouped i.e. it'll relate to a single theme, and will appear as an entry in an outline of the page.

<div> 

This tag does not convey any meaning, aside from any found in it's class, lang and title attributes.

Note: using a <div> tag does not define a section in HTML.

<section>

<section> element is used to represent a generic section of a document or an application. By including the heading like (h1-h6 element) as a child of the <section> element each section can be identified. But, the <section> element is not a generic container element. A general rule is that the <section> element is appropriate only if the element’s contents would be listed explicitly in the document’s outline.

For more information, refer to this document: https://www.w3.org/TR/html/sections.html#the-section-element

<div>

When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the <div> element instead. Here, the <div> element has no special meaning at all. It's used to represent its children. It can also be used with the class, lang, and title attributes to mark up semantics common to a group of consecutive elements.

For detailed information, refer to this document: https://www.w3.org/TR/html/grouping-content.html#the-div-element

Related questions

Browse Categories

...