MDN self-hosted library · e01.org

CSS selector structure

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

css
#myId {
}

[pattern*="\d"] {
}
css
a#selected {
}

[type="checkbox"]:checked:focus {
}
css
a#selected > .icon {
}

.box h2 + p {
}
css
#main,
article.heading {
}
css
#main,
:bad-pseudoclass,
.validClass {
  /* `:bad-pseudoclass` is invalid, invalidating this style block */
}
css
:has(+ div#topic > #reference) {
}

:has(> .icon) {
}

dt:has(+ img) ~ dd {
}