4 ms·
Styling HTML elements based on locale
- matchu 13y agoNeat! If we didn't have this feature, we could still apply the style to lang=ca elements and reset it in lang!=ca elements, but this is more readable and avoids cases in which resetting is nasty.
- sergeylukin 13y agoWe could, but then we'd need to know specifically what to reset now, and maintain the resetting styles each time we introduce new language which sounds like something we'd want to avoid.
- PavlovsCat 13y ago> While there most likely isn’t much of need in styling elements based on their locale It might be useful for languages that go right to left, etc. since speakers of those languages also like their nav elements (and everything, really) in that order.
- fourstar 13y agoExactly. Plus the fact that words get much longer so things like input placeholders may get cut off, or words get pushed down to the next line.
- gisenberg 13y agoI've been burned by text-transform:uppercase changing the meaning of words in German.
- sergeylukin 13y agoI would only use :lang pseudo class to style direction-specific documents/elements if I'd be certain that no other language of same direction will be added in the future (and I can never be certain in something like that). Actually direction-specific styling is a different topic I think and I wish we had a :dir pseudo class or something for documents with multiple directions. Usually RTL languages expect the whole layout (with few exceptions) to be in opposite direction and not just nav elements. So, if a document exists in LTR and RTL (or even TTB) languages I'd recommend having separate stylesheet for each direction instead (btw it can be achieved and maintained easily with CSS pre-processors). If, however, multiple directions are mixed in one document, I'd probably use descendant selector instead: body [dir="rtl"] p {} or body [dir="ttb"] p {} etc. I have yet to see such combinations however..
- sergeylukin 13y agoBtw I found :dir pseudo class specification in recent draft: http://dev.w3.org/csswg/selectors4/#dir-pseudo http://dev.w3.org/csswg/selectors4/#dir-pseudo So maybe one day it will be easy to style HTML elements based on direction in multiple directional document as well. Just FYI