Nothing in the spec says you can't or shouldn't style HTML5 elements such as <section>
or <article>
. It only says that you shouldn't place a semantic HTML5 element somewhere 'for the sake of' styling something. Use a <div>
instead.
So if you have a semantic reason to add the <section>
or <article>
somewhere, then by all means add it AND also feel free to style it as well. But if you have to wrap a section of your mark-up for styling purposes (eg. to add a border, or float left etc.), but that section does not have any semantic meaning in your mark-up, then use a <div>
.
For instance:
<div class="mainBox">
<nav class="breadcrumbs">
<ol>
<li>...list of links (snip)....</li>
</ol>
</nav>
<section>
<h1>Latest Tweets From Twitter</h1>
<article>
//... a Tweet (snip)... //
</article>
<article>
//... a Tweet (snip)... //
</article>
//... lots more Twitter posts (snip)... //
</section>
</div>
The <section>
element is the main part of your page (ie. your list of tweets) and also has a heading at the start which is required. But it's wrapped in a div.mainBox element because maybe you want to wrap a border around the both the breadcrumbs and section parts, ie. it's purely for styling. But there's nothing to stop you styling the <section>
and <article>
elements also.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…