The html code
<html dir="rtl">
<p>hello (world)</p>
</html>
you will see a page like this:
(hello (world
However,if I change the html code into
<html dir="rtl">
<p>hello (world) again</p>
</html>
Then the text displays normally:
hello (world) again
Anyone can explain why this happens? How to fix the first example?
My browser is chrome
Or better you can try in CSS
*:after {
content: "\200E";
}
You just need to add the LRM character after the last bracket. HTML entity: ‎
<html dir="rtl">
<body>
<p>hello (world)‎</p>
</body></html>
This tells the browser to interpret the brackets as left-to-right reading.
Adding the special rlm character in css before and after your element solved all cases I've come across in Firefox and Chrome:
*:after {
content: "\200E";
}
*:before {
content: "\200E";
}
Use ‏
before (
.
Ex:
<html dir="rtl">
<body>
<p>hello ‏(world)</p>
</body></html>
if you are using javascript/svg Dom then
aText = $('<span>').html(aText.replace("(","‏(")).text();
$("<p>").html(aText);
for other special Charactors
function getRTLText(aText,aChar) {
if ( aText != undefined && aText.replace){
aChar = (aChar === undefined )?"(":aChar;
aText = $('<span>').html(aText.replace(aChar,"‏"+aChar)).text();
}
return aText;
}
and call function
getRTLText("March / 2018","/");
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