Skip to content

Instantly share code, notes, and snippets.

@premasagar
Created October 18, 2010 02:15
Show Gist options
  • Save premasagar/631599 to your computer and use it in GitHub Desktop.
Save premasagar/631599 to your computer and use it in GitHub Desktop.
Rules on omitting quotation marks from HTML5 attributes:
http://www.w3.org/TR/html-markup/syntax.html#syntax-attr-unquoted
An unquoted attribute value has the following restrictions:
* must not contain any literal space characters
* must not contain any """, "'", ">", "=", characters
* must not be the empty string
////
HTML4:
http://www.w3.org/TR/html4/intro/sgmltut.html
"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 (") and single quotes ('). For double quotes authors can also use the character entity reference ".
In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58)."
(see http://www.cs.tut.fi/~jkorpela/qattr.html for a warning)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment