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

Stephen Calderon
Stephen Calderon
4,564 Points

In my basic attributes lesson. My css code is still not being applied to my web page. Im using a workspace. Please help.

<!DOCTYPE html>
<html>
<head>
  <title>Attribute Selectors</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <h1 class="main-heading">CSS Attribute Selectors</h1>
  <p>
      <span class="highlight"> Lorem idjsfi ishheih whiih</span>, jihe        ewjjjs kkjkjfd ksjds skj
  </p>
  <a href="#" class="foo">Duis ut ehwh kjnndnsks</a>
  <p>
     ewgwgwrgrwgwrgewgreahaehaerhsh. <a href="#" class="bar">                ewrtwetewtewtwetewtewte</a> erwerewrewrewrewrewrewrewrewr
  </p>
  <a href="#" target="_blank">view more in a new tab &raquo;</a>
    <form class="e-form">
      <input type="text" name="email">
      <input type="submit" name="submit">
    </form>
  </body>
  </html>
Stephen Calderon
Stephen Calderon
4,564 Points

HERES MY CSS

body {
    padding: 1% 22%;
    font: 1em/1.5 sans-serif;
}
form {
  margin-top: 30px;
}

/* Attribute Selectors */

a[class="foo"]{

  background-color: crimson;
  color: white;
  padding: 5px;
}

input[type="text"] {
  width: 200px;
  height: 25px;
  border: 2px solid grey;
  background:lightyellow;
}

input[type="submit"] {
  margin-left: 5px;
  width: 100px;
  height: 30px;
  border: none;
  background-color: steelblue;
  color: white;
}

a[target="_blank"] {
  text-decoration: none;
  border-bottom: 2px dotted crimson
}

2 Answers

Luke DePass
Luke DePass
6,843 Points

Hi Stephen,

Is it possible that your CSS file is in a different directory than the one you are linking to? You have:

<link rel="stylesheet" href="css/style.css">

This means style.css should be in the CSS folder, and the CSS folder should be in the same folder as your HTML file.

If your style.css file is in the same folder as your HTML file, you should link to style.css like this:

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

I hope this helps!

Hi Stephen,

Is the name of your CSS file style.css and is it located in the css folder?