[英]Select header-tag (e.g. <h2>) with specific text in CSS
I have a question that I can't figure out after researching for a while:我有一个问题,我研究了一段时间后无法弄清楚:
I have <h2>
-tags in my wordpress-blogs, and if they have a specific text (like <h2>Solution</h2>
) I would like to add a specific icon in front of them.我的 wordpress 博客中有
<h2>
标签,如果它们有特定的文本(如<h2>Solution</h2>
),我想在它们前面添加一个特定的图标。
But how do I select this, only using CSS?但是我该如何选择它,只使用 CSS? I read a lot of posts that say it is not possible - but then I found out about xpath, but I didn't see an example how this would be possible.
我读了很多帖子说这是不可能的——但后来我发现了 xpath,但我没有看到一个例子,这是如何可能的。
I would need a "hint" in the right direction.我需要一个正确方向的“提示”。 Thanks!
谢谢!
To locate the elements with XPath, you can go with:要使用 XPath 定位元素,您可以使用:
//h2[text()="Solution"]
Meaning: look everywhere on the page for a h2
element containing the text "Solution".含义:在页面上到处寻找包含文本“Solution”的
h2
元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.