开发者

html section or div?

开发者 https://www.devze.com 2023-02-24 21:49 出处:网络
My website has a profile page. I have something like: <h1>Foo bar profile</h1> <div> <h2>Address</h2>

My website has a profile page. I have something like:

<h1>Foo bar profile</h1>

<div>
<h2>Address</h2>
<p>Foo bar street, 55</p>
<p>Foo city</p>
</div>

<div>
<h2>Contact information</h2>
<p>foo@bar.com</p>
<p>55-5555-5555</p>
</div>

Should I use divs or sections to wrap this kind of content?开发者_如何学Python With sections, should i change h2 to h1? I don't know what is right. Thank you.


Why not make use of the <address> tag?

<h2>Contact information</h2>
<address>
<a href="mailto:foo@bar.com">foo@bar.com</a><br />
55-5555-5555
</address>


its just fine..

still if u want to learn html5 i will recommend

Tutorials:

  • http://slides.html5rocks.com/#slide1 (built using HTML5)
  • http://diveintohtml5.ep.io/
  • http://html5tutorial.net/

Demos: http://html5demos.com/


I wouldn't call that a <section> although that all might be contained in a <section class="contact">

I recommend the hCard microformat or the HTML5 vCard microdata definition derived from it. It's a set of well defined class names to use to define the pieces of your contact information.

You can use what tag types you want, set the appropriate classes, then style them with CSS - for example is "Address" is not really a 2nd level heading just style it to look like one (if that's the look you want) based on it being within a <div class="vcard">

You might start out like...

<section class="userprofile">
    <div class="vcard">
        <div class="adr">
             ... etc. ...
        </div>
    </div>
</section>

The HTML5 way uses itemprop instead of class - see http://www.html-5.com/microdata/rich-snippets/addresses/ for some more explanation and samples.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号