These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:06 pm Advanced search

HTML Attributes

Do you think the HTML spec should do something differently? You can discuss spec feedback here, but you should send it to the WHATWG mailing list or file a bug in the W3C bugzilla for it to be considered.

HTML Attributes

Postby FirefoxRocks » Thu Jul 23, 2009 11:45 pm

Why should we allow attributes which contain only alphanumeric characters, hyphens and dots to be unquoted?

We should force all attributes should be quoted in order to maintain cleaner code.

I know that unquoted attributes are a byte and bandwidth saver, but is it really worth it?
FirefoxRocks
<h6>
 
Posts: 3
Joined: Wed Sep 05, 2007 1:38 am
Location: Ontario, Canada

Postby RobS » Tue Sep 01, 2009 6:48 pm

If attributes can be unquoted, then the spec needs to indicate whether a parser needs to be greedy or stingy when consuming characters as an attribute value. For example, if parsing a plain text file (ex: a "file:....html" file on disk) as an HTML file and it encounters the following (bad) code:

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta name=robots content=index/></head><body><a id=hidden-link href=http://www.ExampleOnly.com/></a></body></html>

would the last "/" in <meta/> and <a> be part of the attribute or of "/>" indicating an empty tag? In this case it's pretty obvious that it's part of the tag in the first case and part of the attribute in the second case, but how would the parser know that? It might know that "meta" is a void element, but the "a" seems a bit tougher without any HTTP headers to assist. Maybe it needs to be stingy for void tags and greedy for others?
RobS
<h6>
 
Posts: 3
Joined: Thu Jan 31, 2008 4:48 pm

Postby JAB Creations » Tue Sep 01, 2009 7:21 pm

Please tell me the HTML5 does not allow unquoted attributes.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby RobS » Tue Sep 01, 2009 9:07 pm

the quotes surrounding the value may also be omitted in most cases. The value may contain any characters except for spaces, single or double quotes (' or "), an equals sign (=) or a greater-than symbol (>). If you need an attribute to contain those characters, they either need to be escaped using character references, or you need to use either the single- or double-quoted attribute values.

http://dev.w3.org/html5/html-author/#unquoted-attr
RobS
<h6>
 
Posts: 3
Joined: Thu Jan 31, 2008 4:48 pm

Postby JAB Creations » Wed Sep 02, 2009 7:03 am

Genius!

<div class=class1 class2

Instead of having browser vendors spend time on important things like CSS3 let's force them to guess what is an attribute and what is a value!

This is beyond ridiculous. :evil:
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby zcorpan » Wed Sep 02, 2009 7:25 am

JAB Creations wrote:Genius!

<div class=class1 class2

Instead of having browser vendors spend time on important things like CSS3 let's force them to guess what is an attribute and what is a value!
Browser vendors are not spending any time on "guessing" what is an attribute and what is a value. It's well-defined how to parse it, and everyone has done it from the start.

Disallowing unquoted attributes for authors wouldn't make it any different for browsers; they'd still have to parse it the same for compatibility with existing content.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby zcorpan » Wed Sep 02, 2009 7:30 am

RobS wrote:If attributes can be unquoted, then the spec needs to indicate whether a parser needs to be greedy or stingy when consuming characters as an attribute value.
It does.

RobS wrote:For example, if parsing a plain text file (ex: a "file:....html" file on disk) as an HTML file and it encounters the following (bad) code:

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta name=robots content=index/></head><body><a id=hidden-link href=http://www.ExampleOnly.com/></a></body></html>

would the last "/" in <meta/> and <a> be part of the attribute or of "/>" indicating an empty tag?
It would be part of the attribute value.

RobS wrote:In this case it's pretty obvious that it's part of the tag in the first case and part of the attribute in the second case, but how would the parser know that? It might know that "meta" is a void element, but the "a" seems a bit tougher without any HTTP headers to assist. Maybe it needs to be stingy for void tags and greedy for others?
Why would it be handled differently for different tags?
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby JAB Creations » Wed Sep 02, 2009 8:13 am

This is a massive waste of resources and time. Letting clearly broken code be seen as valid opens up a debate about how such code should be parsed. It also degrades the expected level of quality expected of programmers. Instead of allowing trash code the WHATWG group could spend it's time on much more important needs of the web.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby lyosha » Fri Sep 18, 2009 10:50 pm

JAB Creations wrote:This is a massive waste of resources and time. Letting clearly broken code be seen as valid opens up a debate about how such code should be parsed. It also degrades the expected level of quality expected of programmers. Instead of allowing trash code the WHATWG group could spend it's time on much more important needs of the web.


The point is for browsers to be able to handle legacy code, nowhere is it recommended to code ugly; the reason it's there is to describe how to handle ugly code when the browser comes across it.
lyosha
<h3>
 
Posts: 60
Joined: Fri Aug 22, 2008 9:26 pm

Postby JAB Creations » Fri Sep 18, 2009 11:16 pm

The way it's worded (may) suggests that it is valid markup. If it is considered valid markup then it's one of the reasons why I won't adopt HTML5. It should be rewritten to clarify that it is invalid though if it is encountered how to handle pseudo-code in such situations.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby zcorpan » Sat Sep 19, 2009 8:33 am

It is valid.

http://www.whatwg.org/specs/web-apps/cu ... l#unquoted

There are more pages using unquoted attributes than single-quoted attributes, according to a study Philip` did (about something else but gave data about attribute syntax as a side-effect)

http://krijnhoetmer.nl/irc-logs/whatwg/20090427#l-342

If we make unquoted attributes invalid, we're wasting time for people who previously used unquoted attributes and want to move to valid HTML5.

You don't have to use unquoted attributes if you don't want to. You don't have to adopt HTML5, either, obviously, but then you're probably missing out from a number of new features. :)

BTW, Validator.nu currently has a feature to warn about unquoted attributes.
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby mskinner » Sat Sep 19, 2009 11:15 am

JAB Creations wrote:then it's one of the reasons why I won't adopt HTML5


There's always XHTML5. You will get the new features of HTML5 and quoted attributes, closed elements, etc. Whilst I abhor the lax syntax of HTML (and don't think we should perpetuate it's flaws forever) - we/developers do have a choice... XHTML5.

May the W3C be with you. Yes; I am a Jedi Master.
mskinner
<h2>
 
Posts: 116
Joined: Sun Jun 24, 2007 12:20 am
Location: Melbourne, Australia

Postby JAB Creations » Sun Sep 20, 2009 4:12 pm

I love XHTML 1.1 and if XHTML 5 retains the strictness application mentality I may adopt it.

↩

I take it that is a DOS line break entity that is triggering a warning?
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA


Return to Feedback on the Specs

Who is online

Users browsing this forum: No registered users and 1 guest