Quote:
Originally Posted by gautamshaw
I want to run an HTML page with some embedded CSS also working in the same HTML page.So at first i started the httpd service by:
httpd -k start
Then i saved the .html page in the /var/www/html and the html page runs well.But when i use a CSS in the HTML page then the HTML portion of the page works but the CSS part does not work........
Again,i tried to run the same HTML with embedded CSS in windows platform and it works great......
Then how to run the HTML page along with the embedded CSS??
|
In a situation like this, you need to make the problem as simple as possible. There is no way that either the choice of operating systme or the HTTP server can prevent CSS from working, so the problem must be how you are locating the HTML page, and its associated CSS file, with respect to each other
or file permissions.
First, if you do not use a separate CSS files (you do not say), then what you have described is, simply put, impossible. So use this example instead of your own HTML page:
Code:
<html>
<head>
<title>
Test Page
</title>
<style type="text/css">
p {
background-color:red;
}
</style>
</head>
<body>
<p>This should have a red background.</p>
</body>
</html>
Copy the above text block into an HTML file named "index.html," put it in an appropriate location with respect to your server and view it with your browser using an appropriate network address (beginning with (
http://), not a local file path (beginning with file://).
If the Web page is not accessible, or if the single displayed line is not red in color, than the problem is not HTML, it is not Linux, and it is not your Web server.
Step two. Create a separate file called "styles.css". In the file put this:
Code:
p {
background-color:red;
}
And in your HTML page put this (replace the prior content):
Code:
<html>
<head>
<title>
Test Page
</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<p>This should have a red background.</p>
</body>
</html>
Now
do not get creative. Just put the above into your HTML file, identical, character for character. Save it. Put the previously created CSS file with the name "styles.css" in the
same directory as the HTML file, not somewhere else. Make sure both files are universally readable and have the names I have specified.
The displayed HTML page will show a single red line. If it does not show a single red line, go to the top of this page and start over. Do not miss any steps, pay attention to the details, don't get distracted.
This example follows the time-honored practice of reducing a problem to its simplest possible terms. If
anything goes wrong, stop, re-read the instructions, and start over.
If the Web server is running, if the files are located in an appropriate position
in the same directory, if the files are universally readable, if you are using the correct address in your Web browser, the page will be visible and the CSS component will have the expected effect.