My goal: to check if the title attribute is not empty; if it is not, then the value of this attribute title plus a hyphen should be added. On the other hand, if the title attribute is empty, then "-" should not be added at all.
Here is my current CSS code:
div:hover::before{content:attr(title):not(attr(title)="") " - ";}
but it does not work properly.
For instance:
<div title="My username">some text</div>
The following should be displayed:
My username is text
But if:
<div title="">some text</div>
or (no name in the div):
<div>some text</div>
then the hover display should be:
some text
Can this be fixed?
source share