Id='word' vs id="word"

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?

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.

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.

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: Obviously within XHTML all attribute values must be quoted.

In examples like Robert’s, I tend to like to use character entities, so’s I can keepses mah preferred quoteses.

alt="Robert&#8217;s picture"

huh and the forums eatses mah entities. &#8217 + ;

Use NCR and Hex cat… ’ and it won’t get eaten by vBulletin. >;-)

You can also just wrap part of the entity in black color tags to avoid it … &#8217;

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. >;-)

I only use ncr’s.