Morten Hjort
Morten Hjort

Reputation: 1012

CSS3 Selectors - style hashtag-words

I've searched a lot, but still cant find a way to use CSS3 Selectors to style all words starting with a #... Like #diy. Shouldnt that be possible using css-only?

Upvotes: 2

Views: 2472

Answers (2)

Kobi
Kobi

Reputation: 138017

No, but it can quite easily be done with JavaScript.

Using Extend jQuery.highlight to highlight regular expressions:

$('body').highlight(/\B#\w+/)

Working example: http://jsfiddle.net/kobi/ttd9r/

Upvotes: 0

BoltClock
BoltClock

Reputation: 723648

Selectors aren't designed for selecting text content directly in part or in full, so no, it shouldn't.

Selectors are designed for matching elements. If you want to style hashtags differently, you should be wrapping them in their own elements and then styling those elements.

Upvotes: 3

Related Questions