Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering CSS

You're reading from   Mastering CSS A guided journey through modern CSS

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781787281585
Length 522 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Rich Finelli Rich Finelli
Author Profile Icon Rich Finelli
Rich Finelli
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. CSS Foundations 2. Ramping Up FREE CHAPTER 3. Creating a Page Layout with Floats 4. Creating Buttons with Modular, Reusable CSS Classes, and CSS3 5. Creating the Main Navigation and Drop-Down Menu 6. Becoming Responsive 7. Web Fonts 8. Workflow for HiDPI Devices 9. Flexbox, Part 1 10. Flexbox, Part 2 11. Wrapping Up

Descendant selectors

Renaming elements with classes, as you learned in the previous section, is an extremely powerful feature in CSS. However, that's not the only way to target a specific type of element. Descendant selectors will allow you to target elements on a page based on their ancestor elements. This is often necessary because you only want to apply a margin or a new font based on the context of the element. You can use a descendant selector to get that context without putting a class on every element every time you want to target it. I'm going to first explain what parent, sibling, and child elements are as well as what ancestor and descendant elements are. We'll need to be clear about these if we want to use descendant selectors. We'll follow this up by using a practical example of the descendant selector and finishing up by calculating the descendant...

You have been reading a chapter from
Mastering CSS
Published in: Oct 2017
Publisher: Packt
ISBN-13: 9781787281585
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime