4

I've got a really strange issue that I hope some of you can help me with:

Any local HTML file I have doesn't get rendered. If I view the source in the browser, I get the full HTML source, but the displayed page is blank, the page isn't rendered.

I have tried this with both firefox and chrome.

To clarify, normal browsing is totally fine.

For example, if I have a really simple html file:

<html><body>Hello</body><HTML>

and I open it through the browser (by pointing it to file://path/to/file.html), I get a white empty window. If I view the source of this window, I get the correct html.

Any ideas what might be causing this?

system: Ubuntu 14.04

muru
  • 197,895
  • 55
  • 485
  • 740
chaixdev
  • 91
  • 1
  • 7
  • 1
    Open your browser's development tools (F12) and check in the JS console if there are errors or meaningful messages. – Palantir Oct 18 '15 at 16:56
  • Please [edit] your question and tell us i) what webserver you are using; ii) whether there are any errors in your webserver's logs; iii) what happens if you use a very simple HTML page: <html><body>Hello</body><HTML>. – terdon Oct 18 '15 at 17:12
  • @terdon I just removed my remark about node.js, because it's probably irrelevant. My problem is with opening html files directly from the file browser, so the path in my browser says something like file:///media/Data/page.html

    @Palantir the browser console does not give any errors

    – chaixdev Oct 18 '15 at 17:30
  • Check if there is any default styling for the font color for local files. Try inline style for the font color e.g. - <html><body><p style="color:black;">Hello</p></body><HTML> – Sri Oct 21 '15 at 03:28
  • Right. @chaixdev Node is totally irrelevant here. Default color is black over white background. – Jose Barakat Nov 11 '16 at 05:10

3 Answers3

1

The main issue here is the lack of a proper HTML skeleton.

For HTML5:

<!DOCTYPE html>
<html lang="es">

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Title Page</title>
    </head>

    <body>
        <h1 class="some-class">Hello World</h1>
        <p>
           Fresh I'm king of the world do Vanilla Ice, Dolly the Sheep the Matrix Beavis and Butthead Umbro shorts tying your sweater around your waist. 
           Accent braids Ken Griffey Jr Honda Accord in Courtney Love I believe I can fly. 
           Tamagotchi Madonna hottie yo quiero Taco Bell Pontiac Trans Sport adipiscing.
        </p>
    </body>
</html>

CSS and JavaScript not included (and not necessary to render plain text).

Check this out:
HTML !DOCTYPE Declaration

1

What editor are you using? I once had some issues with an editor that didn't actually save as html. Can you run cat -v path/to/file.html to check out the proper file contents? It should be the exact same html you expect to work properly...

tpei
  • 458
0

Try installing xampp for ubuntu.

Then move or create your html files that were not rendering to the /opt/lampp/htdocs and try to open them from there.

You will probably have permission issues creating files or folders there. Follow How to save projects file in htdocs to solve that issue.

Finally on the part of changing ownership of that htdocs folder correct syntax is:

chown -R USER:GROUP DIRECTORY e.g. sudo chown YourUserName:xamppusers /opt/lampp/htdocs

I had earlier noted his syntax: sudo usermod -R root.xamppusers /opt/lampp/htdocs was not working or is incorrect.

That worked for me. And I am able to render html pages on chrome browser now.

Gryu
  • 7,559
  • 9
  • 33
  • 52
MosesK
  • 101