File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes best way to position text in HTML page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "best way to position text in HTML page" Watch "best way to position text in HTML page" New topic

best way to position text in HTML page

ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 131
What is the est way to position text in HTML, so it can work with any screen resolution,
I haev tried <div> which adds a line break , and <span> it works okay
but is it the right tool for position text (using <span style="left: 30%; position: relative; "> tag)
I use to use tables to do this, ut has to be a better way i guess
for example i want to display some text inline as below
the requirement is that the distance between them stays when i change screen resolution
PO Number : 100000122 Date: 27/10/03 Amount: 1222.00 USD
I tried this as below
<span class="style" id="po">Purchase Order Number : </span>10000122 <span class="style" style="left: 10%; position: relative; ">Date :</span> <span style="left: 15%; position: relative; "> 27/10/03 </span> <span class="style" style="left: 25%; position: relative; " >Total Amount :</span> <span style="left: 30%; position: relative; ">7,250.00 GBP</span>

I guess this is lot of coding to achieve it,
Any help


Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
If you're concerned about the amount of code, I'd put something like this in your <style> tag or an external stylesheet:

Then you don't have to set the style inline for each SPAN. And for future reference, if you don't want a DIV to move to a new line, you can set style="display:inline;"
I agree. Here's the link:
subject: best way to position text in HTML page
It's not a secret anymore!