LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2009, 09:33 PM   #1
gautamshaw
LQ Newbie
 
Registered: Jun 2009
Posts: 16

Rep: Reputation: 0
Angry Running a HTML/CSS causing some problem!!!


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??
 
Old 09-26-2009, 01:58 AM   #2
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by gautamshaw View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS - Is there a way to put several lines of HTML into one line using CSS? Chronothread Programming 12 01-05-2011 07:06 AM
HTML/CSS/JS: Problem with <p> not having an absolute position with CSS. RHLinuxGUY Programming 7 03-03-2007 01:21 AM
A little HTML/CSS help? jon_k General 9 07-17-2005 02:49 AM
html/css retrodict Programming 5 11-01-2004 07:56 PM
html/css hylke Programming 0 06-27-2004 03:39 PM


All times are GMT -5. The time now is 03:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration