What is the difference between <section>
and <div>
in HTML? Aren't we defining sections in both cases?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
Here is a tip on how I distinguish couple of recent html5 elements in the case of a web application (purely subjective).
<section>
marks a widget in a graphical user interface, whereas<div>
is the container of the components of a widget like a container holding a button, and a label etc.<article>
groups widgets that share a purpose.<header>
is title and menubar.<footer>
is the statusbar.<section>
marks up a section,<div>
marks up a generic block with no associated semantics.The
<section>
tag defines sections in a document, such as chapters, headers, footers, or any other sections of the document.whereas:
The
<div>
tag defines a division or a section in an HTML document.The
<div>
tag is used to group block-elements to format them with CSS.<section>
means that the content inside is grouped (i.e. relates to a single theme), and should appear as an entry in an outline of the page.<div>
, on the other hand, does not convey any meaning, aside from any found in itsclass
,lang
andtitle
attributes.So no: using a
<div>
does not define a section in HTML.From the spec:
<section>
(https://www.w3.org/TR/html/sections.html#the-section-element)
<div>
(https://www.w3.org/TR/html/grouping-content.html#the-div-element)
Just an observation - haven't found any documentation corroborating this
If a section contains another section, a h1-header in the inner section is displayed in a smaller font than a h1- header in outer section. When using div instead of section the inner div h1-header is diplayed as h1.
-- the Level2 - header is displayed in a smaller font than the Level1 - header.
When using css to color h1 header, the inner h1 were also colored (behaves as regular h1). It's the same behaviour in Firefox 18, IE 10 and Chrome 28.
<div>
—the generic flow container we all know and love. It’s a block-level element with no additional semantic meaning (W3C:Markup, WhatWG)<section>
—a generic document or application section. A normally has a heading (title) and maybe a footer too. It’s a chunk of related content, like a subsection of a long article, a major part of the page (eg the news section on the homepage), or a page in a webapp’s tabbed interface. (W3C:Markup, WhatWG)My suggestion: div: used lower version( i think 4.01 to still) html element(lot of designers handled that). section: recently comming (html5) html element.