XHTML rendering on browser

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Thoralina

    XHTML rendering on browser

    Hi,

    I created an XHTML page, but for some reason it isn't rendering on my
    browser. It is showing up as code.

    Any suggestions? Thanks.
  • Brian

    #2
    Re: XHTML rendering on browser

    Bill Thoralina wrote:
    [color=blue]
    > I created an XHTML page, but for some reason it isn't rendering on my
    > browser. It is showing up as code.[/color]

    Not enough info. Is the browser IE? What is the declared content-type?
    [color=blue]
    > Any suggestions?[/color]

    Yes. Give is a url, and tell us which browser (and os).

    --
    Brian (remove ".invalid" to email me)

    Comment

    • Philipp Lenssen

      #3
      Re: XHTML rendering on browser

      Bill Thoralina wrote:
      [color=blue]
      >
      > I created an XHTML page, but for some reason it isn't rendering on my
      > browser. It is showing up as code.
      >[/color]

      Sounds like you send the correct content-type, and you are using buggy
      Internet Explorer. You need to send XHTML files not as XML but as HTML
      for 90%* of your users to see it.

      *Approximation.

      --
      Google Blogoscoped
      A daily news blog and community covering Google, search, and technology.

      Comment

      • Lachlan Hunt

        #4
        Re: XHTML rendering on browser

        Bill Thoralina wrote:[color=blue]
        > Hi,
        >
        > I created an XHTML page, but for some reason it isn't rendering on my
        > browser. It is showing up as code.
        >
        > Any suggestions? Thanks.[/color]


        First, you should validate your document and make sure it is infact
        XHTML. Although I doubt this would prevent it from at least attempting
        to render the HTML, it's always a good start to solving most problems.
        W3C's easy-to-use markup validation service, based on SGML and XML parsers.


        Otherwise, this can happen in the following situations:

        If the document is being loaded from your local file system:
        * Check that it doesn't have a .txt extension.
        eg. file.html.txt or just file.txt, it will be treated as "text/plain"
        in everything, except IE because it will attempt to sniff the document
        and determine that it's HTML.
        * If it has a .xml extension, and no doctype or namespace declared,
        then you will see a document tree. IE will always show a document
        tree for anything with a .xml extension, whether or not is has a
        doctype and namespace. These files will be treated as either
        text/xml or application/xml.

        If this is being sent from a server
        * Check that the server is sending the correct Content-Type header
        eg. Content-Type: text/html or Content-Type: application/xhtml+xml,
        etc…
        If it's sending text/plain or text/xml or application/xml then see the
        above reasons. The XML media types are also correct, and
        should render correctly, however IE will incorrectly treat it as
        plain XML and show you the docuement tree, unless you use Dean
        Edward's recent hack which allows text/xml to render in IE.

        If this doesn't help solve your problem, could you please send a URI
        so we can see what is happening.

        --
        Lachlan Hunt

        lachlan.hunt@la chy.id.au.updat e.virus.scanners

        Remove .update.virus.s canners to email me,
        NO SPAM and NO VIRUSES!!!

        Comment

        • Kris

          #5
          Re: XHTML rendering on browser

          In article <egtIc.90786$sj 4.53290@news-server.bigpond. net.au>,
          Lachlan Hunt <lachlan.hunt@l achy.id.au.upda te.virus.scanne rs> wrote:
          [color=blue]
          > * Check that it doesn't have a .txt extension.
          > eg. file.html.txt or just file.txt, it will be treated as "text/plain"
          > in everything, except IE because it will attempt to sniff the document
          > and determine that it's HTML.[/color]

          If there is a browser that will treat it as plain text because of the
          file extension, then it is likely to be IE. It is the content-type
          header that first of all determines what kind of file it is. I can put
          images online with the extension .txt and serve them as image/jpeg and
          they will not be treated as plain text by most browsers. I will however
          not do so, since IE is the triggerhappy partycrasher here.

          --
          Kris
          <kristiaan@xs4a ll.netherlands> (nl)

          Comment

          • Brian

            #6
            Re: XHTML rendering on browser

            Kris wrote:
            [color=blue]
            > Lachlan Hunt wrote:
            >[color=green]
            >> Check that it doesn't have a .txt extension. eg. file.html.txt or
            >> just file.txt, it will be treated as "text/plain" in everything,
            >> except IE because it will attempt to sniff the document and
            >> determine that it's HTML.[/color]
            >
            > If there is a browser that will treat it as plain text because of
            > the file extension, then it is likely to be IE.[/color]

            We've had this discussion before. IE only considers the file extension
            after other means have been tried. I might add that you snipped the
            context. L Hunt was talking about opening a file on a local file
            system, where file extension might have some meaning.
            [color=blue]
            > It is the content-type header that first of all determines what
            > kind of file it is.[/color]

            In a network situation, sure.
            [color=blue]
            > I can put images online with the extension .txt and serve them as
            > image/jpeg and they will not be treated as plain text by most
            > browsers. I will however not do so, since IE is the triggerhappy
            > partycrasher here.[/color]

            Have you tested this? MS claims that IE sniffs the content and guesses
            the correct content-type. If I believe MS, the problem isn't as you
            describe it. On the contrary: if you declare the content-type as
            text/plain, IE may treat it as something else, e.g., image/jpeg.

            --
            Brian (remove ".invalid" to email me)

            Comment

            • Keith Bowes

              #7
              Re: XHTML rendering on browser

              Philipp Lenssen wrote:[color=blue]
              > Bill Thoralina wrote:
              >
              >[color=green]
              >>I created an XHTML page, but for some reason it isn't rendering on my
              >>browser. It is showing up as code.
              >>[/color]
              >
              >
              > Sounds like you send the correct content-type, and you are using buggy
              > Internet Explorer. You need to send XHTML files not as XML but as HTML
              > for 90%* of your users to see it.
              >
              > *Approximation.
              >[/color]

              Or can send it as application/xml as a cruel joke.

              Comment

              • Ian

                #8
                Re: XHTML rendering on browser

                Bill Thoralina wrote:
                [color=blue][color=green]
                >> You need to send XHTML files not as XML but as HTML
                >> for 90%* of your users to see it.[/color][/color]

                I've heard the term "content negotiation" referred to as a
                solution to this. I figure it involves having Apache serve
                application/xhtml+xml to Mozilla/Opera/etc. and text/html to IE.
                Is this a practical solution?

                Ian
                --

                Comment

                • Brian

                  #9
                  Re: XHTML rendering on browser

                  Ian wrote:
                  [color=blue]
                  > Bill Thoralina wrote:
                  >[color=green][color=darkred]
                  >>> You need to send XHTML files not as XML but as HTML for 90%* of
                  >>> your users to see it.[/color][/color]
                  >
                  > I've heard the term "content negotiation" referred to as a solution
                  > to this. I figure it involves having Apache serve
                  > application/xhtml+xml to Mozilla/Opera/etc. and text/html to IE. Is
                  > this a practical solution?[/color]

                  Only if done very carefully. IE/Win does not include text/html in its
                  accept header (sic), and will thus happily accept xhtml that it cannot
                  parse. Thus, you have to look explicitly for application/xhtml+xml in
                  the header, and send text/html if it isn't there. Then you must
                  disable caching, so that IE/Win users don't get the appl...xml version
                  via a proxy cache.

                  In short, I don't recommend it. The costs are rather high, for very
                  little benefit. But ciwah regular Mark Tranchant managed to pull it
                  off without too much adverse effects.



                  Call him brilliant, persistent, or crazy. I'd go for at least 2 of
                  them. ;-) His switcher works, but note the no-cache header.

                  --
                  Brian (remove ".invalid" to email me)

                  Comment

                  • Ian

                    #10
                    Re: XHTML rendering on browser

                    On Mon, 26 Jul 2004 20:36:24 -0400, Brian
                    <usenet3@juliet remblay.com.inv alid> wrote:
                    [color=blue]
                    >http://tranchant.plus.com/notes/xhtml11
                    >
                    >Call him brilliant, persistent, or crazy. I'd go for at least 2 of
                    >them. ;-) His switcher works, but note the no-cache header.[/color]

                    Thanks, Brian. I'll keep that in a cubbyhole until I become better
                    educated. :-)

                    Ian
                    --

                    Comment

                    • Claire Tucker

                      #11
                      Re: XHTML rendering on browser

                      On Mon, 26 Jul 2004 20:36:24 -0400, Brian
                      <usenet3@juliet remblay.com.inv alid> wrote:
                      [snip!][color=blue]
                      >Then you must
                      >disable caching, so that IE/Win users don't get the appl...xml version
                      >via a proxy cache.
                      >[/color]

                      Theoretically, you should be able to send:
                      Vary: Accept
                      ....in the response header so that caches either don't cache at all or
                      cache a different version for each unique Accept header. Of course, in
                      practice caches probably ignore this rule completely.

                      -Claire

                      Comment

                      • Alan J. Flavell

                        #12
                        Re: XHTML rendering on browser

                        On Tue, 27 Jul 2004, Claire Tucker wrote:
                        [color=blue]
                        > Theoretically, you should be able to send:
                        > Vary: Accept[/color]

                        If you're negotiating on the Accept header, then it would indeed be
                        very remiss of you not to do so.
                        [color=blue]
                        > ...in the response header so that caches either don't cache at all or
                        > cache a different version for each unique Accept header.[/color]

                        Keep in mind that the client or proxy still has the option (if using
                        HTTP/1.1) to say to the server, "excuse me, I have this ETag on hand,
                        how would you feel if I used this to fulfil the request" and the
                        server can say either "go ahead" or "no, here's the correct variant".
                        Or in technical terms, an "if-any-match" request to the origin server.
                        [color=blue]
                        > Of course, in
                        > practice caches probably ignore this rule completely.[/color]

                        Of course, in practice HTTP/1.0 proxies will follow HTTP/1.0 rules;
                        whereas HTTP/1.1 proxies aren't mandated to use if-any-match requests:
                        it's optional.

                        But if everyone would follow the rules (if -only- everyone would
                        follow the interworking rules, instead of assuming that because
                        they're the biggest they have to be right), the results could be
                        correct, even when the response might be a bit slower than it had to
                        be.

                        Comment

                        • Alan J. Flavell

                          #13
                          Re: XHTML rendering on browser

                          On Tue, 27 Jul 2004, Alan J. Flavell wrote:
                          [color=blue]
                          > Or in technical terms, an "if-any-match" request to the origin server.[/color]

                          What *was* I thinking??? That should've been "if-none-match", of
                          course.

                          Comment

                          • Brian

                            #14
                            Re: XHTML rendering on browser

                            Alan J. Flavell wrote:[color=blue]
                            > On Tue, 27 Jul 2004, Alan J. Flavell wrote:
                            >[color=green]
                            >> in technical terms, an "if-any-match" request to the origin
                            >> server.[/color]
                            >
                            > What *was* I thinking??? That should've been "if-none-match", of
                            > course.[/color]

                            That explains it! I read that message a couple of times, and wasn't
                            sure how a if-any-match request would fit in. ;-)

                            --
                            Brian (remove ".invalid" to email me)

                            Comment

                            • Alan J. Flavell

                              #15
                              Re: XHTML rendering on browser

                              On Wed, 28 Jul 2004, Brian wrote:
                              [color=blue]
                              > Alan J. Flavell wrote:[color=green]
                              > > What *was* I thinking??? That should've been "if-none-match", of
                              > > course.[/color]
                              >
                              > That explains it![/color]

                              Somehow got my wires crossed with Apache's "satisfy any", but that's
                              something entirely different. I blame the fading grey cells...

                              Comment

                              Working...