Search code examples
htmlcsspre

How do I match nested tag?


I need to match pre when it is under long class, like in here:

<div class="long highlight-text">
  <div class="highlight">
    <pre>
      some code
  </pre>
  </div>
</div>

I tried: long.highlight.pre -- but doesn't seem to be working.


Solution

  • As from your test you seem to also want to include .highlight in the selector, I'd suggest this one :

    .long .highlight pre
    

    or if you just want to "match pre when it is under long class" :

    .long pre
    

    A space in a b means b is a descendant of a.

    Here's the official documentation on CSS3 selectors.