Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I select an element under another element in CSS?

In HTML I have:

<td bgcolor="#f9f8bb">
   <b>text here</b>

How can I select this specific bold text that is under the td element using CSS? I wonder if it possible to write something like:

td.b[bgcolor*="#f9f8bb"] {...}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can give this a shot:

For all child nodes

td[bgcolor="#f9f8bb"] > b {
  color: red;
}

For a single child node

td[bgcolor="#f9f8bb"] b {
  color: red;
}

References:

Selecting a tag by attribute

Selecting all child tags

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading