If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

CSS: The class selector

The class selector is a way to select all of the elements with the specified class name, and apply styles to each of the matching elements. The selector must start with a period (.) and then the class name. The browser will look for all tags in the page that have a class attribute containing that class name.
The spelling and casing must be exactly the same - ".cold-city" is different from ".Cold-City". The class name can't contain a space, but it can contain hyphens or underscores. Any tag can have multiple space-separated class names.

Want to join the conversation?

No posts yet.