1

When I first use CSS, I thought it is impossible to get the properties of an element. However, I found this code Here, it shows that I can get the properties of elements by using CSS.
For example, if I want to get the title of <abbr> element, I can just use this code:

abbr::before{
  content:attr(title);
  color:red
}
<abbr title="the title">
  Content Test
</abbr>

attr(title) give me the title of <abbr>

In that case, I want to ask if there is a way to get the content of the element.
For example, I want to get Content Test in the code in my example by just using CSS.
How could I finish that?

Han Han
  • 328
  • 12
  • Does this answer your question? [CSS only get text](https://stackoverflow.com/questions/20335753/css-only-get-text) – toffler Feb 15 '23 at 05:41
  • @toffler I do not think so, I found another [Link](https://stackoverflow.com/questions/1520429/is-there-a-css-selector-for-elements-containing-certain-text) in that question, and I tried to use *content:text(.class1);* and *content:text(#id1);*, but they both not working. Thank you for your comment. – Han Han Feb 15 '23 at 05:48
  • 2
    What you're looking for isn't possible with CSS. – EmSixTeen Feb 15 '23 at 07:32

1 Answers1

0

I didn't fully understand the question. Why get the content of ? change style or change the content? You can define content through CSS rather than through HTML. Maybe this will help you:

abbr::after{
  content: 'Content Test';
  color:red
}
<abbr title="the title">
  
</abbr>
ff99cc
  • 61
  • 8