PDA

View Full Version : div and span tag


sachin_himcs
04-05-2006, 07:44 AM
sir

what are the differences between div and span tag ?

ronaldb66
04-05-2006, 08:43 AM
Are you familiar with the distinction between block and inline elements, or the box model? If not, the following answer may not mean much to you.
(In short: block level elements stack on top of each other like, well, blocks, and inline elements run from line to line like normal text does).

Anyway: the div element is a block level element by default, meant for marking up logical DIVisions in a page. It is semantically neutral (adds little meaning to the content it marks up). It can contain inline content and just about any other element (block and inline).

The span element is an inline element by default; it, too, is semantically neutral and meant for containing inline content and elements where no other existing inline elements are applicable; sort of like a "spare" element.

khendar
04-05-2006, 08:49 AM
A div is a block type element and a span is an inline type element. If you remember this fact then you will be able to work out when to use which.

Divs should be used for building blocks of content, laying out pages etc. Spans should be used for applying style attributes to a section of text or image.

If you google you'll find heaps of info on this.

oldcrazylegs
04-07-2006, 08:25 PM
block level element

<div>
put alot of stuff here
</div>

inline element

<span style="font:10pt arial,sans-serif;">your text here</span>