This page is a minimal, practical reference for common CSS / DOM selectors, with short HTML examples only. No advanced or edge‑case selectors are included.
Select elements by their HTML tag name.
main
article
body
<body>
<main>
<article>
<p>Article text</p>
</article>
</main>
</body>
Select elements by tag name and class name.
div.entry-content
<div class="entry-content">
Main content here
</div>
Select elements by class name only.
.entry-content
<section class="entry-content">
Same class, different tag
</section>
Select a single element by its unique id attribute.
#main-title
<div id="main-title">Page title</div>
Select elements by arbitrary attribute name and value.
span[itemprop="publicationDate"]
<span itemprop="publicationDate">2025-03-01</span>
Select elements inside other elements.
article h1
<article>
<h1>Article title</h1>
<p>Article text</p>
</article>