Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 1.3 — Attribute Selectors
CSS · Example 1 of 3

Links styled by where they go

The ::after part adds text after each PDF link; you'll learn pseudo-elements in Topic 1.6. Remove the i and the upper-case report loses its bold and label.

Attribute selectors match elements by their attributes: whether an attribute exists, equals a value, or starts with, ends with or contains some text, optionally ignoring upper and lower case.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Give every external link (starting with http) a small arrow after it, and every mailto: link an italic style.

02

Style every input that has a placeholder with a grey border, and every input with type="password" with letter spacing of 2px.

Explain it without notes

01

List the attribute selector operators and what each one matches.

02

What is the difference between [class~="note"], [class*="note"] and [class="note"]?

03

Why is it a good idea to style [aria-expanded="true"] instead of an .is-open class?

04

How do you match a link to a PDF whatever the case of the file extension?

Links styled by where they go

Preview

Press Run to see the page.

Console

Nothing logged yet.