Macji Pro2010

记录一些应该记录的东东

语义元素和非语义元素

July 13, 2008 - by Macji - HTML/CSS/JS/PHP - html, semantics

在我上一篇文章,我指出“所有语义的元素都不应作为布局来使用”,引来很多反对声音。这里我想解释一下我认为的语义和非语义元素(只是个人观点哦)。


非语义元素,布局元素


我认为的作为布局只有div,span,因为他们只有属性display。一个表示块(断行的),一个表示内联的(不断行的),并无其他实际意义。所以他们只能用来布局,我们可以理解为水泥板和砖头。

The DIV and SPAN elements, in conjunction with the id and class attributes, offer a generic mechanism for adding structure to documents. These elements define content to be inline (SPAN) or block-level (DIV) but impose no other presentational idioms on the content. Thus, authors may use these elements in conjunction with style sheets, the lang attribute, etc., to tailor HTML to their own needs and tastes.

语义元素,非布局元素

以上是常见的一些元素(当然还有很多元素,这里就不一一列出了),我们拿出来比较就会发现,语义元素和非语义元素的差别。最后我还是想强调,所有语义的元素都不应作为布局来使用。(如果你不同意我的观点,你当然坚持自己的,挖哈哈~~)。

1 条评论»