Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Desmond Dallas
Desmond Dallas
6,985 Points

Css/HTML

Can anyone help me with this. It is driving me crazy lol.

Ive done code for HTML and CSS. When I incode CSS on the same page as HTML its fine when refreshing browser. Now when I put the CSS in a different file and link it to the HTML file it all goes wrong. Can you look on these and tell me what is wrong please.

CSS FILE <style> ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #FF8C00; }

li { float: right; }

li a { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; }

li a:hover { background-color: #111; } </style>


HTML FILE <!DOCTYPE html> <html> <head>

<link rel="stylesheet" href="styles.css">

<body>

<ul> <li><a class=β€œactive” href=β€œ#home”>Home</a></li> <li><a href=β€œ#news”>News</a></li> <li><a href=β€œ#contact”>Contact</a></li> <li><a href=β€œ#about”>About</a></li> </ul>

</body> </html>

5 Answers

Christopher De Lette
PLUS
Christopher De Lette
Courses Plus Student 7,139 Points

First thing you don't have a closing </head> tag after your link reference and not sure what you named your css file however make sure it exactly matches what you have listed in the href attribute of your link tag in the head section.

Hope this helps,

Chris

Hi,

did you leave the <style>-Tags in the separate css-file? You should have them removed when using a separate file.

Desmond Dallas
Desmond Dallas
6,985 Points

Thanks something changed but still not working. Ive placed the HTML and CSS Files in a folder, which I named 'My Website'.

The CSS file is named 'styles.css and HTML file name 'index.html'.

The ref link in HTML file: <link rel="stylesheet" href="styles.css">

Desmond Dallas
Desmond Dallas
6,985 Points

Haaaa its working now... Thanks guys nice one

How did you solve the prob?

Desmond Dallas
Desmond Dallas
6,985 Points

If I remember correct I didn't but the HTML and CSS files in the same folder