I was taking a test in upwork. There I got the following question:
Consider the following code:
body{text-replace: "a" "b" "b" "c"}
What will be the output of the following string if the text replace style is implemented?
andy lives behind cafe
- ndy lives behind cbfe
- cndy lives cehind ccfe
- andy lives behind cafe
- andy lives cehind bafe
I couldn't find any reference for the text-replace property in css.
The text “Old Text” needs to be hidden first and a new text has to be positioned exactly where the old text was. To do so, we change the visibility of this text using CSS to hidden first. Then we add a new text at the exact same position, using the pseudo elements and corresponding explicit positioning.
To replace the text with a logo image, use a negative text indent value (it has to be a pretty high value, like the one below) and insert the image using background: url(). Make sure you define the width and height as well, or the image won't render.
By using text-indent: -999px; or a similar method, the text is still there — just not visually there. Use display:none , and the text is gone.
Wow! You've stumbled upon a property that was last in the 2007 GCPM specification and removed in the 2010 revision. And in an online test at that! Either the test you're taking is several years out of date, or whoever set it was just pulling from random old revisions of W3C specifications and treating them all as relevant (as users have been known to do here on Stack Overflow).
Because of how esoteric this is I'm going to just answer the question. Needless to say, this answer is provided for educational purposes only. There is no text-replace
property in any current CSS specification, and there hasn't been for almost a decade (neither in css-content nor css-gcpm). Don't put it in your CSS and expect it to work. It won't. If you need to do text replacements in an HTML document, use JavaScript.
The answer is #2: "cndy lives cehind ccfe"
The exact CSS sample appears in the spec, linked above, and the example is described as follows (emphasis mine):
The two rules below yield the same result. In the first rule all ‘a’ characters are converted to ‘b’. Subsequently, all ‘b’ characters are converted to ‘c’. In the second rule, all ‘a’ and ‘b’ characters are converted directly to ‘c’.
body { text-replace: "a" "b" "b" "c" } body { text-replace: "a" "c" "b" "c" }
So the processing order goes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With