I’m trying to select the class .signup-choose-subtitle
and .signup-choose-list li
in my parent class of signup-choose-card-content
to apply the font-family.
This is my code in css
.ja_jp
.signup-container
.signup-content
.signup-choose-card-content
.signup-choose-subtitle
.signup-choose-list li
{
font-family: "M+1C", Roboto, sans-serif;
}
and code in the html
<div class="signup-choose-card-content">
<p class="signup-choose-subtitle" translate="">Easy registration in 15 seconds! Play now!</p>
<p class="signup-choose-text-highlight">Lite</p>
<ul class="signup-choose-list">
<li translate="">No identity verification required</li>
<li translate="">Over 2,000 games</li>
</ul>
</div>
My goal is to overwrite the existing font-family: "Bahnschrift", Roboto, sans-serif;
to font-family: "M+1C", Roboto, sans-serif;
like this image:
2
Answers
Option 1
Target specific elements that are nested within the
.signup-choose-card-content
element.See the snippet below.
Option 2
Target all elements within the
.signup-choose-card-content
element by using the direct child selector (i.e.,>
) except paragraphs with the classsignup-choose-text-highlight
.See the snippet below.
According to your description you would probably want it this way (I added the border-property for better visibility druing development):
With the child combinator you can select direct children of classes/elements etc, see here: https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator