holmes0
holmes0

Reputation: 59

How to select anywhere inside something?

Let's say there's a big group of selectors:

a,
abbr,
acronym,
address,
applet,
article,
aside,
audio,
b,
big,
blockquote,
body,
canvas,
caption,
center,
cite,
code,
dd,
del,
details,
dfn,
div,
dl,
dt,
em,
embed,
fieldset,
figcaption,
figure,
footer,
form,
h1,
h2,
h3,
h4,
h5,
h6,
header,
hgroup,
html,
i,
iframe,
img,
ins,
kbd,
label,
legend,
li,
mark,
menu,
nav,
object,
ol,
output,
p,
pre,
q,
ruby,
s,
samp,
section,
small,
span,
strike,
strong,
sub,
summary,
sup,
table,
tbody,
td,
tfoot,
th,
thead,
time,
tr,
tt,
u,
ul,
var,
video{
    font:inherit;
}

How can I make them select only pure elements (without classes) inside anywhere of #some_container? I tried doing it like #some_container strong, but it didn't work properly. When doing it without adding anything as listed above, everything works fine, but it selects elements that I don't need to be selected.

<div id="some_container" class="test">
     <a href="https://google.com">Applies here</a>
     <div id="another_container">
         <strong>Applies here</strong>
         <strong class="anything">Does not apply here</strong>
     </div>
</div>
<div id="main">
     <strong>Does not apply here</strong>
</div>

Upvotes: 0

Views: 1065

Answers (1)

Reza Saadati
Reza Saadati

Reputation: 5439

Try it with:

.test strong:not([class]) {
  color: red;  
}
<div id="some_container" class="test">
     <a href="https://google.com">Applies here</a>
     <div id="another_container">
         <strong>Applies here</strong>
         <strong class="anything">Does not apply here</strong>
     </div>
</div>
<div id="main">
     <strong>Does not apply here</strong>
</div>

Also make sure to close " in your href attribute.

Upvotes: 1

Related Questions