SitePoint Sponsor

User Tag List

View Poll Results: What kind of HTML Quotes do you use ?

Voters
34. You may not vote on this poll
  • "

    32 94.12%
  • '

    1 2.94%
  • [Both]

    1 2.94%
  • [No quotes]

    0 0%
Page 1 of 2 12 LastLast
Results 1 to 25 of 28
  1. #1
    <?php echo"GiroPets"; ?> giropets's Avatar
    Join Date
    Jul 2003
    Location
    United States
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTML Quotes Poll

    What kind of quotes do you use when programming HTML ? I use '

    Example :

    HTML Code:
    <img src="img.png">
    <img src='img.png'>
    <img src=img.png>

  2. #2
    Vermicious Knid moncur's Avatar
    Join Date
    May 2003
    Location
    Salt Lake City, UT
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While both work 90% of the time, I've found that there are a few buggy browsers out there that get confused by single quotes, so I've standardized with double quotes across my sites.

  3. #3
    Ensure you finish what you sta bronze trophy John Colby's Avatar
    Join Date
    Aug 2003
    Location
    University of Central England, U.K.
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to http://www.w3.org/TR/xhtml1/#h-4.4 all attributes must be quoted - which makes the double quote the correct method - nothing else.
    John
    No electrons were harmed during the creation, transmission
    or reading of this posting. However, many were excited and
    some may have enjoyed the experience.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Double or Nothing

    I use doube quotes. Incidentally, do you need to encapsulate integers in quotes in HTML? I know that you don't in most programming languages, so what about HTML?

  5. #5
    Ensure you finish what you sta bronze trophy John Colby's Avatar
    Join Date
    Aug 2003
    Location
    University of Central England, U.K.
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by compuwhiz7
    I use doube quotes. Incidentally, do you need to encapsulate integers in quotes in HTML? I know that you don't in most programming languages, so what about HTML?
    (X)HTML does not discriminate about the type of assignment to an attribute. You quote them all. It is the action of assignment rather the apparent data type or content of the assignee that is the issue.
    John
    No electrons were harmed during the creation, transmission
    or reading of this posting. However, many were excited and
    some may have enjoyed the experience.

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by compuwhiz7
    I use doube quotes. Incidentally, do you need to encapsulate integers in quotes in HTML? I know that you don't in most programming languages, so what about HTML?
    Since HTML is not a programming language and knows nothing about data types, yes you have to quote them.

    As for the question, I use double quotes; always have .

  7. #7
    SitePoint Evangelist N9ne's Avatar
    Join Date
    Aug 2002
    Location
    UK
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use double quotes too.

    Also, just to be picky:

    <img src="image.png" alt="This is an Image!!!" style="width: 200px; height: 200px" />

    Better

  8. #8
    Ensure you finish what you sta bronze trophy John Colby's Avatar
    Join Date
    Aug 2003
    Location
    University of Central England, U.K.
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by N9ne
    I use double quotes too.

    Also, just to be picky:

    <img src="image.png" alt="This is an Image!!!" style="width: 200px; height: 200px" />

    Better
    Except that XHTML 1.1 deprecates inline styles. See http://www.w3.org/TR/xhtml11/doctype.html#s_doctype

    And http://www.w3.org/TR/xhtml-modulariz...#s_imagemodule says: that an img tag should have alt* (Text), height (Length), longdesc (URI), src* (URI), width (Length) as attributes so IMHO it is incorrrect to specify length and height in a style declaration, and they should be declared directly.
    John
    No electrons were harmed during the creation, transmission
    or reading of this posting. However, many were excited and
    some may have enjoyed the experience.

  9. #9
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by John Colby
    And http://www.w3.org/TR/xhtml-modulariz...#s_imagemodule says: that an img tag should have alt* (Text), height (Length), longdesc (URI), src* (URI), width (Length) as attributes so IMHO it is incorrrect to specify length and height in a style declaration, and they should be declared directly.
    yep, same for <object> as well

  10. #10
    <?php echo"GiroPets"; ?> giropets's Avatar
    Join Date
    Jul 2003
    Location
    United States
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John Colby
    According to http://www.w3.org/TR/xhtml1/#h-4.4 all attributes must be quoted - which makes the double quote the correct method - nothing else.
    That's XHTML, I program HTML and PHP. And because of that, I'm too lazy to do this :

    PHP Code:
    <?php
    echo"<img src=\"img.png\">";
    ?>
    With me...

    PHP Code:
    <?php
    echo"<img src='img.png'>";
    ?>
    I find it easier than hitting the [SHIFT] key all the time as well as adding backslashes...

  11. #11
    Ensure you finish what you sta bronze trophy John Colby's Avatar
    Join Date
    Aug 2003
    Location
    University of Central England, U.K.
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thisn is nnow getting confusing. The http://www.w3.org/MarkUp/html-spec/html-spec_3.html says
    Attributes

    In a start-tag, white space and attributes are allowed between the element name and the closing delimiter. An attribute specification typically consists of an attribute name, an equal sign, and a value, though some attribute specifications may be just a name token. White space is allowed around the equal sign.

    The value of the attribute may be either:

    * A string literal, delimited by single quotes or double quotes and not containing any occurrences of the delimiting character. (7)
    * A name token (a sequence of letters, digits, periods, or hyphens). Name tokens are not case sensitive. (8)

    In this example, img is the element name, src is the attribute name, and `http://host/dir/file.gif' is the attribute value:

    http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 says (HTML4)
    By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (&#34 and single quotes (&#39. For double quotes authors can also use the character entity reference &quot;.
    However no examples on either HTML or XHTML show single quotes.

    The validators accept either.
    John
    No electrons were harmed during the creation, transmission
    or reading of this posting. However, many were excited and
    some may have enjoyed the experience.

  12. #12
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by giropets
    That's XHTML, I program HTML and PHP. And because of that, I'm too lazy to do this :

    PHP Code:
    <?php
    echo"<img src=\"img.png\">";
    ?>
    With me...

    PHP Code:
    <?php
    echo"<img src='img.png'>";
    ?>
    I find it easier than hitting the [SHIFT] key all the time as well as adding backslashes...
    Why not:
    PHP Code:
    <?php
    echo '<img src="img.png" />';
    ?>
    Unless you're throwing a variable in there, you can do what I did above just fine. There goes your argument .

  13. #13
    Entrepreneur Spencer F.'s Avatar
    Join Date
    Dec 2003
    Location
    New York, NY
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use " for sure.
    + Carbonmade - Easiest way to display and manage your portfolio.
    + Burstoid - Design magazine.

    + twitter/spencerfry

  14. #14
    <?php echo"GiroPets"; ?> giropets's Avatar
    Join Date
    Jul 2003
    Location
    United States
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John Colby
    Thisn is nnow getting confusing. The http://www.w3.org/MarkUp/html-spec/html-spec_3.html says



    http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 says (HTML4)

    However no examples on either HTML or XHTML show single quotes.

    The validators accept either.

    I've talked to a Programming Expert in the past about this. He told me that browsers accept all three of them. He said it didn't matter which I use.
    The only thing is that if you use it without any kind of quotes..it'll only pick up the first value.

    Ex :
    HTML Code:
    <input type=Submit value=Click Me>
    It'll only pick up 'Click'.

    Just take a quick look at www.neopets.com, they're one of the biggest sites on the net. If you look at their HTML source code, you'll see that they don't use quotes and sometimes use single quotes.
    At this very second, they have 66,098,612 accounts on their site with 116,622,550,000 page views.

    Ex :
    HTML Code:
    <img src="http://images.neopets.com/blank.gif" width=2 height=5>
    HTML Code:
    <font size=1 color=#666666>NEOPETS, characters, logos, names and all related indicia<br>
     are trademarks of <a href='/aboutus.phtml'><font size=1>Neopets, Inc.,</a><font size=1 color=#666666> &copy; 1999-2003.  
    All rights reserved.</font><br>
    <a href='/privacy.phtml'><font size=1>Privacy Policy</a> |
    <a href='/safetytips.phtml'><font size=1>Safety Tips</a> |
    <a href='/contact.phtml'><font size=1>Contact Us</a> |
    <a href='/aboutus.phtml'><font size=1>About Us</a> |
    <a href='/presskit_form.phtml'><font size=1>Press Kit</a>
    If they're one of the most popular sites on the net, then how come they still have single quotes and sometimes no quotes ?

  15. #15
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by giropets
    If they're one of the most popular sites on the net, then how come they still have single quotes and sometimes no quotes ?
    Becuase they don't know better.

    Seriuosly. It doesn't make it more correct/ok to break the standards because a large site do it.

    Getting the quotes correct is a very simple task though.

    -Helge

  16. #16
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Generally it is optional whether single or double are used though to be on the safe-side it is generally preferable to use double.

    However, let us consider:
    Code:
     <div style="font-face: 'Times New Roman', Times, Georgia, Serif;">X</div>
    The above would be legal XHTML whereas if the author had chosen to use double quotes for Times New Roman they would have failed validation.

  17. #17
    Phil fillup07's Avatar
    Join Date
    May 2002
    Location
    Jacksonville, FL
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I generally use " in HTML. However, if I am outputting HTML through
    ASP I prefer the single ' because it simply makes the
    code a little easier to see and takes up less room in monospaced fonts.

  18. #18
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xhtmlcoder
    However, let us consider:
    Code:
     <div style="font-face: 'Times New Roman', Times, Georgia, Serif;">X</div>
    The above would be legal XHTML whereas if the author had chosen to use double quotes for Times New Roman they would have failed validation.
    This would also have passed validation:
    Code:
     <div style="font-face: Times New Roman, Times, Georgia, Serif;">X</div>
    -Helge

  19. #19
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Helge
    This would also have passed validation:
    Code:
     <div style="font-face: Times New Roman, Times, Georgia, Serif;">X</div>
    -Helge
    Off Topic:


    Yeah, you and xhtmlcoder would have passed XHTML validation, but you both would have failed at CSS validation. It's font-family!

  20. #20
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let's stay on topic shall we.



    -Helge

  21. #21
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Ah yes, I didn't have my CSS Santa hat on since it was markup that was in question (I don't know how I managed to write face instead of family probably my dyslexia). .

    Also I have to use a similar nesting method with my ICRA labels.

  22. #22
    <?php echo"GiroPets"; ?> giropets's Avatar
    Join Date
    Jul 2003
    Location
    United States
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Helge
    Becuase they don't know better.

    Seriuosly. It doesn't make it more correct/ok to break the standards because a large site do it.

    Getting the quotes correct is a very simple task though.

    -Helge

    I'm saying that because they're a big site. They are one of the biggest sites on the internet. Because of that, their visitors will have many different browsers -- some of which may not be compatable to that. Or so you say. Then if they get so many members, then why isn't all of their code with double quotes ?

  23. #23
    SitePoint Member
    Join Date
    Dec 2003
    Location
    Marion, Arkansas
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post A more professional angle.

    I don't agree with the rest of you. The most browser efficient way to quote or define html is transversal. There is no ONE quote you use, because this would overlap. Heres an example of what I use.

    HTML Code:
    <img height=0 width=0 src="image.jpg">
    And for server side scripts I would use:
    PHP Code:
    <?php echo '<img height=0 width=0 src="image.jpg">'?>
    I don't usually program in php, but that is how I do my quotes. For asp I would reverse it and just use:
    Response.Write "<img height=0 width=0 src='image.jpg'>"
    This allows for non-overlapping tags that would cause errors, which also goes for JavaScript. This is what I have found over the years of programming, don't bother visiting my website to see, its messed up at the moment.
    Last edited by mdshort; Dec 16, 2003 at 17:44.

  24. #24
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Double quotes.
    In php, I would use

    PHP Code:
    echo '<img src="/path/to/image.jpg" />'

  25. #25
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    One other advantage to using single quotes in your PHP code--it parses those strings faster, since it does not need to scan them and see if there are any variables or escaped characters. Also, to make things more readable, I do not include variables in strings but instead concatonate. So, how I would put an image in is:

    PHP Code:
    echo '<img src="'.$imagepath.$imagefile.'" alt="'.$imagealt.'">' 
    WWB


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
  •