Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- div align attribute
- Icarus - iD_Ten_T helper
September 4, 2007, 10:20 am
rate this thread
I am currently teaching myself PHP, JS, HTML and CSS.
I would say I am a beginner to interemediate at varying levels within
all 4, however I have some queries and I wonder if any of you can
I understand that since HTML 4.01 that the 'align' attribute of the
div tags, well any tags have been deprecated. I know the transitional
ones still support it, but HTML 4.01 strict and XHTML strict do not.
They say use style sheets instead.
but for example, I want my entire page to appear in the center of the
the way I would normall do this is:
<div align = "center" id="allContent">
all other content
which makes life incredibly simpler. This way for me was very
graceful, everything appeared center unless explicity asked not to,
which was correctable by some more nested div's and further changes in
now I am finding this impossible to do with stylesheets. there is no
explicit align attribute in css. text-align does exactly that, only
aligns text within the element, or behaves strangley.
I though about using
postion:relative; //to the body I am assuming
left: 50%; // 50% away from left of body at all times
this should keep it center no?!?
well, no. firefox displays it ok, but what looks like 75% away from
the left. and well IE 7, it puts it about 80% over on the right and
other bad things.
what is the accepted way to align, not position things in CSS rather
than using deprecated attributes,
can any of you help?!
- Jukka K. Korpela
September 4, 2007, 11:53 am
Re: div align attribute
Scripsit Icarus - iD_Ten_T helper:
For the div tag, yes, but not for all other tags. Check the quick reference
to HTML 4.01 attributes:
where a "D" in the "Depr." column tells that the attribute has been
but you can mostly ignore IE versions prior to 6 (at least if the problem
with them is just not centering content), so you can use just the simple CSS
In what way? It centers each _line_ of text inside the content. This is
quite different from centering the content as a block. Which one do you
Positioning is overkill for simple centering, the property name was
misspelled, no URL was provided, and CSS questions don't belong here but to
Jukka K. Korpela ("Yucca")