Jwan622
Jwan622

Reputation: 11639

Why use characters like &quot over ""?

I was wondering why we should use $quot or &ldquot over regular string representations of those characters? What are these characters called and why would we use them anything else in an html file?

I would google this myself but I don't even know what these characters are? Is it Unicode? ASCII?

Is it faster to represent quotes and ellipsis this way?

Upvotes: 0

Views: 1534

Answers (2)

Quentin
Quentin

Reputation: 943216

why we should use $quot or &ldquot over regular string representations

It's " and you would use it only in attribute values delimited by " characters because a literal " would end the attribute value.

why we should use &ldquot over regular string representations

It is &ldquot; and you would use it either because:

  • You had no convenient way to type the literal character
  • You were using a character encoding which didn't include the character

The latter shouldn't be a problem this century because we have had good support for UTF-8 for ages.

Upvotes: 1

theglossy1
theglossy1

Reputation: 553

It may have to do with encoding. If you use " etc, you leave it up to the browser and/or the operating system on how to display it. It should work with all encodings.

If you use an actual character, you need to specify the encoding (e.g., utf-8), in the document's meta tag. I prefer to do everything in utf-8 and use real characters as opposed to the html entity equivalents, and I believe that is the W3C recommendation these days (though don't quote me on it).

Upvotes: 1

Related Questions