Lab 01: Advanced Selectors
Overview
Step 1: Attribute Selectors
/* [attr] — has attribute */
input[required] { border-color: red; }
/* [attr=val] — exact match */
input[type="email"] { background: url(email-icon.svg) no-repeat right; }
/* [attr^=val] — starts with */
a[href^="https"] { color: green; } /* secure links */
a[href^="mailto"] { color: blue; } /* email links */
/* [attr$=val] — ends with */
a[href$=".pdf"]::after { content: " (PDF)"; }
a[href$=".zip"]::after { content: " (ZIP)"; }
/* [attr*=val] — contains */
[class*="icon-"] { display: inline-block; width: 1em; height: 1em; }
/* [attr~=val] — word in space-separated list */
[data-tags~="featured"] { border: 2px solid gold; }
/* [attr|=val] — exact or prefix with hyphen (language codes) */
[lang|="en"] { font-family: "Georgia", serif; }
/* Case-insensitive flag */
input[type="TEXT" i] { outline: 2px solid blue; }Step 2: Structural Pseudo-Classes
Step 3: Specificity Calculation
Step 4: Cascade Layers (@layer)
@layer)Step 5: Logical Properties for Internationalization
Step 6: Combining Selectors Effectively
Step 7: Pseudo-Elements & Focus Management
Step 8: Capstone — Verified Specificity Calculator
Summary
Concept
Syntax
Specificity
Last updated
