picnictutorials — 2013-03-28T07:56:07-04:00 — #1
Most of the time you can use single quotes for things. But I just noticed that you can use them for id's as well. Does this work everywhere and is it valid?
ralphm — 2013-03-28T08:54:43-04:00 — #2
Yes, it's valid, but personally, I'd stick with double quotes. It's clearer, and I'd say keep single quotes for other languages like JS and PHP. Consistency is the key.
stevie_d — 2013-03-28T09:07:32-04:00 — #3
According to a thread we had here 11 years ago (and no, I wasn't around then either!) – XHTML: single quotes or double quotes – it's perfectly valid to use single quotes when quoting attribute values. ID is no different to any other attribute, you can use single quotes there – the only time you are likely to run into trouble is if the attribute value contains a single quote/apostrophe character, and it will then be taken as the end of the attribute value, so you would need to use double quotes in those cases, or escape the single quote/apostrophe using a NCR/entity.
xhtmlcoder — 2013-03-28T10:01:22-04:00 — #4
Like mentioned; if double quotes appear in an attribute value, you should use single quotes to quote the value; if single quotes appear in an attribute value, you should use double quotes to quote the value. For example: <img src="example.png" alt="Robert's picture" /> Basically be constant: http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 Obviously within XHTML all attribute values must be quoted.
stomme_poes — 2013-03-29T15:43:13-04:00 — #5
In examples like Robert's, I tend to like to use character entities, so's I can keepses mah preferred quoteses.
huh and the forums eatses mah entities. ’ + ;
xhtmlcoder — 2013-03-29T16:28:30-04:00 — #6
Use NCR and Hex cat... ’ and it won't get eaten by vBulletin. >;-)
ralphm — 2013-03-29T19:16:00-04:00 — #7
You can also just wrap part of the entity in black color tags to avoid it ... ’
xhtmlcoder — 2013-03-30T09:13:47-04:00 — #8
Using hex NCR is still better though regardless. NCR is the preferable choice over the entities, entities are limited to a subset of Unicode characters, NCR can specify any character and theoretically Hexadecimal has less ambiguity. >;-)
stomme_poes — 2013-03-31T09:45:30-04:00 — #9