CSS for changing color of last word in h1

前端 未结 10 2477
遇见更好的自我
遇见更好的自我 2020-11-29 09:31

I have a website that I am developing using CSS3 and I have h1 tag for the title:

main title

Now I want t

10条回答
  •  不知归路
    2020-11-29 09:36

    CSS has no knowledge about words. The only thing existing is :first-letter and :first-line. A construct like a word and a pseudo element for last are not existing.

    If you really want to have a workaround within one element, then you must use javascript to parse the last word out. I think the way you are going is the best way when you only have a few cases on the page.

    If you use it for h1 then you should have it so or so only once on the page.

提交回复
热议问题