Click here to get back home

div align attribute

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
div align attribute Icarus - iD_Ten_T helper 09-04-2007
|--> Re: div align attribute Jukka K. Korpel...09-04-2007
Posted by Icarus - iD_Ten_T helper on September 4, 2007, 6:20 am
Please log in for more thread options


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
help.

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
screen.

the way I would normall do this is:

<div align = "center" id="allContent">
<div....etc....
all other content
</div.... etc...
</div>

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
alignment.

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

#allContent
{
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?!
Ic


Posted by Jukka K. Korpela on September 4, 2007, 7:53 am
Please log in for more thread options


Scripsit Icarus - iD_Ten_T helper:

> I understand that since HTML 4.01 that the 'align' attribute of the
> div tags, well any tags have been deprecated.

For the div tag, yes, but not for all other tags. Check the quick reference
to HTML 4.01 attributes:
http://www.w3.org/TR/html401/index/attributes.html
where a "D" in the "Depr." column tells that the attribute has been
deprecated.

> but for example, I want my entire page to appear in the center of the
> screen.

Then check
http://theodorakis.net/blockcenter.html
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
method.

> the way I would normall do this is:
>
> <div align = "center" id="allContent">
> <div....etc....
> all other content
> </div.... etc...
> </div>
>
> which makes life incredibly simpler.

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
want?

> postion:relative;

Positioning is overkill for simple centering, the property name was
misspelled, no URL was provided, and CSS questions don't belong here but to
c.i.w.a.stylesheets.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Posted by Michael Fesser on September 4, 2007, 7:57 am
Please log in for more thread options


.oO(Icarus - iD_Ten_T helper)

>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
>screen.
>[...]

To center a block-level element, give it a width and set its left and
right margins to 'auto'.

>the way I would normall do this is:
>
><div align = "center" id="allContent">

#allContent {margin: 0 auto; width: ...}

Micha

Similar ThreadsPosted
Newbie question: css layout with 3 columns (left align, use all remaining space, right align) March 29, 2006, 10:36 pm
How to align this? December 2, 2005, 7:05 am
Align Right July 14, 2006, 12:33 pm
img align=right :-( May 31, 2008, 10:15 pm
Trying to align something at the very bottom August 19, 2006, 3:50 pm
How do I align a link? September 17, 2006, 12:45 am
text align right November 5, 2007, 8:25 pm
center align a page August 5, 2005, 2:27 am
div align bottom inside a td February 5, 2006, 7:27 pm
Image Align problems November 9, 2007, 2:48 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap