Coding task · HTML and CSS course · Module 3: CSS Basics
Descendant Selectors in Structure
In Egyptian hierarchy, the pharaoh's child inherited the title. In CSS, the descendant selector (e.g., div p) styles elements inside others. The child selector (div > p) styles only direct children. Use nested selectors for precise control!
Task
Create a structure: <div class='temple'> with <div class='room'> inside, and inside that a <p> and <span>. In CSS, use .temple p { color: gold; } and .temple > .room { background: #2C1810; padding: 20px; } and .room > p { font-size: 18px; font-weight: bold; }. Observe how descendant selectors control styles.