SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    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:

    Code:
    &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:

    Code:
    "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
    Location
    Melbourne, AU
    Posts
    24,117
    Mentioned
    448 Post(s)
    Tagged
    8 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.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

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

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

    ... so I'd say you're safe with that.
    Jon Matthews - founder - Deep Cognition Ltd.
    http://deepcognition.com/mTrawl.htm - Free for Windows & Mac;
    check your links and validate all your html with one click

  4. #4
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 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;">


Bookmarks

Posting Permissions

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