Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Div positioning 1

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi,

I am having some problems getting my head around div positioning - a lot of the tutorials online seem to deal with more complicated stuff. What I am trying to do is have a text box and a div right next to it saying "Hello World"

So far I have:

<input type="text">
<div style="border:1px solid black;width:100px;position:>Hello world</div>

I have tried float:right but this sticks it on the very edge of the screen...

Thanks very much

Ed
 
3 things:

1. Divs are block level elements by default, this means they have a carriage return or line feed before and after them. Which inherently sends them down one line.

2. Floating moves the element as far to the direction specified as it can. Float right moves it all the way to the right. Float left moves it all the way to the left.

3. Why a DIV? Divs are boxes that hold more content not only text, if you want just a text holding box use a span or even a label since you are using it with an input. They will sit nicely beside an input without any extra CSS.


If you really must use a DIV give it a display of inline.
Code:
<div style="display:inline;"></div>

That turns the div into an inline element which by default sit next to each other and have no carriage returns.

Look into block and inline elements for more info.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top