'content' attribute to inherit node value

若如初见. 提交于 2019-11-28 01:50:47

No, there's no way to do that. That's not what inherit is for.

The closest you can get is this:

<h2 data-title="Random title">Random title</h2>

h2:after {
    content: attr(data-title);
}

..which is obviously horrible because of the duplication.

CSS3 has a way, content: contents; but (a) it seems to be contrived in such a way as to not be useful; and (b) probably isn't implemented anywhere yet. See http://dev.w3.org/csswg/css3-content/#contents0

@thirtydot's answer is correct for now, at least.

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