CSS 3 class selector not working?

+1 Lois Lewis · September 8, 2015
Hello, I am following the tutorials on this website for HTML 5. Specifically, I'm following this tutorial: https://www.thenewboston.com/videos.php?cat=43&video=18822

In the beginning of the tutorial, Bucky shows how to style things using classes. Following his instruction, in the CSS file I use the following line:

.tuna{color:yellow;} //class

Then, in the body of the HTML file, I use the following line:

<p class="tuna">test</p>

However, when I test this, the text doesn't turn yellow as I think it is supposed to. Anyone know what could be causing this?

Post a Reply


Oldest  Newest  Rating
0 rajeev man dongol · September 8, 2015
have you linked the css file to your html file ?
0 Lois Lewis · September 9, 2015
Yes, or at least I think so. Not sure how to use code tags on this forum but here is my full code:


#tina{color:red;} //ID
.tuna{color:yellow;} //class (not working)
p.tuna{color:blue;} //attribute + class (not working)


<!doctype html>

<html lang="en">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="main.css" />
        <link rel="icon" type="image/x-icon" href="./favicon.ico"> 
        <p id="tina">omgwtfbbq?</p>
        <p class="tuna">test</p>
        <p name="whatever">damnation</p>
0 rajeev man dongol · September 9, 2015
<link rel="stylesheet" type="text/css" href="">
in your code you hanen't define the type . 
0 Lois Lewis · September 10, 2015
Thanks! That solved the problem
0 rajeev man dongol · September 10, 2015
how ?
  • 1

HTML / CSS / Web Design


Discuss, share, ask, learn and teach HTML5 and CSS3.