Daniel Villanueva
Daniel Villanueva

Reputation: 3

HTML trouble linking CSS

I am trying to edit my HTML file called index.html using a css file called style.css which is located inside of /root/var/www/ and the html file i located in /root/var/www/html.

<!DOCTYPE html>
<html>
  <link rel="stylesheet" type="text/css" href="style.css">
<div class="body">
  <head>
    <title>Homepage</title>

I think its because they are in two different folders and i tried googling the problem which made me try using href="../style.css" which also did not work.

Upvotes: 0

Views: 51

Answers (2)

spencer.sm
spencer.sm

Reputation: 20526

Your html should be structured like this:

<!DOCTYPE html>
<html>
  <head>
    <title>Homepage</title>
    <link rel="stylesheet" href="../style.css">
  </head>
  <body>

  </body>
</html>

Upvotes: 1

Johannes
Johannes

Reputation: 67748

Your order and the hierarchy of tags is wrong: Start with <html> , then <head>, inside that put the link to the stylesheet (with href="../style.css"), but NO div yet, then close </head>, open <body> and then start with your DIVs etc., i.e. all the visible stuff. At the end close </body> and </html>

Upvotes: 0

Related Questions