The rules for quoting the attribute of an HTML element.

Date: 2015-06-12

Mozilla kept complaining about my href attributes every time I looked at the source.

I decide to Google: html5 attribute quotes

The top three response are:

Starting with W3C:

attribute values
can contain text and character references, with additional restrictions depending on whether they are unquoted attribute values, single-quoted attribute values, or double-quoted attribute values. Also, the HTML elements section of this reference describes further restrictions on the allowed values of particular attributes, and attributes must have values that conform to those restrictions.

There is also the attribute with no value or an "empty attribute". This is usually, but not always, a boolean.

The rules are convoluted and overlapping, but the rules that apply to unquoted values are:

  1. must not contain any literal space characters
  2. must not contain any """, "'", "=", ">", "<", or "`", characters
  3. must not be the empty string