There isn't a built-in CSS solution for this specific task, but you can experiment with iterating through each text node in JavaScript and checking for alphabetic characters without case sensitivity (match(/^[a-z]+$/i)
). Keep in mind that this method won't guarantee the language is specifically English.
If the condition is met, you can assign a custom class to the parent element, such as appears-english
, and then style it using CSS properties like
.appears-english { font-size: 120% }
.
Update
Upon request, below is a sample code snippet...
JavaScript
var divs = document.getElementsByTagName('div');
for (var i = 0, divsLength = divs.length; i < divsLength; i++) {
var div = divs[i];
if (div.firstChild.nodeValue.match(/^[a-z]+$/)) {
div.className += 'appears-english';
}
}
CSS
.appears-english {
font-size: 170%;
}
jsFiddle.
The provided fiddle demonstrates that numbers are not matched - you can modify the regex to include numbers, letters, and underscore by changing [a-z]
in the regex to \w
.
Additionally, if you need to update English characters within an element that also contains Arabic characters, consider using replace()
and wrapping them in span
elements assigned with the appears-english
class.