::target-text
Baseline 2024Newly available
Since December 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Das ::target-text
CSS-Pseudo-Element repräsentiert den Text, zu dem gescrollt wurde, wenn der Browser Textfragmente unterstützt. Es erlaubt Autoren, festzulegen, wie dieser Abschnitt des Textes hervorgehoben werden soll.
css
::target-text {
background-color: pink;
}
Syntax
css
::target-text {
/* ... */
}
Beispiele
Hervorheben von Textfragmenten
css
::target-text {
background-color: rebeccapurple;
color: white;
}
Um dieses CSS in Aktion zu sehen, folgen Sie dem Link zur Scroll-to-Text-Demo.
Spezifikationen
Specification |
---|
CSS Pseudo-Elements Module Level 4 # selectordef-target-text |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
::target-text |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.