CSS rules are applied without classes, why?
P粉795311321
2023-09-04 13:26:05
<p>I define CSS rules: </p>
<pre class="brush:php;toolbar:false;">.info-specs h2, h3, h4, h5 {
font-size: 1.5em;
text-transform: none;
}</pre>
<p>This should only work for h5 in elements with class "info-specs". However, upon inspection, I found that other h5 elements are also using this rule. Why?
Here's an example: </p>
<p>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.info-specs h2, h3, h4, h5 {
font-size:5em;
text-transform: none;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><h5>mytest </h5></code></pre>
</p>
The browser's CSS interpreter will look for any
h3
,h4
andh5
elements, and onlyh2 it will look at Is it within
.info-specs
. Comma or grouped selectors treat everything separated by commas as separate selections.Possible solutions to your problem are: