Attribute name not allowed on element paragraph at this point?

0 Lois Lewis · September 8, 2015
Hello, I'm following this tutorial: https://www.thenewboston.com/videos.php?cat=43&video=18822

I'm trying to use attribute selectors, as explained in the tutorial, using the following lines:

CSS file: p[name]{color:green;} //attribute selector

HTML file (In body): <p name="whatever">omgwtfbbq</p>

I am using NetBeans IDE 8.0.2, and it gives me the error "attribute name not allowed on element paragraph at this point"

And when I test it the line doesn't change color like it is supposed to.

I have tried just double-clicking the file to test it instead of running it through NetBeans but it has the same problem.

Anyone know what could be going wrong? The code is practically exactly copied from the tutorial so I'm very confused

Post a Reply

Replies

Oldest  Newest  Rating
0 rajeev man dongol · September 8, 2015
have you linked the stylesheet 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:

main.css:

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


index.html:

<!doctype html>

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Title</title>
        <link rel="stylesheet" href="main.css" />
        <link rel="icon" type="image/x-icon" href="./favicon.ico"> 
    </head>
    <body>
        <p id="tina">omgwtfbbq?</p>
        <p class="tuna">test</p>
        <p name="whatever">damnation</p>
        
        
        
    </body>
</html>
0 rajeev man dongol · September 9, 2015
<link rel="stylesheet" type="text/css" href="">
0 rajeev man dongol · September 9, 2015
make sure you have save the .css and .html file in same folder/directory
0 Lois Lewis · September 10, 2015
Thanks! That solved the problem
0 rajeev man dongol · September 10, 2015
how ?
  • 1

HTML / CSS / Web Design

107,052 followers
About

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

Links
Moderators