tags:

views:

62

answers:

6

I want to make a small text-height div run with the text. My code looks like this:

blah blah blah <div style="display:block; float: left; width: 100px">[IN A DIV]</div> blah

it should come out to look like:

blah blah blah [IN A DIV] blah blah

but it always comes out as:

blah blah blah 
[IN A DIV]
blah blah
+2  A: 

Change display:block to display:inline

Matthew Jones
+9  A: 

Why do you want a <div>? <div> is a block-level element and not meant for what you want.

Try a <span>, as that is what should be used for inline stuff and would be more semantically accurate.

Required reading: Block and Inline elements.

Paolo Bergantino
thanks for this. Helped a lot.
laxj11
@laxj11: If this solved your problem, you should except an answer
gonzohunter
hehe. couldn't do that when I originally asked this question
laxj11
+1  A: 

display: inline; and get rid of the float.

Jason
+2  A: 

That's because a <div> is a block-level element. A block will always break up the flow of the objects around it. You either want to set your <div> to display: inline; or use a <span> instead. Spans are inline by default.

Mark Hurd
+1  A: 

use a <span>, which is the inline equivalent of a div.

Alex Brown
+2  A: 

Use display:inline instead of display:block or better yet use a SPAN instead of a DIV

ichiban