CSS Selectors

A CSS selector is what allows you to focus on some specific HTML elements to which you want to apply certain CSS rules. There are many different types of selectors but can usually get by with the most basic.

Basic CSS Selectors

CSS Selecting by Element

Element selectors are the easiest. There’s nothing fancy, just the name of the element. Every single element that matches will get the rules. You can have more than one by just adding a comma.

html, body {
  height: 100%;
  margin: 0;
  background: #000000;

This example applies all the rules to both html and body.

CSS Selecting by Id

#myform {
  width: 100%

So a form might look like this.

<form id=myform>
  <input name=name>
  <input type=submit>

CSS Selecting by Class Name

.spy {
  font-family: "SpyAgency";

Then the HTML would look something like this.

<p>Here at <span class=spy>SkilStak</span></p>