There are several methods for (absolute) positionning of a DOM element in a HTML page :
style directly in the CSS with
top/left:position: absolute; top: 100px; left: 50px;style directly in the CSS with
transform:transform: translate(50,100)and of course, CSS style modification with Javascript :
element.style.top = "100px";...
But these are all CSS methods.
Question:
Is it possible to set DOM elements' position without CSS? (for example thanks to some methods that were available in browsers before CSS became famous or simply before CSS was added to browsers)
Note: This question is for pure knowledge / browsers' history / culture. I won't necessarily want to use it.
2 Answers
(Warning: Sarcasm and humor abounds)
A Clean Table For Layout
Tables were the only way to position elements without CSS.
Let's take the legendary "3 column layout" as an example (with room for the new 768px wide banner ad AND a 300px wide box ad on the right!).
<table cellspacing="1" cellpadding="0" width="1318" bgcolor="gray">
<tr>
<td width="200" bgcolor="white">
<img src="spacer.gif" width="200" height="1">
</td>
<td width="768" bgcolor="white">
<!-- body content goes here -->
</td>
<td width="300" bgcolor="white">
<img src="spacer.gif" width="300" height="1">
</td>
</tr>
</table>
So nothing majorly crappy here. Just some widths and spacer GIFs. Perfectly acceptable for late '90s and early century browsers. Pretty standard fare. But wait, you need to support Netscape 4 as well!? Now we have a problem.