CSS3 > Selectors

Descendant selector in CSS3

How to specify CSS style for the Descendant of the parent element in CSS3?


Descendant selector is used to specify css style for the descendent of the parent element.

<style>
        .myGallery li {
            background-color: Fuchsia;
            border: 1px solid #c0c0c0;
        }
</style>

<body>
    <div style="background-color: #efefef; padding: 50px; height: 150px;">
        <ul class="myGallery">
            <li>
                <img src="../images/dotnetlogo.gif" /></li>
            <li>
                <img src="../images/iconnectin.gif" /></li>
            <li>
                <img src="../images/itfunda.gif" /></li>
            <li>
                <img src="../images/myfundalogo.gif" /></li>
        </ul>
    </div>
</body>

In the above code snippet, we applied class to the <ul> tag and the images are place inside the <li> tags.

OUTPUT

 Views: 3660 | Post Order: 6



Write for us






Hosting Recommendations