When to Span and when to Div Home
When to Span and when to Div
8/12/2005 posted by Kevin S
|
HTML Span and Div uncovered
The <span> tag has very similar attributes to the <div> tag.
The <div> tag affects the style of text it encloses.
Items enclosed by the <span> can be given specific style attributes and can also be aligned.
The main difference between <span> and <div> tags is that <span> does not do any of its own formatting,
wheras the <div> tag acts as a paragraph break, because it is setting a logical division in the document.
The <span> tag will only tell the browser to apply the style and alignment rules to whatever is contained within the <span> enclosure.
<span> - no formating of its own, apply these yourself with styles.
<div> will always apply a paragraph break ( i.e. <p/> ).
|