What are differences between DIV and SPAN?

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.

Questions by GeekAdmin   answers by GeekAdmin

Showing Answers 1 - 22 of 22 Answers

k.jayanthi

  • Oct 9th, 2006
 

here

DIV  and Span is using same purpose but the syntax is different

we are using both for hiding the content.

  Was this answer useful?  Yes

psuresh1982

  • Oct 24th, 2007
 


Suppose if you use div tag for a single line in a big paragraph, it will give the space before and after the div tag line. If you use span then it does not give any space.

For example you have a paragraph. In that paragraph third line you have a word "geekinterview". So you want to highlight the word and also use CSS class.

In the above situation if you use <div class="ssss".....You can see the space between the lines. but if you use <span class="ssss"....You can't see the space. So it is best to use span when you want to apply some style for a single line.

There is no align property in span tag. At that time you need to use div tag.

  Was this answer useful?  Yes

DIV is a HTML tag in advance. Genarally we use table & div tag for the loyout.  If we use table tag, the site will take lot of time to load, but use of DIV tag is quick & Advance.  Especially in search engine, we should use Div tag to load easy. It has attributes, position and all other feature like table tag. Nowadays everybody prefers DIV tag for quick loading.

Whereas, SPAN is a like sub tag (my own language) to apply styles for the specified text, bg and whatever it may. it is applicable only for the specified content in-between the SPAN tag.  we can use it for highlight some text, to fix extra space for any other text or content like.

Hope u'll understand. 

Abzetdin ADAMOV

  • Jun 22nd, 2014
 

DIV is container or area (by default rectangular, but may be even rounded using CSS3) that generally is used to layout element or group of elements.

SPAN doesn't have own container or area, it is used just for formatting elements within SPAN block.

  Was this answer useful?  Yes

NandiniChatterjee

  • Oct 16th, 2014
 

Div is a block level object, that is, It contains a HTML box model around itself by default, and its width is 100% in respect to the immidiate parent of it, while span is an inline object and does not contain any box module with it.Its width is the with of its child object.

  Was this answer useful?  Yes

sanjay rana

  • Mar 29th, 2016
 

The < span > element is an inline element that is often used as a container for some text When used together with CSS, the < span > element can be used to style parts of the text:

The < span > element has no required attributes, but style and class are common.

When used together with CSS, the < span > element can be used to style parts of the text:

The < div > element is a block-level element that is often used as a container for other HTML elements.

The < div > element has no required attributes, but style and class are common. When used together with CSS, the < div > element can be used to style blocks of content:

  Was this answer useful?  Yes

Arjya Bhattacharya

  • Sep 27th, 2016
 

< div > is used for denoting divisions in a paragraph in HTML.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions