Furkan İlhan Furkan İlhan - 6 months ago 15
CSS Question

Why the CSS header does not work

I have an external CSS file name main.css. The ID nav, section and footer are working fine but the ID header doesn't work. When I put the header part in HTML file, it works. Why does it not work in CSS file.

---------------------------HTML File-------------------------

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="main.css">
<meta charset="UTF-8">
</head>

<body>

<div id="header">
<h1>Furkan İlhan</h1>
</div>

<div id="nav">
Hakkında<br>
Kariyer<br>
Projeler<br>
Galeri<br>
</div>

<div id="section">
<h2>Hakkında</h2>
<p>asfsfsdfsdfsdfsdfsdfsfwefsdfsefssdsfsgsgsdsdsdgsdssdsssdmskdfmsldsmdlfskmflsmfsfm,
sdfsfsdfsdfsdfsdfsfsefsefsefsefsefsefsefsefsefsefsefsefsef</p>
<p>asfsfsdfsdfsdfsdfsdfsfwefsdfsefssdsfsgsgsdsdsdgsdssdsssdmskdfmsldsmdlfskmflsmfsfm,
sdfsfsdfsdfsdfsdfsfsefsefsefsefsefsefsefsefsefsefsefsefsef</p>
</div>

<div id="footer">
Tüm Hakkı Saklıdır. Furkanilhan.com
</div>
</body>

</html>


--------------------------CSS File-------------------------------

<style>

#header {
background-color:black;
color:white;
text-align:center;
padding:5px;

}

#nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}

#section {
width:350px;
float:left;
padding:10px;
}

#footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>


The image of result

Answer
  1. Dhaval is wrong - You had it right with the #header since you have it as an id in your HTML.

  2. remove the <style></style> tags from your CSS sheet.

Let me know how you go

Regards,
Kostantinos