开发者

Html DIV and SPAN tags

开发者 https://www.devze.com 2023-01-16 02:39 出处:网络
Can I make DIV tag function as SPAN tag? i开发者_如何学Go.e., removing line-break before and after the DIV tag.Yes, use CSS

Can I make DIV tag function as SPAN tag? i开发者_如何学Go.e., removing line-break before and after the DIV tag.


Yes, use CSS

display: inline


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 :)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号