0

What am I not seeing here?

HTML (index.html):

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" type="text/css" href="css/style.css"></link>
  </head>

  <body>
  </body>
</html>

CSS: (css/style.css)

body{
  background-color:black;
}

I already double-checked the file structure. What am I missing?

DJG
  • 435
  • 2
  • 14
  • Oops. Bootstrap (which I removed from the example because I assumed it didn't modify or double up on default page attributes) was the problem. – DJG Jul 17 '16 at 01:36

1 Answers1

5

Don't give your link element a closing tag. Either leave it as <link attributes='values'> or make it self closing: <link attributes='values'/>

body{
  background-color:black;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" type="text/css" href="css/style.css">
  </head>

  <body>
  </body>
</html>

Less typing if you leave the / off self closing tags. In HTML5 this is ok, however there are other versions of HTML and XML that require all tags to be formally closed.

link: Are (non-void) self-closing tags valid in HTML5?.

Update: Despite this, most browsers still render correctly when the link element is closed incorrectly. And that wasn't the problem here.

Community
  • 1
  • 1
  • Also don't close `` tags (for future references). Most tags require closing tags but very few of them don't. – btrballin Jul 17 '16 at 01:29