PDA

View Full Version : What is the difference between DIV and SPAN tags in HTML?


bloglover
14-02-2010, 06:50 PM
DIV is used to select a block of text so that one can apply styles to it. SPAN is used to select inline text and let users to apply styles to it.

The main difference between DIV and SPAN is SPAN does not do formatting by itself. Also the DIV tag is used as a paragraph break as it creates a logical division of the document in which it is applied. This is in contrast to the SPAN as SPAN simply dos the functionality of applying the style and alignment whatever was specified in it. DIV has ALIGN attribute in it which is not present in case of SPAN. Thus DIV is used in cases where one wants to apply styles to a block of text.

But there may be situations in which there might not be clear well structured block of text to work with. In those cases one can opt to apply SPAN which is used to apply styles inline. That is in other words DIV is generally used for block of text and SPAN is generally used for words or sentences.

ajaypathak
06-03-2010, 06:59 AM
Span can be used in place of Font Tag.