Closed Bug 298875 Opened 19 years ago Closed 19 years ago

align=right should not be applied to input elements with a type other than image

Categories

(Core :: Layout: Form Controls, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: info, Unassigned)

References

()

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

I discussed this problem with Tantek on #webkit:

rakaz:
  "Tantek: It might make only sense on an image, it is not formally 
   restricted to type=image."

Tantek:	
  "it's clear that <input type="image"> is a replaced object like 
   applet,iframe,img,object"
  "whereas the other inputs are not"
  "and yes, the spec should have been more clear about that"
  "so it is not well defined what align should do on non-image inputs"
  "IMHO the intent of the HTML4 authors was that 'align' only apply to 
   <input type="image">"
  "rakaz, therefore, "align" should have no effect on other inputs"
  "just like an attribute like 'inputAlign="right"' would have no effect"

The behavoir described above by Tantek is consistant with IE 4, 5, 5.5
and 6.0. Also consistant with Opera 7 and 8. It would appear the current
behavoir of both Firefox and Safari is not correct.

See also: http://bugzilla.opendarwin.org/show_bug.cgi?id=3360

Reproducible: Always

Steps to Reproduce:
1. Open http://bugzilla.opendarwin.org/attachment.cgi?id=2316
Actual Results:  
The three form fields are be align to the left. The text inside the first and
third input are aligned to the right.

Expected Results:  
The three form fields should be align to the left and the text inside the form
input fields should also be aligned to the left.
What about input elements with dir="rtl"?
The dir attribute is not valid on input elements. So the input
element should ignore this attribute even if it is set. The
input element should honour the current text-direction though.

For example:

<body><input type=text value='The quick brown...'></body>

   [The quick brown...           ]

<body><input type=text align=right value='The quick brown...'></body>

   [The quick brown...           ]

<body><input type=text dir=rtl value='The quick brown...'></body>

   [The quick brown...           ]

<body dir=rtl><input type=text value='The quick brown...'></body>

   [           ...The quick brown]

(In reply to comment #2)
> The dir attribute is not valid on input elements.

I don't think this statement is correct:

http://www.w3.org/TR/REC-html40/sgml/dtd.html#InputType

<!ATTLIST INPUT
  %attrs;                              -- %coreattrs, %i18n, %events --


http://www.w3.org/TR/REC-html40/sgml/dtd.html#i18n

<!ENTITY % i18n
 "lang        %LanguageCode; #IMPLIED  -- language code --
  dir         (ltr|rtl)      #IMPLIED  -- direction for weak/neutral text --"
  >
/me hides in shame... Of course is the dir attribute valid on
an input element. You are absolutely correct.

My mistake make the examples I gave invalid. These are the 
correct examples:

<body><input type=text value='The quick brown...'></body>

   [The quick brown...           ]

<body><input type=text align=right value='The quick brown...'></body>

   [The quick brown...           ]

<body><input type=text dir=rtl value='The quick brown...'></body>

   [           ...The quick brown]

<body dir=rtl><input type=text value='The quick brown...'></body>

   [           ...The quick brown]


<body dir=rtl><input type=text align=left value='The quick brown...'></body>

   [           ...The quick brown]


In this examples you can see that the dir attribute should 
be honoured at all times, but that the align attribute does 
not have any influence at all.

So align=left and dir=rtl will leave the text aligned to the
right and align=right and dir=ltr will leave the text aligned
to the left.
IE6 and Opera8 seem to ignore align=left and align=right for all input types,
except input type=image.
Attached patch patchSplinter Review
This makes Mozilla behave just like IE6/Opera8 for me.
What effect does the patch have on bug 170781 and its duplicates?
(In reply to comment #7)
> What effect does the patch have on bug 170781 and its duplicates?
No effect, and it shouldn't have any affect, afaik. The patch makes input tags
ignore align values for style purposes, except for input type=image.
This patch won't have any effective effect on bug 170781 or it duplicates.

Bug 170781 changed the mapping of the align attribute. Previously this attribute
mapped to float for any input element. After the patch was applied the align
attribute was mapped to text-align, except when the type attribute is image. In
that case it was still mapped to float.

The behavoir of the patch attached to this bug will change the behavoir created
by bug 170781, because instead of mapping to text-align, the align attribute
will now be ignored completely, except when the type attribe is image. This is
the correct behavoir. The new patch won't affect the testcase mentioned in bug
170781, mapping to text-align on a checkbox does not any effect at all. The new
patch ignores the attribute completely, so there is no effective change.
Attachment #187413 - Flags: review?(bzbarsky)
With my former HTML WG member hat on, the align attribute on INPUT was never
meant to be restricted to type="image".

Align should map to text-align for non-image types and float for image.

Sorry, but Tantek is wrong here. There is what says the spec, and there is browsers
common practice. They happen to be different. But the spec is clear, align
is allowed on all INPUT elements.
While I believe the specification could spell it out more clearly, 
I do believe the DTD is clear enough to support the opinion of 
Tantek.

Text align is handled by the 'align' entity:

  <!ENTITY % align "align (left|center|right|justify)  #IMPLIED"
                     -- default is left for ltr paragraphs, right for rtl --
    >

This entity is used in for example div's, paragraphs and headings:

  <!ATTLIST DIV
    %attrs;                              -- %coreattrs, %i18n, %events --
    %align;                              -- align, text alignment --
    %reserved;                           -- reserved for possible future use --
    >

The alignment used for images use a different entity:

  <!ENTITY % IAlign "(top|middle|bottom|left|right)" -- center? -->

  <!ATTLIST IMG
    [...]
    align       %IAlign;       #IMPLIED  -- vertical or horizontal alignment --
    [...]
    >

Now if you look at the INPUT attribute definition you can see
the same IAlign entity is used.

  <!ATTLIST INPUT
    %attrs;                              -- %coreattrs, %i18n, %events --
    [...]
    align       %IAlign;       #IMPLIED  -- vertical or horizontal alignment --
    [...]
    >

This leads me to conclude that the behavoir of an input element should
be similar to that of an image, not to that of an div element. The DTD
specifically tells us that align='left' on an input element is not the same
thing as align='left' on a div or paragraph.

Additionally, I do not believe the writers of the HTML spec indented the
align attribute on an input element to fall back to changing the text 
alignment. The writers of the spec would have specifically told us so 
and allowed a greater set of values for the align attribute. 

For example: the traditional text alignment values of 'justify' and 
'center' are not allowed on input elements. If the writers would have 
wanted the align attribute to change the text aligment they would have 
allowed these two values as valid values for the align attribute.

The patch is technically good (if the trailing whitespace is removed), if we
want the behavior change.  I guess that's what we need to decide, then...
Status: UNCONFIRMED → NEW
Ever confirmed: true
Ian, does WHATWG plan to clarify this?
QA Contact: layout.form-controls → ian
Yeah. By dropping "align" altogether. Probably not what you wanted to hear. :-)

Being like IE6 seems good to me.
Comment on attachment 187413 [details] [diff] [review]
patch

OK, let's try this out in 1.8b4 and see how things go...
Attachment #187413 - Flags: superreview+
Attachment #187413 - Flags: review?(bzbarsky)
Attachment #187413 - Flags: review+
Attachment #187413 - Flags: approval1.8b4?
Attachment #187413 - Flags: approval1.8b4? → approval1.8b4+
Fix checked in by timeless at 2005-07-20 16:24.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Blocks: 337068
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: