Skip to content Skip to sidebar Skip to footer

Is It Acceptable To Use Single Quotes Around Values In HTML Attributes?

Is it acceptable to use single quotes around html attribute values like this: Hi Instead of double quotes like this:

The HTML5 spec says:

In the HTML syntax, attributes can be specified in four different ways:

  1. empty attribute syntax
  2. unquoted attribute-value syntax
  3. single-quoted attribute-value syntax
  4. double-quoted attribute-value syntax

The HTML4 spec says:

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.


Solution 2:

Single quotes are and have always been completely kosher, according to the W3 specification. It's a markup/code style choice, nothing more.


Solution 3:

Yes, the W3C publishes HTML standards.

They also provide a validator at http://validator.w3.org/

the validator is ok with both for XHTML 1.0 Strict.

There is several HTML standards, so whether it’s "acceptable" entirely depends on which you're using. Furthermore collaborative projects may have a coding style which defines to use one or the other. Using " is de-facto standard, even if the HTML standard may allow ' as well.


Post a Comment for "Is It Acceptable To Use Single Quotes Around Values In HTML Attributes?"