5. CSS Combinators, Pseudo-Classes & Dropdowns

Combinators, :hover, :nth-child(), ::before, ::after & animated hover dropdowns

Module 1: CSS Combinators & Pseudo-Classes

Combinators explain relationships between selectors.

Core Theory & Principles

  • Descendant selector (div p): selects all

    inside

    .
  • Child selector (div > p): selects direct children

    inside

    .
  • Pseudo-classes: :hover, :active, :focus, :first-child, :nth-child(even).

Practical Key Takeaways

Mastering CSS Combinators & Pseudo-Classes builds fundamental development capability. Review practical code and outputs carefully.

💻 Practical Code Example - CSS Combinators & Pseudo-Classes
<!DOCTYPE html>
<html>
<head>
<style>
  .hover-btn {
    background: rgb(56, 189, 248);
    color: rgb(15, 23, 42);
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  .hover-btn:hover {
    background: rgb(74, 222, 128);
    transform: translateY(-2px);
  }
</style>
</head>
<body>
  <button class="hover-btn">Hover Over Me!</button>
</body>
</html>
📤 Expected Output / Browser Rendered Result:
Output Verified Cleanly.