W3C home > Mailing lists > Public > public-html@w3.org > February 2009

Re: Rendering: align=right and 'margin-right:auto'

From: Simon Pieters <simonp@opera.com>
Date: Wed, 04 Feb 2009 20:36:11 +0100
To: "L. David Baron" <dbaron@dbaron.org>
Cc: public-html <public-html@w3.org>
Message-ID: <op.uoud2il1idj3kv@hp-a0a83fcd39d2>

On Wed, 04 Feb 2009 19:02:43 +0100, L. David Baron <dbaron@dbaron.org> wrote:

> On Wednesday 2009-02-04 14:00 +0100, Simon Pieters wrote:
>> Consider
>> http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!doctype%20html%3E%0D%0A%3Cdiv%20align%3Dright%3E%0D%0A%20%3Ctable%20border%20style%3Dmargin-right%3Aauto%3E%3Ctd%3Ex
>> Should the table be left-aligned or centered?
>> AFAICT the spec says it should be centered.
> Which spec?  If HTML5 says something here I think it should say
> left-aligned.  The margin-right:auto on the table should override
> the align=right on its parent.  (Do you see the same results if you
> specify align=center on a grandparent, etc.?)

HTML5 says:

   The div, caption, thead, tbody, tfoot, tr, td, and th elements, when
   they have an align attribute whose value is an ASCII case-insensitive
   match for the string "right", are expected to right-align text within
   themselves, as if they had their 'text-align' property set to 'right'
   in a presentational hint, and to right-align blocks and tables within
   them, as if their descendants had their 'margin-left' property set to
   'auto' in presentational hints.


  <div align=right>

is effectively the same as

  <div style="text-align:right">
   <table style="margin-left:auto"><tr><td>x</table>

Now add 'margin-right:auto' to the table and it becomes centered.

> (I could see an argument for left aligned, but I don't think
> centering is a reasonable compromise between one thing saying left
> and the other saying right... what would you then do as a compromise
> between center and left, etc.?)
> align=right and align=left on DIV and similar can't be expressed
> using existing CSS, although they could be expressed using the
> property described here (which could be called 'block-align' if it
> were added):
> http://lists.w3.org/Archives/Public/www-style/2007Nov/0071.html
> Gecko implements this proposal as extra values on 'text-align',
> though.

If we want HTML5 to match IE, WebKit and Gecko then I guess it needs to rephrase along the lines of the proposal for 'block-align' referenced above.

Simon Pieters
Opera Software
Received on Wednesday, 4 February 2009 19:37:04 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:43 UTC