SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2012
    0 Post(s)
    0 Thread(s)

    Should HTML use the quotation mark character or the " entity?

    I'm seeking opinions on the use of the plain quotation mark in HTML content, versus use of the equivalent entity, ".

    I've always viewed the plain quotation mark as one of those things that you can get away with, but shouldn't. Right now, though, I have to publish a large quantity of stuff that looks like this:

    "message": "string",

    The HTML looks like this:

    &quot;message&quot;: &quot;<span class='pl'>string</span>&quot;,
    It sure would be easier to read and write if I could do this instead:

    "message": "<span class='pl'>string</span>",
    Suddenly using the HTML entity because it exists doesn't seem as wise as it used to. Are there stronger reasons to use it than that?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Melbourne, AU
    411 Post(s)
    6 Thread(s)
    I don't see a problem with it, as long as you remember to use single quotes on classes etc, like you have. Seems tiresome to write out the entity references every time.

  3. #3
    SitePoint Member
    Join Date
    Mar 2013
    0 Post(s)
    0 Thread(s)
    When wrapped in some boilerplate the example validates as html 5....

    <!DOCTYPE html>
    <meta charset="utf-8">
    <p>"message": "<span class='pl'>string</span>"</p>

    ... so I'd say you're safe with that.
    Jon Matthews - founder - Deep Cognition Ltd. - For Windows & Mac; check your site for errors - Monitor your site for stuff that goes wrong on it's own

  4. #4
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    47 Post(s)
    1 Thread(s)
    I've always viewed the plain quotation mark as one of those things that you can get away with, but shouldn't.
    Nope. Farting silently near a group of children after a chili-eating contest is a Shouldn't. Quote character entities are purely for when you like to punish yourself, with a small exception.
    Unless you want to make cute curvy quotes (8220, 8221), you should have no problems using direct quotes. Same way you use apo'stro'phes' (you don't usually write out the character entity for those, do you?). Only reason everyone harps on ampersands is because they can start character entities themselves, so it's just smart to escape them.

    However the character entity is super-handy to have when you want to put quote marks as text within an attribute (if delineated by doubles), such as

    <img src="lolwut.gif" alt="Picard saying &quot;Lolwut?&quot;">


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts