tags:

views:

57

answers:

3

Hi all..

Can I make DIV tag function as SPAN tag? i.e., removing line-break before and after the DIV tag.

+5  A: 

Yes, use CSS

display: inline
Sjoerd
+5  A: 

DIVs are block level elements which means they have a default display:block - give it display:inline (which SPANs have) to override this. Please be a good programmer and do this with CSS not inline styles :)

annakata
+3  A: 

As others have said, generally you can use display: inline; but beware of the beast...

Make sure you're aware of differences between browsers on display: inline; and display: inline-block; and when you might want to use which:

http://www.brunildo.org/test/InlineBlockLayout.html

http://www.brunildo.org/test/inline-block.html

joshcomley
inline-block is a wonderful tool, but not x-browser safe
annakata
@annakata, yep, you have to use `display: inline;` in IE but `display: inline-block;` elsewhere for the same effect. Sigh.
joshcomley