Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Open local xhtml files in chrome, however, chrome treats it as XML files, and won't render it as HTML.

I don't want to change all my *.xhtml file extension to .html, so is there any workaround?

EXAMPLE

a.xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
        <b>Hello</b>, 
        <i>World</i>!
    </body>
</html>
share|improve this question
    
Can you pastebin an example xhtml file? I did a test on my computer and google chrome opened up my xhtml file without issue. Perhaps you have the wrong DOCTYPE declared? –  OmnipotentEntity Apr 17 '11 at 5:45
    
I've added the example, thanks. –  Xiè Jìléi Apr 17 '11 at 5:56

1 Answer 1

up vote 5 down vote accepted

Because you declared XHTML-1.0 strict your html tag needs an xml namespace:

<html xmlns="http://www.w3.org/1999/xhtml">

A few other validation issues: you need a character set declaration and your text needs a <p> around it.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Example</title>
    </head>
    <body>
      <p>
        <b>Hello</b>, 
        <i>World</i>!
      </p>
    </body>
</html>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.