View Full Version : how do you do without the ALIGN attribute in XHTML Strict ??
brothercake
01-20-2003, 12:53 PM
??
ronaldb66
01-20-2003, 01:37 PM
Which use did you have in mind? For alignment of content the text-align (horizontal) and vertical-align (duh!) properties of CSS1 are available; for table cells (td elements), the align and valign attributes are still available in XHTML 1.0 strict.
cg9com
01-20-2003, 01:51 PM
centering a whole table would require something like.
margin-left:auto;
margin-right:auto;
in your CSS, i think its only ie5.5+ tho
brothercake
01-20-2003, 02:17 PM
text-align is for text, not objects in general. I wanted to align an IMG inside a DIV, but in the end I used float
thanks all :)
ronaldb66
01-20-2003, 02:50 PM
What's in a name? Maybe text-align isn't such a great one, since i believe it works for other objects and elements as well. Should try it, though. Float works too, but really is CSS2, as opposed to text-align which is CSS1, if you worry about browser support, but let's not get into that again.
Update: slapped a div around a table; text-align definitely centers whole tables as well. Text in table cell default aligned, but this might be browser-dependent (inheritance and all), but in my case (IE5.5 in WinNT) it was default.
brothercake
01-20-2003, 03:17 PM
I think you're slightly missing the point - it may well be that text-align can align objects, but it is not supposed to; if you're relying on implementation bugs then arguably there's no point coding to Strict. :)
ronaldb66
01-21-2003, 09:28 AM
You had me confused, so i looked up the W3C recommendations for both CSS1 and CSS2:
CSS1 Recommendation (http://www.w3.org/TR/REC-CSS1#text-align)
CSS2 Recommendation (http://www.w3.org/TR/REC-CSS2/text.html#alignment-prop)
The first one among other things states:
Since 'text-align' inherits, all block-level elements inside the 'DIV' element with 'CLASS=center' will be centered.
the latter one speaks of "inline content" rather then "text". Well, that's the W3C for you.
I'm still not sure, but i wouldn't say text-align isn't supposed to center elements other then text.
brothercake
01-21-2003, 11:12 AM
... interesting ...
Originally posted by ronaldb66
I'm still not sure, but i wouldn't say text-align isn't supposed to center elements other then text.
text-align only aligns inline content. IE < 6 was stupid this way, and had it align block-level boxes too. Use margin: 0 auto; to center block-level content.
ronaldb66
01-21-2003, 01:13 PM
jkd,
i was waiting for someone like you to reply... :D I just visited blooberry.com and it suggested the margin auto solution as given earlier on as well. Seems like there's no one-on-one CSS property for centering blocks then, eh?
brothercake
01-21-2003, 03:27 PM
shurely that's what float does ...
float:left;
float:center;
float:right;
works exactly like align, from what I've tried so far
Originally posted by brothercake
shurely that's what float does ...
float:left;
float:center;
float:right;
works exactly like align, from what I've tried so far
No such value as "center":
http://www.w3.org/TR/REC-CSS2/visuren.html#propdef-float
brothercake
01-21-2003, 11:11 PM
yeah I clocked that one .. :)
Grant Palin
01-22-2003, 01:06 AM
I posted a similar question a couple days ago...I wanted to know how to use CSS to center align images and tables.
I was told that you can center align an image by putting it in a paragraph tag with a center style:
<p style="text-align:center"><img src="whatever.jpg"></p>
And that will center-align the paragraph, along with it's contents, namely, the image.
For tables, I was told to use:
<div style="text-align:center">
<table border="0" style="margin-right: auto; margin-left: auto;">
Apparently, some browsers prefer the styled div enclosing the table, and others prefer the margin-right and -left styles inside the table tag.
Originally posted by brothercake
shurely that's what float does ...
No, float is not the same at all. Float is similar to the HTML attribute align=left|right used with IMG or TABLE. It floats the element to the left or right margin of the element it's contained in and allows other content to flow around it.
'text-align', as already mentioned, aligns inline content, may it be text or images, within the blocklevel element it's applied to.
cg9com
01-22-2003, 01:11 AM
im glad this is being discussed
this is a question i get daily, now i get somewhere to refer to.
i vote to sticky this thread
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.