Elysia Tools

Browse tools, examples, visual explainers, and topic guides from one clear workspace.

Top Categories

Hubs

Language
ZHDERUPTENFRES

Elysia Tools

Navigation

Developer Tools

CSS Selector Examples: Classes, Combinations and Media Queries

Copy selector samples and test them with your own HTML.

Samples

Entries inside this sample collection

TextcssSimple

Basic Class Selectors

Simple CSS class selectors including single, multiple, and chained classes

Difficulty

1/10

Estimated time

5 min

Tags

css, classes, basic, selectors

css
/* Basic CSS with class selectors */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  background-color: #333;
  color: white;
  padding: 15px;
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.button-primary {
  background-color: #007bff;
  color: white;
}

.button-secondary {
  background-color: #6c757d;
  color: white;
}

.card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 10px;
}

.card-body {
  color: #666;
  line-height: 1.6;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: -10px;
}

.col {
  flex: 1;
  padding: 10px;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
lineCount
80
fileSize
1.2 KB
category
css-selectors
useCase
Basic class selector extraction
TextcssSimple

ID Selectors

CSS ID selectors including single and combined with classes

Difficulty

1/10

Estimated time

5 min

Tags

css, ids, selectors, identifiers

css
/* CSS with ID selectors */
#main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

#header {
  background: #333;
  padding: 20px;
}

#logo {
  font-size: 24px;
  font-weight: bold;
  color: white;
  text-decoration: none;
}

#navigation {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

#navigation li {
  margin-right: 20px;
}

#navigation a {
  color: white;
  text-decoration: none;
}

#content {
  padding: 40px 20px;
}

#sidebar {
  width: 300px;
  float: left;
}

#main-content {
  margin-left: 320px;
}

#footer {
  background: #333;
  color: white;
  padding: 20px;
  text-align: center;
  clear: both;
}

#search-box {
  width: 300px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}

#submit-button {
  background: #007bff;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#hero-section {
  background-image: url('hero.jpg');
  background-size: cover;
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#hero-title {
  font-size: 48px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#contact-form {
  max-width: 500px;
  margin: 0 auto;
}

#map-container {
  width: 100%;
  height: 400px;
  background: #f0f0f0;
}
lineCount
97
fileSize
1.5 KB
category
css-selectors
useCase
ID selector extraction
TextcssIntermediate

Combined Selectors

Complex CSS selectors combining classes, IDs, elements, and pseudo-classes

Difficulty

3/10

Estimated time

10 min

Tags

css, combined, pseudo-classes, attributes

css
/* Combined selectors - classes, IDs, elements, and pseudo-classes */
.container #header {
  background: #333;
  padding: 20px;
}

.nav-bar .menu-item {
  display: inline-block;
  margin-right: 20px;
}

.nav-bar .menu-item:hover {
  color: #007bff;
}

.nav-bar .menu-item.active {
  font-weight: bold;
  color: #007bff;
}

.button-primary:hover {
  background-color: #0056b3;
}

.button-primary:active {
  transform: translateY(2px);
}

.card .card-title {
  font-size: 24px;
  font-weight: bold;
}

.card .card-body p {
  line-height: 1.6;
  color: #666;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
}

.form-group input[type="email"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
}

.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  min-height: 100px;
}

.dropdown-menu {
  display: none;
  position: absolute;
  background: white;
  border: 1px solid #ddd;
  min-width: 200px;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.table-striped tr:nth-child(odd) {
  background-color: #f9f9f9;
}

.table-striped tr:nth-child(even) {
  background-color: #fff;
}

.alert-success {
  background-color: #d4edda;
  color: #155724;
  padding: 15px;
  border-radius: 5px;
}

.alert-error {
  background-color: #f8d7da;
  color: #721c24;
  padding: 15px;
  border-radius: 5px;
}

.pagination .page-item:first-child .page-link {
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

.pagination .page-item:last-child .page-link {
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
}

.input-group .input-group-addon {
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  padding: 10px;
}

.modal .modal-header {
  padding: 15px;
  border-bottom: 1px solid #dee2e6;
}

.modal .modal-body {
  padding: 15px;
}

.modal .modal-footer {
  padding: 15px;
  border-top: 1px solid #dee2e6;
}
lineCount
120
fileSize
2.8 KB
category
css-selectors
useCase
Combined selector analysis
TextcssIntermediate

Media Query Selectors

CSS selectors within @media queries for responsive design

Difficulty

4/10

Estimated time

12 min

Tags

css, media queries, responsive, breakpoints

css
/* CSS with media queries */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

@media (max-width: 1200px) {
  .container {
    max-width: 960px;
  }

  .col-md-6 {
    width: 50%;
    float: left;
  }
}

@media (max-width: 992px) {
  .container {
    max-width: 720px;
  }

  .col-sm-12 {
    width: 100%;
  }

  .header {
    padding: 10px;
  }
}

@media (max-width: 768px) {
  .container {
    max-width: 540px;
    padding: 15px;
  }

  .nav-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-bar .menu-item {
    margin-right: 0;
    margin-bottom: 10px;
  }

  .sidebar {
    width: 100%;
    float: none;
  }

  .main-content {
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .container {
    max-width: 100%;
    padding: 10px;
  }

  .button {
    width: 100%;
    margin-bottom: 10px;
  }

  .card {
    padding: 15px;
  }

  .card-title {
    font-size: 20px;
  }
}

@media print {
  .container {
    max-width: 100%;
  }

  .no-print {
    display: none;
  }

  .print-only {
    display: block;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }
}

@media (min-width: 992px) and (max-width: 1200px) {
  .col-lg-4 {
    width: 33.333%;
    float: left;
  }
}

@media (orientation: landscape) {
  .banner {
    height: 300px;
  }
}

@media (orientation: portrait) {
  .banner {
    height: 200px;
  }
}
lineCount
115
fileSize
2.9 KB
category
css-selectors
useCase
Media query selector extraction
TextcssIntermediate

Keyframe Animation Selectors

CSS selectors and keyframes for animations

Difficulty

4/10

Estimated time

10 min

Tags

css, keyframes, animations, transforms

css
/* CSS with keyframes and animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-20px);
  }
  60% {
    transform: translateY(-10px);
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

.animate-fadeIn {
  animation: fadeIn 1s ease-in;
}

.animate-slideIn {
  animation: slideIn 0.5s ease-out;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-rotate {
  animation: rotate 2s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-shake:hover {
  animation: shake 0.5s;
}

@-webkit-keyframes slideUp {
  from {
    -webkit-transform: translateY(100%);
  }
  to {
    -webkit-transform: translateY(0);
  }
}

@-moz-keyframes flash {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0;
  }
}
lineCount
105
fileSize
2.1 KB
category
css-selectors
useCase
Keyframe and animation selector extraction
TextcssComplex

Nested SCSS-like Selectors

CSS with nested selectors similar to SCSS/LESS preprocessing

Difficulty

5/10

Estimated time

15 min

Tags

css, nested, scss, less, preprocessors

css
/* SCSS-like nested selectors */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.container .header {
  background: #333;
  padding: 20px;
}

.container .header .logo {
  font-size: 24px;
  color: white;
}

.container .header .nav {
  display: flex;
  justify-content: space-between;
}

.container .header .nav .menu-item {
  margin-right: 20px;
}

.container .header .nav .menu-item:hover {
  color: #007bff;
}

.container .content {
  padding: 40px 20px;
}

.container .content .sidebar {
  width: 300px;
  float: left;
}

.container .content .sidebar .widget {
  background: #f5f5f5;
  padding: 20px;
  margin-bottom: 20px;
}

.container .content .sidebar .widget .widget-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}

.container .content .main {
  margin-left: 320px;
}

.container .content .main .article {
  margin-bottom: 30px;
}

.container .content .main .article .article-title {
  font-size: 32px;
  margin-bottom: 15px;
}

.container .content .main .article .article-meta {
  color: #999;
  font-size: 14px;
  margin-bottom: 15px;
}

.container .content .main .article .article-content {
  line-height: 1.8;
  color: #333;
}

.container .content .main .article .article-content p {
  margin-bottom: 15px;
}

.container .footer {
  background: #333;
  color: white;
  padding: 20px;
  text-align: center;
}

.dropdown {
  position: relative;
}

.dropdown .dropdown-toggle {
  background: #007bff;
  color: white;
  padding: 10px 20px;
  border: none;
  cursor: pointer;
}

.dropdown .dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #ddd;
  min-width: 200px;
  z-index: 1000;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown .dropdown-menu .dropdown-item {
  padding: 10px 20px;
  display: block;
  color: #333;
  text-decoration: none;
}

.dropdown .dropdown-menu .dropdown-item:hover {
  background: #f5f5f5;
}
lineCount
124
fileSize
3.2 KB
category
css-selectors
useCase
Nested selector extraction and analysis
TextcssIntermediate

Pseudo-classes and Pseudo-elements

CSS selectors with various pseudo-classes and pseudo-elements

Difficulty

4/10

Estimated time

12 min

Tags

css, pseudo-classes, pseudo-elements, advanced

css
/* CSS with pseudo-classes and pseudo-elements */
a:hover {
  color: #007bff;
  text-decoration: underline;
}

a:visited {
  color: #6c757d;
}

a:active {
  color: #0056b3;
}

a:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input:checked + label {
  font-weight: bold;
}

input:required {
  border-color: #dc3545;
}

input:valid {
  border-color: #28a745;
}

input:invalid {
  border-color: #dc3545;
}

:first-child {
  font-weight: bold;
}

:last-child {
  margin-bottom: 0;
}

:nth-child(odd) {
  background-color: #f9f9f9;
}

:nth-child(even) {
  background-color: #fff;
}

:nth-child(3n) {
  border-left: 2px solid #007bff;
}

:first-of-type {
  text-transform: uppercase;
}

:last-of-type {
  margin-right: 0;
}

:not(.exclude) {
  padding: 10px;
}

:lang(en) {
  font-family: Arial, sans-serif;
}

::before {
  content: "\2192";
  margin-right: 5px;
}

::after {
  content: "\2190";
  margin-left: 5px;
}

::first-letter {
  font-size: 24px;
  font-weight: bold;
  color: #007bff;
}

::first-line {
  font-weight: bold;
  color: #333;
}

::selection {
  background: #007bff;
  color: white;
}

::placeholder {
  color: #999;
  font-style: italic;
}

li:first-child::before {
  content: "First: ";
}

li:last-child::after {
  content: " (Last)";
}

p:not(.exclude)::first-line {
  font-weight: bold;
}

a.external::after {
  content: "\2197";
}
lineCount
127
fileSize
2.7 KB
category
css-selectors
useCase
Pseudo-class and pseudo-element extraction
TextcssIntermediate

Attribute Selectors

CSS selectors using various attribute matching patterns

Difficulty

4/10

Estimated time

12 min

Tags

css, attributes, selectors, advanced

css
/* CSS with attribute selectors */
input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
}

input[type="email"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
}

input[type="password"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
}

input[type="submit"] {
  background: #007bff;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

a[href^="https://"] {
  color: #28a745;
}

a[href^="http://"] {
  color: #dc3545;
}

a[href^="#"] {
  color: #007bff;
}

a[href$=".pdf"]::after {
  content: " (PDF)";
}

a[href$=".doc"]::after {
  content: " (DOC)";
}

a[href$=".xls"]::after {
  content: " (XLS)";
}

img[alt] {
  border: 2px solid #28a745;
}

img[alt=""] {
  border: 2px solid #dc3545;
}

[class*="col-"] {
  float: left;
  padding: 10px;
}

[data-toggle="dropdown"] {
  cursor: pointer;
}

[data-dismiss="modal"] {
  background: #dc3545;
  color: white;
  border: none;
  padding: 5px 10px;
  cursor: pointer;
}

[data-target^="#collapse"] {
  cursor: pointer;
}

[data-spy="scroll"] {
  position: relative;
}

[aria-hidden="true"] {
  display: none;
}

[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}

[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

[readonly] {
  background-color: #f5f5f5;
  cursor: not-allowed;
}

[required] {
  border-color: #dc3545;
}

[multiple] {
  height: 100px;
}

[name="email"] {
  width: 100%;
}

[name~="first-name"] {
  width: 48%;
}

[name|="en"] {
  font-family: Arial, sans-serif;
}

input[class~="form-control"] {
  border: 1px solid #ced4da;
}

a[rel~="nofollow"] {
  color: #999;
}

div[id^="section-"] {
  padding: 20px;
  margin-bottom: 20px;
}

div[id$="-container"] {
  background: #f5f5f5;
  padding: 20px;
}

[data-info*="user"] {
  font-weight: bold;
}
lineCount
144
fileSize
3.1 KB
category
css-selectors
useCase
Attribute selector extraction

Tools

Tools frequently paired with this sample

Related

Related sample collections

Related

Related workflows

Tool usage guide

Sample-focused context for search and workflow understanding

Overview

Selectors determine which elements a rule can affect. These examples include classes, combinations, media queries and attributes. Use your own HTML and browser developer tools to check matching and when each rule applies.

Choose a sample

“Basic Class Selectors” is useful for individual classes; “Combined Selectors” demonstrates descendants and :hover; “Media Query Selectors” changes rules by viewport; “Attribute Selectors” matches attribute values. The page presents text; you must supply your own HTML to run a visual test.

The sample titled “Nested SCSS-like Selectors” actually contains expanded descendant selectors. Do not assume that its text requires a preprocessor to compile nested syntax.

Choose a sample
Sample cardUse
Basic Class SelectorsClass rule and box sizing
Combined SelectorsDescendant and hover
Media Query SelectorsViewport condition

Matching and the cascade

A space represents a descendant relationship; multiple classes on one element are written together. :hover denotes an interaction state. Rules inside @media participate only when its condition holds. Specificity and later rules also affect the final style.

How it works

  1. 1Copy CSS from the relevant card.
  2. 2Create matching elements and classes in local test HTML.
  3. 3Change state or viewport and inspect matching and computed styles in browser developer tools.

Edge cases & common failures

  • Standalone text

    The samples do not supply a running test page; use your own HTML and browser to check appearance.

  • Rendering differences

    Final style depends on the complete stylesheet, selector support and cascade, not only one rule.

Examples

1. Select a basic class

How to use

Copy “Basic Class Selectors”, create an element with class="container" and inspect the .container rule.

Outcome

The rule sets max-width:1200px, margin:0 auto and padding:20px. Matching a class does not guarantee that every declaration wins the cascade.

2. Distinguish descendants and state

How to use

Copy “Combined Selectors”, place .menu-item inside .nav-bar and hover over it.

Outcome

.nav-bar .menu-item selects a descendant; the :hover rule can set #007bff. The final color still depends on the cascade.

3. Test a viewport condition

How to use

Copy “Media Query Selectors”, create a .container element and compare viewports of 1100 px and 1300 px.

Outcome

At 1100 px, max-width:1200px matches and the inner rule sets max-width to 960px. At 1300 px that query does not match and the base maximum is 1200px.

Hub

CSS Authoring, Layout, and Cascade Workflows

Write and review CSS with readable formatting, selector diagnostics, responsive snippets, visual effects, and rendered-intent checks.

Hub

Infer JSON Schema from Samples and Spreadsheets

Derive a reviewable JSON Schema draft from representative JSON samples or XLSX rows, then inspect types, requiredness, nulls, and outliers before treating it as a contract.

Hub

Color System and CSS Effect Design Workflow

Extract a palette, build accessible color relationships, generate tokens, and apply CSS effects that stay consistent in real interface states.

Hub

Singing and Music Practice Tools

Shift songs into a comfortable key, find vocal range, generate tuning references, extract melody and chords, build tempo drills, add swing, and practice pronunciation with repeatable browser audio tools.

Home
Tools3212
Workbench
Samples593
Visualizations471
Viewers103
Hubs239
Tags333
Images, Audio & Video657

Image, audio, and video processing, conversion, and optimization tools

Math, Date & Finance647

Calculators, numerics, date logic, statistics, and finance tools

Design & Color298

Color, layout, graphics, visual styling, and design helper tools

Text & Writing209

Writing, cleanup, formatting, extraction, and text analysis tools

Developer & Web193

Developer utilities, networking, web debugging, and automation helpers

Conversion & Encoding175

Format, file, archive, unit, and encoding conversion tools

Lead Generation Quiz Launch and Contact Handoff
Memorial Drafts: Family Review and Print Handoff
Private Habit Records: Backup, Restore and Sharing Review
Article to X and LinkedIn Drafts: Fact Review and Handoff
Markdown Interactive Deck Review and Offline Handoff

© 2026 Elysia Tools. All rights reserved.

DocsPricingAboutTerms of ServicePrivacy PolicyCookiesContact

Development

CSS Selector Extractor

Extract and categorize all CSS selectors from CSS content

Development

CSS Selector Specificity Calculator

Calculate CSS selector specificity scores, compare multiple selectors, and get suggestions for avoiding cascade conflicts

Development

CSS Beautifier

Format and beautify minified or messy CSS code into readable, well-indented stylesheets

Design

CSS Fluid Typography Clamp Calculator

Generate a clamp() expression from min and max viewport and font-size bounds, with copy-ready CSS and preview data

Design

CSS Text Shadow Generator

Generate CSS text-shadow properties

Data Processing

CSV Column Selector

Select specific columns from CSV data by column names or indices. Perfect for extracting relevant data from large CSV files with many columns.

Document Tools

HTML/CSS to Print-Ready PDF

Typeset a multi-page, print-ready PDF straight from HTML and CSS: @page size/margins, running chapter headers, page counters, crop and registration marks, bleed.

Design

Variable Font Axis Instance and CSS Font Variation Settings Builder

Upload a variable font (TTF/OTF/WOFF/WOFF2) to inspect its fvar axes and named instances, preview interpolation live in the browser, and generate ready-to-paste font-variation-settings CSS plus the equivalent high-level properties and a variable @font-face block.

Blockchain

Hardhat Development Framework Samples

Hardhat Ethereum development environment examples including smart contracts, testing, deployment, scripts, plugins, and development workflows

Blockchain

Truffle Development Suite Samples

Truffle Ethereum development framework examples including smart contracts, testing, deployment, migrations, debugging, and development workflows

Testing

Jest Testing Framework

Comprehensive Jest testing examples including unit tests, integration tests, mocking, async testing, and advanced patterns for JavaScript/TypeScript applications

Media

Copyright-Free MP3 Audio Samples

Collection of royalty-free audio samples for testing and development purposes including nature sounds, meditation music, and ambient audio

Document

PDF Samples

Generated PDF samples from tools dated 2026-02-01 to 2026-02-10

Media

SVG Samples

Scalable Vector Graphics (SVG) samples demonstrating various SVG features and techniques