SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Not using &amp

  1. #1
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    740
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not using &amp

    I have some html that seems to work but I am getting the following comment from an html validator:

    [64] An invalid entity was found in the value for the "href" attribute. Often this is because the ampersand character was not properly encoded as the entity "&". Example 1: href="script.cgi?var1=value&var2=value" should be href="script.cgi?var1=value&var2=value", example 2: alt="For him & her" should be alt="For him & her". Note that the ampersand in the values was encoded as "&".
    It is referring to this line of code:

    HTML Code:
    <a href="main.php?navtype=products&category=business&filter=1">
    Is it essential? What happens if I leave it like it is? Does it slow page loading or something?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Look at the results of the links on this page to see why you shouldn't keep those ampersands unencoded.

    More info

  3. #3
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    740
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

  4. #4
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in reality however it is not very likely, you will encounter any trouble with it.. but it is wise to just use the special char code
    Go visit my site :-D you know you want to ;-)
    www.mech7.net

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use (real) XHTML, an unencoded ampersand constitutes a well-formedness error, which causes a Yellow Screen of Death in Gecko browsers. If you're ever planning on switching to XHTML, it's a very good thing to learn to always encode your ampersands.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    causes a Yellow Screen of Death in Gecko browsers.
    Care to explain that one Cuckoo? Havent heard of this bug yet.

  7. #7
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not a bug. Conforming XML parsers must return an error message to the user when it encounters a well-formedess error. Here's a test case:
    Code:
    data:application/xml,<foo> & </foo>
    Simon Pieters

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dc dalton
    Care to explain that one Cuckoo? Havent heard of this bug yet.
    As zcorpan said, it's a feature, not a bug. When Mozilla or Firefox encounter a malformed X(HT)ML page, it will present a big fat error message on a page with a pale yellow background. This has been dubbed the YSoD (Yellow Screen of Death), referencing the BSoD (Blue Screen of Death) with which users of Microsoft operating systems are all too familiar.

    An XML parser must abort when it encounters a well-formedness error, according to the XML 1.0 specification. Gecko browsers do so with extreme prejudice. Opera will render as much as it can of the page (before the error), and give you a little more information about where the error occurred.
    Birnam wood is come to Dunsinane


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
  •