More styling
Part of the CSS Mastery section of Coddy's HTML journey — lesson 19 of 43.
Challenge
EasyLet’s target specific paragraphs and menu items and apply different styles to each using structural and sibling selectors.
- Style the first paragraph (first child) inside the
.info-section. Change its font size (20px) and weight to make it stand out. - Style all the paragraphs that come after (general sibling) the one with the
.introclass. Add a padding to make them easier to read. - Style every odd menu item (nth-child) in the top navigation. Give them a different color to create a striped effect.
Try it yourself
<html>
<head>
<title>Dropdown Menu</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<section class="menu-panel">
<h2>Hobby Club</h2>
<nav class="top-menu">
<ul class="menu-list">
<li class="menu-item">Photography</li>
<li class="menu-item">Cooking</li>
<li class="menu-item has-submenu">
Games
<ul class="submenu">
<li>Board Games</li>
<li>Card Games</li>
<li>Video Games</li>
</ul>
</li>
<li class="menu-item">Drawing</li>
<li class="menu-item">Music</li>
</ul>
</nav>
<div class="menu-controls">
<input type="text" class="search" placeholder="Search activities..." />
<button class="cta-button">Join a Club!</button>
</div>
<div class="info-section">
<p class="intro">Welcome to the Hobby Club community!</p>
<p>Joining a hobby club is a great way to meet people who share your interests.</p>
<p>You can learn new skills, have fun, and even discover talents you didn’t know you had!</p>
</div>
</section>
</body>
</html>
All lessons in CSS Mastery
1Selector Mastery – Combination
IntroductionDescendant SelectorChild SelectorAdjacent Sibling SelectorGeneral Sibling SelectorRecap Challenge