It’s specifically for text-spacing
styling. I want to set the element to auto height/width of the letter-spacing/word-spacing has some specific value.
HTML
<span class="subjectText">this is the text</span>
universal selector
*{
letter-spacing:1.641px;
}
desired styling
*[style*="letter-spacing:1.614px"] .subjectText{
background-color:yellow;
}
I tried below,but its not working
*[style*="letter-spacing:1.614px"] .subjectText{
background-color:yellow;
}
2
Answers
The CSS selector will select any element with a style attribute containing the value "letter-spacing:1.614px" and any descendant with the class .subjectText. However, it won’t work in your case because the style attribute is not defined on the span element itself, but rather on the universal selector.
you can define a separate class for the letter-spacing and apply it to the parent element of the text:
UPDATED
The short answer: Currently there is now way to test individual properties of defined CSS rules and use their value to define further CSS rules. Regardless whether they are defined with a universal or a specific selector, the CSS attribute selector mechanism simply does not incorporate testing for properties.
A simple test shows that it will work for inline style attributes, but you need to add
!important
to the properties you want to override as inline style attributes (<tag style=".." />
) have precedence over in document styles (<head><style>...</style></head>
).In the current construction the ‘*’-universal selector is even [OPTIONAL] as the
[attribute]
selector rule is common enough.BE AWARE, though, that the CSS attribute rule
[style*="..."]
must exactly match the tagsstyle="..."
assignment. It will fail when not an exact match.