INF-250: Web Design and Development — Pseudo Classes and Display Settings

Pseudo Classes

In CSS, we've learned how to select an element by using the element's name, its class, or ID.

But what if we want to target an element only part of the time, or target an element only under certain conditions? That's where pseudo-classes come in.

:hover
:active
:visited
:first-child

a {
	color: blue;
}

a:hover {
	color: red;
}

.nav-link:visited {
	color: purple;
}

Try it in CodPen.

Display Settings

display: none vs visibility: hidden

These two are easy to mix up:

  • display: none removes the element from the layout. Other elements move to fill the space.
  • visibility: hidden makes the element invisible, but it still takes up space in the layout.

CodePen Challenge #1

Navbar Challenge

CodePen Challenge #2

Specificity Challenge

CodePen Challenge #3

HTML Debug Challenge

CodePen Challenge #4

CSS Debug Challenge

CodePen Challenge #5

Full Page Styling Challenge