Friday, July 24, 2015

Div vs Span

Div

Block Element
Legal to have a span within a DIV

w3c Describes span as follows;

"The div element has no special meaning at all. It represents its children. It can be used with the class, lang, and title attributes to mark up semantics common to a group of consecutive elements."

Span

Inline Element
Illegal to have a DIV within a span


w3c Describes span as follows;

"The span element doesn't mean anything on its own, but can be useful when used together with the global attributes, e.g. class, lang, or dir. It represents its children."

Reference:
http://www.w3.org/TR/html5/grouping-content.html#the-div-element
https://www.w3.org/wiki/HTML/Elements/span

No comments:

Post a Comment

Please leave your comments here...