My CSS won't work


#1

I am trying co get my CSS to work on my site, and it isn’t working. Just to give you an idea of what is happening, here is the coding:

<!DOCTYPE html>
<html>
  <head>
    <title>Hawkblade's Themes</title>
    <link rel="stylesheet" type="text/css" href="/bfthemes.info/style.css">
  </head>
<body>
  <h1>Welcome to HawkBlade's themes!</h1>
</body>
</html>
html,body{
background:#000fff;
font-family: arial;
font-size: 12px;    
}

h1 {
font-family:Times New Roman;
font-size:20px;
text-align:center;
}

Is there anything wrong?


#2

Can you link to the page? It may be how you’re calling the file :slight_smile:


#3

Yes I can link to the page, but when i link to the page, I get the “Index of /” is there any way to get rid of that?


#4

The path to your CSS file looks… odd. It needs to be relative to your site root, not to your FTP account — unless there is a folder called “bfthemes.info” inside your web directory (which there doesn’t appear to be), you should just be linking to it as “/style.css”.

Also, you cannot (and do not need to) style the “html” element in CSS, as it is never rendered on screen. The highest-level element “visible” to CSS is the “body” element. Additionally, if you are going to change the background color, you should probably also set the foreground color (using the “color” attribute), as the user’s default colors may clash with the background you set.


#5

Ah, okay. So all I have to do is just place a forward slash behind my css file? That seems to be easy enough.


#6

If it’s in the same folder, you can do “style.css” on it’s own. The leading / says ‘In my main folder…’

Also the reason you get ‘index of…’ is because you don’t have an index file :slight_smile: Make one named index.html or index.php to fix that :slight_smile:


#7

Thank you again, I love the support that you guys give, you rock!