tags:

views:

21

answers:

3

I have the following code but the image is wrapping below the input box. What am I doing wrong?

<input type=text name='test" />
<div style="float:left"><img src="test.jpg" /></div>
A: 

the <div> tag it's a block, it mean have a new line before and after, try to use a <span>

<span ><img src="test.jpg" /></span>
Cesar
Or just drop the span and leave the `img` there alone. Also, the correct term is "block level element". The `div` is not a "block" ;)
Yi Jiang
maybe yes, i guess the div it's there for a reason... i hope :)
Cesar
@ Yi, I tried this but the image still wraps below the input
jim
well, you can also <img src="test.jpg" display:inline; " />
Cesar
A: 

You want this instead.

<input type="text" name="test" style="float:left" />
<div><img src="test.jpg" /></div>

It also works just as well if you remove the <div>

Thomas
Thanks, This worked.
jim
A: 

Your div is floated left from the point at which it would normally appear in the source order, ie on a new line below the input. Try floating the input as well.

Chris Cox
Thanks Chris, floating the input was what did the trick for me. Thanks.
jim