For some html attributes, I can use quotes around the values, or not:
For example, I can do
<table colspan='1'></table>
Or
<table colspan=1></table>
Is there any difference between these two ways? Which is the more conventional way of doing things?
The HTML specification says: Attributes are placed inside the start tag, and consist of a name and a value, separated by an = character. The attribute value can remain unquoted if it doesn't contain spaces or any of " ' ` = < or > . Otherwise, it has to be quoted using either single or double quotes.
The HTML standard does not require quotes around attribute values.
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), and periods (ASCII decimal 46). We recommend using quotation marks even when it is possible to eliminate them.
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 ".
Wrap your values in quotes (single or double, just don't mix them):
class="container modal warning"
)class="foo"id="bar"
)During Tokenization, all three are considered (single, double, and none).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With