SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

     appears at the top of my test page in FireFox?

    Hi,

    I have just started a basic web page layout, using XHTML and CSS.

    Here is the XHTML:

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <link rel="stylesheet" type="text/css" href="gw_css.css"/>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>GW Tester</title>
    </head>
    <body>

    <div id="container">

    <div id="Header">
    </div><!-- Header -->

    <div id="in_container">

    <p>Text goes here ****</p>

    </div><!-- In_Container -->

    </div><!-- Container -->

    </body>
    </html>


    Here is the CSS:

    * {
    padding: 0;
    margin: 0;
    }

    body {
    background: url(images/BKG.jpg) 0 0 repeat-x;
    text-align: center;
    }

    #header {
    width: 760px;
    height: 120px;
    background: url(images/header.jpg) 0 0 no-repeat;
    margin: 0 auto;
    border: 1px solid black;
    }

    #in_container {
    width: 780px;
    border: 1px solid red;
    height: 800px;
    margin: 0 auto;
    }


    It all works fine in I.E.7 and Safari 3 but when I look at this in FireFox I get a group of strange characters at the top of my page.

    The strange characters are: 

    If I remove the character set declaration they disappear.

    I am using Notepad to write this in, as I have always done in the past. The only difference is that I am now using Windows Vista and obviously a more up to date version of Notepad.

    Please help if you can

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Weird.....

    First, I would change the charset to utf-8.

    Also have you declared a DOCTYPE?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The byte order mark usually appears where the content is Unicode and served as some other character set. Changing the character set to UTF-8 will mean that the browser will correctly interpret the byte order mark instead of displaying it as text.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Those characters are the UTF-8 byter order mark (BOM), which indicates that the encoding you declare (ISO 8859-1) isn't the one you used when saving your source file.

    Either make the server state UTF-8 in the Content-Type HTTP header (and change the corresponding meta element) or re-save the document as ISO 8859-1.

    Even if you stick with UTF-8, you should save the file without a BOM, since it is unnecessary and only causes problems.
    Birnam wood is come to Dunsinane

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You only need the BOM with UTF-8 if you use characters that require more than one byte to hold them.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Wizard bronze trophy Centauri's Avatar
    Join Date
    May 2007
    Location
    Newcastle, Australia
    Posts
    3,718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know, Notepad will insert the BOM when saved as UTF-8, and I don't know whether this can be changed. Might be better to go with one of the better Notepad replacement programs that many here use.

  7. #7
    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 felgall View Post
    You only need the BOM with UTF-8 if you use characters that require more than one byte to hold them.
    You don't need the BOM in UTF-8, ever.

    The BOM is necessary in UTF-16, but it has no function whatsoever in UTF-8. The only reasons you'd use it is when there is no external way of declaring the encoding (such as a text file on a local hard drive). An application performing a heuristic test to detect the encoding would be able to recognise the BOM and decide that the encoding is UTF-8.

    UTF-8 uses 1-4 octets to encode characters, but they are sequences of single octets, unlike UTF-16 which uses two octets for any character. Thus, '' (U+00C4) is encoded as C3 84, regardless of whether the CPU byte order is big-endian or little-endian. There is no byte order that needs to be known.
    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
  •