Is it possible to style this? |
Is it possible to style this? |
Terminator |
May 8 2015, 04:53 PM
Post
#1
|
Advanced Member Group: Members Posts: 218 Joined: 19-March 15 Member No.: 22,398 |
For an unordered list, is it possible to add a CSS style to change the color of the entire first word including the colon? But keep the whole word that is after the colon the default font color?
example: <ul class="list1"> <li>Question: Answer</li> <li>Question: Answer</li> <li>Question: Answer</li> </ul> Basically I would want "Question:" to be an orange color, the entire word including the colon : Then "Answer" would stay as the default font color I know about :first-of-type and ::first-line, etc, but this is usually going to be on one line. I was trying to avoid doing it this way: <ul class="list1"> <li><mark class="orange">Question:</mark> Answer</li> <li><mark class="orange">Question:</mark> Answer</li> <li><mark class="orange">Question:</mark> Answer</li> </ul> thanks This post has been edited by Terminator: May 8 2015, 05:02 PM |
Christian J |
May 8 2015, 05:52 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
For an unordered list, is it possible to add a CSS style to change the color of the entire first word including the colon? But keep the whole word that is after the colon the default font color? Not that I know of. QUOTE I was trying to avoid doing it this way: You could use a definition list instead, that way the markup becomes a little more semantically meaningful as well. See http://www.w3.org/TR/html5/grouping-conten...#the-dl-element |
pandy |
May 8 2015, 06:22 PM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
There are JavaScript solutions to work around the lack of a :first-word pseudo element. Here's one, but it's oldish. There's problably newer ones around. Not saying this script is bad, I just don't know how it fares in newer browsers.
http://www.dynamicsitesolutions.com/javasc...-word-selector/ |
Lo-Fi Version | Time is now: 24th April 2024 - 10:51 PM |