SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: or &pound?

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    or &pound?

    hi all,

    which one should i use on my page?
    in the header i got:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    im using "&pound" on all my pages. the symbol looks fine in IE, but in Netscape(8.1) it will display both: "&pound" on normal pages, which is not the result i want, and displays "&#163;" inside tables.

    so im confused, what shall i use? how to gurantee it always displays "&#163;"?

    thanks

  2. #2
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    &pound;
    You sure you aren't missing the semicolon?

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx JonSiddle,

    you're right! i missed some of the semicolon.

    it works now in Netscape after i added these semicolons.

    anyway, is it more safe to use "&pound;" than just the symbol "&#163;"?

    thanks again!

  4. #4
    Brevity is greatly overrated brandaggio's Avatar
    Join Date
    Dec 2005
    Posts
    1,424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also use an ampersand then pound sign then the number 163 then a semi-colon.

    If the character you require is not a part of your charset you should use an entity.

  5. #5
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyway, is it more safe to use "&pound;" than just the symbol "&#163;"?
    Yes, since it works regardless of what default charset/conversions the browser supports. It's defined by the standards rather than just happening to work due to the charset.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should never use named character entities with XHTML, other than the five predefined in XML.

    XML parsers used in browsers aren't validating parsers and do not read the DTD (where entities are defined). Some browsers have the HTML entities hard-coded even for their XML parsers, but it's not something you can rely on.

    Either use a numeric character reference (&#38;#163;) or use a literal &#163; character. In the latter case, make sure that the encoding you declare matches the encoding you saved your markup file with. And remember that any encoding sent in the Content-Type HTTP header by your web server will override an XML declaration (or a pretend-XHTML <meta/> element).
    Birnam wood is come to Dunsinane

  7. #7
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way I read it, the entities are part of the XHTML1.0 spec:
    http://www.w3.org/TR/xhtml1/dtds.htm...n-1_characters:
    The XHTML entity sets are the same as for HTML 4, but have been modified to be valid XML 1.0 entity declarations. Note the entity for the Euro currency sign (&euro; or € or &#x20AC is defined as part of the special characters.
    Is there actually any browser which won't display &pound; correctly?

    Whatever you do I'd never use a literal &#163;

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JonSiddle View Post
    The way I read it, the entities are part of the XHTML1.0 spec:
    Yes, they are. But those entities are defined in the XHTML DTDs, and non-validating XML parsers are not required to read the DTD. Browsers use non-validating XML parsers.

    In other words, the HTML entities are valid to use in XHTML, but they can still fail in a browser or other user agent!

    Quote Originally Posted by JonSiddle View Post
    Is there actually any browser which won't display &pound; correctly?
    IIRC, Opera 7/8 did not have a hard-coded list of entities in their XML parser.

    Actually, it doesn't matter whether all existing browsers support character entities or not. Non-validating XML parsers do not have to read the DTD, ergo they are not guaranteed to understand any entities other than &#38;lt;, &#38;gt;, &#38;amp;, &#38;quot; and &#38;apos;.

    One of the main arguments from XHTML proponents is that XHTML can be used by other XML-aware user agents than web browsers. Surely there will be such user agents that will not have a hard-coded list of HTML entities? They may not even be aware that there is such a thing as HTML.

    Quote Originally Posted by JonSiddle View Post
    Whatever you do I'd never use a literal
    Why in the world not? As long as you declare the character encoding properly, there is absolutely nothing wrong with using literal characters (or , , , Chinese ideographs, etc.). That is why Unicode was invented.

    On the other hand, XML parsers are only required to support UTF-8 and UTF-16. And UTF-16 support seems to be rather iffy. Thus, you should always use UTF-8 with X(HT)ML, and if you do, there are no problems whatsoever with using a literal character.
    Birnam wood is come to Dunsinane

  9. #9
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, they are. But those entities are defined in the XHTML DTDs, and non-validating XML parsers are not required to read the DTD. Browsers use non-validating XML parsers.
    Ah, I see. Another braindead XMLism IMHO.

    Thus, you should always use UTF-8 with X(HT)ML, and if you do, there are no problems whatsoever with using a literal &#163; character.
    I'll take your word for that. I'd still use &#163; as it's more general.

  10. #10
    Brevity is greatly overrated brandaggio's Avatar
    Join Date
    Dec 2005
    Posts
    1,424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason to use the numeric reference regardless is that if you are using "real" XML it will still be rendered, unlike the HTML entities. This was an issue I ran into awhile back.

    If the user agent can't display your charset then you are going to have more than just the &#163; not showing so it to some extent is all or nothing - that is why if it is safe to use the charset you are using for your target audience and the character you want is a part of the available set, it too is safe to use.

    You should reserve the use of entities for those rare occasions when a character you need is not in the charset you are using.

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JonSiddle View Post
    Ah, I see. Another braindead XMLism IMHO.
    I'm prepared to agree with you. Entities are not very useful in XML, except in limited-scope applications.

    Quote Originally Posted by JonSiddle View Post
    I'll take your word for that. I'd still use as it's more general.
    I assume something got lost in the vBulletin posting thing, or you're contradicting yourself.

    A literal '' character or a decimal NCR (&#38;#163;) are the most reliable ways to insert a pound character. A hexadecimal NCR (&#38;#xa3;) may fail in old browsers. Using &#38;pound; is the least reliable way, especially for XHTML.
    Birnam wood is come to Dunsinane

  12. #12
    malloc
    Join Date
    Nov 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, yeah - I typed '& #163;' but it decided to turn it into


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
  •