Element Selectors
h1 { color: blue; }
p { margin: 10px; }Class Selectors
.classname { color: red; }
.btn { padding: 10px; }ID Selectors
#id { background: yellow; }Attribute Selectors
[type="text"] { border: 1px solid; }
[href^="https"] { color: green; }
[class*="btn"] { cursor: pointer; }Pseudo-classes
a:hover { color: red; }
li:first-child { font-weight: bold; }
input:focus { outline: 2px solid blue; }
p:nth-child(2) { margin-top: 20px; }Combinators
div p { color: blue; }
div > p { color: green; }
h1 + p { margin-top: 0; }
h1 ~ p { color: gray; }
Common mistakes / Pitfalls
- People often copy a command or pattern without adapting placeholders, which can break production workflows unexpectedly.
- It is easy to forget environment-specific differences, so always verify behavior in your shell, runtime, or API gateway before shipping.
- Many errors come from skipping small validation steps, so test with realistic sample input before relying on the result.
Last updated: February 2026