0

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?

1
  • #test, .test {} and #test input[type="text"], .test input[type="text"] {} if you weirdly need to be able to handle both cases. Commented Jul 26, 2013 at 15:22

2 Answers 2

3

Use . to signify a class.

.test {
    color: red;
}
Sign up to request clarification or add additional context in comments.

3 Comments

Yes... this is not the problem... My problem is about the input under the class
Add input after the .test, so .test input
Same concept... see DevlshOne's answer to have it spelled out for you. Also would recommend that you take some time to go through one of the many many CSS tutorials on the web. (I have to say that this is the first time I've seen someone using the attribute-selector and /not/ understand basic class-selectors first!)
2

Simply replace the # with a . (period):

.test {
   color:#F00;
}

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.