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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I position something with xhtml? 3

Status
Not open for further replies.

Zvark

Programmer
Jun 1, 2006
2
US
I used to use the following code to position items when I used regular html, but now I'm upgrading my skills to xhtml and this code no longer works. Here's an example:
<img src="top.jpg" div style="position: absolute; top:0; left:0">
I would use the same div style=etc. to position everything from graphics to tables and even my iframes. Why won't it work in xhtml and what will work now?
 
This is the correct way. It should align the image in the top left corner.
Code:
<img src="top.jpg" style="position:absolute; top:0px; left:0px">

M. Brooks
 
Whatever that div was in your code, it was completely erroneous, either in html or xhtml. Style tag launches css and positions the element via css. Same can be achieved through the stylesheet in the head of the document or best in a separate file. However, I have found that maintaining a site that is fully absolutely positioned can be a nightmare (since you have to reposition everything if you decide to add something or lenghten the other thing) and I advise people to use the normal document flow whenever possible.
 
Thank you all. I am pretty new to xhtml. As for my old code being erroneous, I didn't know that. I got that code from another site and it worked just fine until, like I said, I switched to xhtml. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top