George Hester wrote:
<center><a
href="http://www.microsoft.com">www.microsoft.com</a></center>
Do not use the `center' element, it is deprecated. Use the
`p' or `div' element and CSS' `text-align:center' instead.
I can use CSS, the DOM and\or JavaScript to determine the width
style.innerHTML.length of the www.micosoft.com. But how can I tell
in pixels how far it is from the left side of the client area using
JavaScript?
Use the DOM either. IE provides the `offsetLeft' property
while with standards-compliant UAs like Mozilla you can use
the getComputedStyle(...) method. Questions like this were
asked a few times, especially in the last days. Please
search/read *before* you post.
If the browser is resized and the text wraps the distance will change.
What's the problem?
So I need to determine it dynamically.
You only need working markup. What if JavaScript is disabled or not
supported? What if the DOM of the UA does not allow for reading the
computed coordinates? (X)HTML is not designed to be a layout language
or format like PDF. That the text flow adjusts automatically to the
client area instead of scaling the content to its size is its major
advantages, and you cannot fix design flaws in Web documents with
JavaScript reliably.
PointedEars