Perocat
Perocat

Reputation: 1521

Apply style to elements in a div with a class

What I am able to do:

HTML:

<div id="test">
    HELLO! 
    <input type="text">
</div>

CSS:

#test {
   color:#F00;
}

#test input[type=text] {
   background-color:#000;
}

What I'd like to do is the same thing if the #test has not an ID but a class:

<div class="test">
   ...

How should I write the CSS in this case?

Upvotes: 0

Views: 48

Answers (2)

DevlshOne
DevlshOne

Reputation: 8457

Simply replace the # with a . (period):

.test {
   color:#F00;
}

.test input[type=text] {
   background-color:#000;
}

Upvotes: 2

tymeJV
tymeJV

Reputation: 104775

Use . to signify a class.

.test {
    color: red;
}

Upvotes: 3

Related Questions