0

For legacy reasons, my CSS class is has a .x prefix:

.x input.myclass {
  background-color: red;
}

I'm not familiar with this syntax, how can I use this class in an HTML element? None of the below work:

<input type='text' class='myclass'>
<input type='text' class='x myclass'>
<input type='text' class='.x myclass'>
<input type='text' class='.x.mylcass'>
<input type='text' class='x.mylcass'>
4
  • 3
    that's a descendant selector. Please spend more time researching CSS syntax. Commented Jul 12, 2017 at 17:23
  • 1
    The only CSS prefixes I'm aware of are -webkit-, -moz-, -o-, and -ms- and what you have above isn't close to that. Commented Jul 12, 2017 at 17:28
  • 2
    @zzzzBov's is right: if you read, say, the MDN article on CSS selectors, you would have had the knowledge to answer your own question. Looking at your other css questions, it seems like there are others that you could also solve by reading some docs first. Commented Jul 12, 2017 at 17:35
  • 1
    @j08691 it's pretty normal for someone in a new technology to not know the right terminology. In the general sense of "prefix", yes, .x is a prefix. In the css sense, no, it definitely isn't. It seemed pretty clear to me what he was trying to communicate, though Commented Jul 12, 2017 at 17:38

1 Answer 1

2
.x input.myclass {
    // css goes here
}

The above CSS will affect any input tag with a class of myclass wrapped inside any containing block of class x

Therefore it will match the pattern below:

<div class="x">
    <input type="text" class="myclass" />
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.