Pablo
Pablo

Reputation: 29519

CSS syntax questions

.features img{...}

I understand .features is custom CSS class and div is HTML element. But I don't understand what kind of relationship this syntax will build between them?

Upvotes: 1

Views: 93

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245489

This syntax doesn't build any relationship between the .features class and a div.

The style that you provided is styling any child <img> tag contained within a .features class.

Both of these would be valid and apply the given style to the image:

<div class="features">
    <img src="myImg.png" />
</div>

and

<table class="features">
    <tr>
        <td><img src="myImg.png" /></td>
    </tr>
</table>

If you wanted to specify that your class was only applicable to divs, you would need to change the declaration to:

div.features img { }

Upvotes: 3

Related Questions