penguru
penguru

Reputation: 4370

DOCTYPE CSS problem

When I added

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

line to the top of my html file, my css rules disappear in firefox. Also i can't see them with firebug.

Do you have any idea about this problem ?

Upvotes: 2

Views: 4788

Answers (3)

Ravi Chauhan
Ravi Chauhan

Reputation: 1458

Please check it

http://www.w3schools.com/tags/tag_doctype.asp

i think you have more idea of doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
padding:0;
margin:0;
height:100%;
}
#wrap {
background:red;
height:100%;
overflow:hidden;
}
#right {
background:blue;
float:left;
width:30%;
height:100%;
}
#left {
background:yellow;
float:left;
width:70%;
height:100%;
}
</style>
</head>
<body>
<div id="wrap">
<div id="left"> Content </div>
<div id="right"> Side Content </div>
</div>
</body>
</html>

Upvotes: -1

RoToRa
RoToRa

Reputation: 38390

Make sure that the files are sent by the server with the correct MIME type (text/css). Have a look in the error console ( IIRC the menu should be Tools / Error Console in the English version).

Usually, if the file ends with .css, this should happen automatically, however there are still badly configured servers around. If you are using a Apache web server, you may be able to correct this with a .htaccess file, otherwise you'll need to ask your support.

Details: https://developer.mozilla.org/en/incorrect_mime_type_for_css_files

Upvotes: 3

Benny Skogberg
Benny Skogberg

Reputation: 10681

You need to add attributes to your start-html tag to get it right. This is done since XHTML really is XML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    ...
    </body>
</html>

The code above suggest you to have the style.css file in the root-catalog of your website.

Upvotes: 2

Related Questions