- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Good afternoon,
This is my first post and I am a beginner but I was wondering if it was possible using CSS and not Javascript to be able to add text or a character based upon a variable being brought onto the page.
I have an order number being brought through as the variable with a prefix or SI or SC for invoice or credit and wanted to add some specific text based upon this prefix using CSS.
Many thanks for your help
Basically….No.
CSS can style what is there but it can’t actually detect what the content of the element is.
If you were able to apply a class or data-type to the variable ‘element’ as it is injected into the page…that’s another matter.
How are you getting this ‘variable’ into the HTML?
Can you assign custom CSS to the order number when bringing it into the page? Such as wrapping it with a SPAN tag? If so, you could use the “:before” or “:after” CSS selectors to include some additional content before or after order number.
SI Order Number
SC Order Number
Then the CSS would be something like:
.style-si:before {
content:”aaa “;
}
.style-sc:before {
content:”bbb”;
}
How are you bringing the variable onto the page? Get/Post or direct user input?