Comments (1)
Developers can change the highlight color as outlined in the article:
Styling text fragments
By default, browsers style text fragments the same way they style mark (typically black on yellow, the CSS system colors for mark). The user-agent stylesheet contains CSS that looks like this:
:root[::target-text](https://drafts.csswg.org/css-pseudo/#selectordef-target-text) {
color: MarkText;
background: Mark;
}
As you can see, the browser exposes a pseudo selector ::target-text
that you can use to customize the applied highlighting. For example, you could design your text fragments to be black text on a red background. As always, be sure to check the color contrast so your override styling does not cause accessibility issues and make sure the highlighting actually visually stands out from the rest of the content.
:root::target-text {
color: black;
background-color: red;
}
from link-to-text-fragment.
Related Issues (20)
- Can I get the link to selection in code? HOT 1
- Idea - When no text selected, copy link with title of the page HOT 1
- Errors out on highlights beginning with whitespace HOT 1
- Doesn't work on documents of Content-Type text/plain HOT 3
- Firefox 107.0 on Fedora: link-to-text doesn't appear in context menu HOT 7
- Text fragment in Bootsrap Offcanvas doesn't jump to the point in mobile mode HOT 1
- Scroll to text fails for fragments that include hyphenated words HOT 2
- Issues.
- Dashes in selected text to create link from HOT 1
- Selection Error -- 'Couldn't create a unique link, please select a longer sequence of words' HOT 1
- Provide a method for generating a method from a range instead of a selection HOT 2
- Unable to link to text inside table HOT 2
- Incompatible encoding (`-`, `&`, `,`) HOT 1
- Provide progress indicator. HOT 6
- [feature-request] add to mobile/android HOT 4
- Doesn't work for Safari Version 16.6 (18615.3.12.11.2) HOT 1
- Do not remove pre-existent `#.*:` section of URI. HOT 3
- Copied Link to Selected Text Appearing as a Link Rather Than the Text HOT 1
- Text fragment link converts upper-case to lower-case in Firefox HOT 1
- Does not work on Firefox anymore HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from link-to-text-fragment.