Search code examples
htmlcsscss-selectorslang

CSS Selector for xml:lang


I want to use different CSS selectors for every language. I've got an HTML document like:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
     ...
</html>

I have got different languages, and I want to change the style depending on the language.

I've tried html:lang(es) but it doesn't work.


Solution

  • I recommend updating the language attribute in the html aswell. You could select this element using CSS aswell. xml is an attribute that you can select with CSS.

    html[xml:lang="es"]{ //your style }
    

    You could also use change the css with the lang attribute

    html[lang="es"]{ //your style } 
    

    html[xml\:lang="es"] body{ background: red; } 
    html[xml\:lang="en"] body{ background: green; } 
    <html xml:lang="es" lang="es">
    <head>
    </head>
    <body>
    </body>