Links, Pseudo-classes & Responsive Design
Interactive states and media/container queries for responsive layouts.
Link & Interaction Pseudo-class Selectors
| Pseudo-class | Matches |
|---|---|
a:link | Unvisited link — default state |
a:visited | Link the user has already clicked |
a:hover | Mouse is over the link |
a:active | Link is being clicked right now |
button:focus-visible | 2025: keyboard focus only (not mouse click) |
input:invalid | Form field fails validation |
:user-invalid | 2025: shows only after user interaction |
a { font-weight: bold; }
a:link { color: #0084D8; }
a:visited { color: #90E0EF; }
a:hover { color: #FF8703; text-decoration: none; }
a:active { color: #FB8500; }
button:focus-visible { outline: 3px solid #0084D8; }
Responsive Design & Media Queries (2025)
Media queries apply styles only under specific conditions.
@media (min-width: 768px)— mobile-first approach.- Common breakpoints: 640px, 768px, 1024px, 1280px.
- Also query
prefers-color-schemeandprefers-reduced-motion.
/* Mobile-first default */
.grid { display: block; }
/* Tablet+ */
@media (min-width: 768px) {
.grid { display: grid; grid-template-columns: 1fr 1fr; }
}
/* Desktop */
@media (min-width: 1024px) {
.grid { grid-template-columns: repeat(3, 1fr); }
}
/* Accessibility — reduce motion */
@media (prefers-reduced-motion: reduce) {
* { animation: none !important; }
}
Container Queries (2025)
Container queries respond to the parent container's width rather than the viewport — components become truly reusable.
.card-wrapper { container-type: inline-size; }
@container (min-width: 400px) {
.card { display: flex; flex-direction: row; }
}
Activity — complete the code
Complete the code correctly to mark this lesson as complete automatically.
Complete the pseudo-class and the media queries.
a: { color: red; }@media (min-width: ) {.grid { display: grid; }}@media (prefers-reduced-motion: ) {* { animation: none; }}