Style specific letters in a word [duplicate]

China☆狼群 提交于 2019-12-10 16:06:45

问题


My current HTML:

<a href="#" id="word">T<span style="font-size: 28px;">est</span><span style="color: pink;">W<span style="font-size: 28px;">ord</span></span></a>

This is terrible for SEO. Ideally, I'd like all styling done to the anchor tag:

<a href="#" id="word">TestWord</a>

I understand there is a :first-letter selector, but how can I modify an nth letter and get my expeced output?

jsFiddle: http://jsfiddle.net/HUGKv/1/


回答1:


Currently there is no way to target n-th letter through CSS. There are some calls for CSS to allow n-th everything in the future, but as of today, no such luck.

Currently, you would probably have to use some JS approach to solve this.




回答2:


Tricky, yes, but happier SEO, also:

<h1>TestWord</h1>

h1 {
    color: pink;
}
h1:before {
    content: "Test";
    position: absolute;
    left: 8px;
    color: red;   
}

fiddle




回答3:


Add a span element with the CSS you require for individual letters.

<a href="#" id="word">Test<span class="classname">W</span>ord</a>


来源:https://stackoverflow.com/questions/15511142/style-specific-letters-in-a-word

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!