Html 如何获取文档';CSS3的标题

Html 如何获取文档';CSS3的标题,html,css,Html,Css,我想使用CSS3选择器“内容”将一些文本添加到一些HTML中,例如文档的标题,我该怎么做?纯CSS无法实现它。内容属性值只能是以下值之一: content: normal /* Keywords that cannot be combined with other values */ content: none content: 'prefix' /* <stri

我想使用CSS3选择器“内容”将一些文本添加到一些HTML中,例如文档的标题,我该怎么做?

纯CSS无法实现它。内容属性值只能是以下值之一:

content: normal                                /* Keywords that cannot be combined with other values */ content: none
content: 'prefix'                              /* <string> value, non-latin characters must be encoded e.g. \00A0 for   */
content: url(http://www.example.com/test.html) /* <uri> value */
content: chapter_counter                       /* <counter> values */
content: attr(value string)                    /* attr() value linked to the HTML attribute value */ 
content: open-quote                            /* Language- and position-dependant keywords */ content: close-quote
content: no-open-quote content: no-close-quote
content: open-quote chapter_counter            /* Except for normal and none, several values can be used simultaneously */
content: inherit
有关更多详细信息,请参阅

使用
attr
只能获取当前元素的属性

但是您可以添加
数据
属性,如下所示:

<style>
.article-title:before{
    content:attr(data-mytag);font-size:0.5em;margin-right:1em}
</style>
<span data-mytag="Tips here" class="article-title">1</span>

.文章标题:之前{
内容:attr(数据mytag);字体大小:0.5em;右边距:1em}
1.

非常感谢,我将使用JS来解决我的问题,因为我想为不属于我的网站添加一些样式。如果你想为指向其他网站的链接添加额外样式,可以尝试
a[href^=“http:/”]:在{content:url('any-icon-you-like.png')之前