W3C home > Mailing lists > Public > www-html-editor@w3.org > April to June 2001

Re: attribute value delimiters

From: Masayasu Ishikawa <mimasa@w3.org>
Date: Fri, 29 Jun 2001 02:13:13 +0900
To: dcgomes@xldb.fc.ul.pt
Cc: www-html-editor@w3.org
Message-Id: <20010629021313P.mimasa@w3.mag.keio.ac.jp>
Hello,

"Daniel Gomes" <dcgomes@xldb.fc.ul.pt> wrote:

> In HTML 4.01, is it correct to use both \' or \" to delimit attribute values? 
Yes.  "3.2.2 Attributes" says as follows [1]:

    By default, SGML requires that all attribute values be delimited using
    either double quotation marks (ASCII decimal 34) or single quotation
    marks (ASCII decimal 39). Single quote marks can be included within
    the attribute value when the value is delimited by double quote marks,
    and vice versa. Authors may also use numeric character references to
    represent double quotes (&#34;) and single quotes (&#39;). For double
    quotes authors can also use the character entity reference &quot;.

> so it seems that 
> 
> <img src= "someimage.gif" >
> 
> is correct but
> 
> <img src= 'someimage.gif' >
> 
> isn't.

Both are correct.

> However the W3C validator considered that all the following cases are correct in HTML 4.01 strict, transitional and xhtml
> 
> <img alt='somedesc' src= 'someimage.gif' >
> <img alt="somedesc" src= "someimage.gif" >
> <img alt=somedescsrc= someimage.gif >

In XHTML, the "img" element must end with />, and attribute values must
always be quoted.  See "4.6 Empty Elements" [2] and "4.4 Attribute values
must always be quoted" [3] respectively.

[1] http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2
[2] http://www.w3.org/TR/xhtml1/#h-4.4
[3] http://www.w3.org/TR/xhtml1/#h-4.6

Regards,
-- 
Masayasu Ishikawa / mimasa@w3.org
W3C - World Wide Web Consortium
Received on Thursday, 28 June 2001 13:12:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:16:58 GMT