473,224 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

div align attribute

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

Sep 4 '07 #1
2 5631
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/

Sep 4 '07 #2
..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
Sep 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stan Brown | last post by:
In converting my pages to 4.01 Strict, I've been removing ALIGN attributes everywhere. I was surprised to notice that a page that validated contained a <td align=left>. Sure enough, when I...
6
by: Viken Karaguesian | last post by:
Hello, Just wondering what the difference is between "float" and "align"? If I align a picture to the left, is that not the same as floating it? Can align and float be used together or do you...
14
by: jlemay | last post by:
if you look at http://www.emrose.net/contact1.html the last field is a textarea field and I can't make it align with the other text fields. it's pretty close, but this comes from trial and...
8
by: ALI-R | last post by:
How do I allign all my content in aspx page in the middle of page like a lot of websites ? Dose it work with differnet screen resolutions? Thanks for your help.
5
by: Cappy2112 | last post by:
Does anyone know if the table align property is available in HTMLgen.Table? The docs don't show it, but I find it hard to believe that it is not available. I want to center the table. Only the...
4
by: shivas | last post by:
Hi, I am using vertical-align for a table row, but the Image and the text are not aligned properly. I don't what to align image in the img tag, rather in the row itself I want to align. I want...
3
by: torbs | last post by:
Strange behaviour in ie7. A collegue of mine put several images into a page using JCE in Joomla. JCE have the option to align these images and he left aligned every single one - to create a...
0
by: rafeig77 | last post by:
I want help How I can align rectangles differ in its tow dimensions inside big rectangle with lesser waste in area ? for mor information align.rar - 1.8 Kb or: copy this code to text file...
13
by: Roderik | last post by:
Hi, I am wondering why (half of the) squared images are not aligned on the right of the text in Internet Explorer (using <img ... align="right" />. I thought this was supported even in IE. In FF...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.