By Chen Hui Jing / @hj_chen
Internationalisation is the design and development of a product, application or document that enables easy localisation for target audiences that vary in culture, region, or language.
A vocabulary for communicating with the browser.
To inform the browser how we want elements to be styled and laid out.
CSS is a domain-specific, declarative programming language.
–Lara Schenck
lang
matters?Source: Why use the language attribute?
lang
Set the default language of the document:
<html lang="zh">
If you have mixed language content on your page:
<p>The fourth animal in the Chinese Zodiac is Rabbit (<span lang="zh">兔子</span>).</p>
:lang()
pseudo-classA selector that represents an element based on its language
We use italics to emphasise words in English, 但是中文则是用着重号.
We use italics to emphasise words in English, 但是中文则是用着重号.
A selector that matches elements based on the presence or value of a given selector
[lang="zh"]
/* will match only zh */
[lang^="zh"]
/* will match zh, zh-HK, zh-Hans, zhong, zh123…
* basically anything with zh as the first 2 characters */
[lang|="zh"]
/* will match zh, zh-HK, zh-Hans, zh-amazing, zh-123 */
The :lang()
pseudo-class does take care of partial tag matching
In terms of selector matching, the |=
operator performs a comparison against a given attribute on the element, while the :lang()
pseudo-class uses the UAs knowledge of the document's semantics for the comparison
You can always use normal classes or ids, but you would no longer be making use of the convenience of what already exists
font-synthesis
Controls if the browser should synthesize a missing typeface or not
We use italics to emphasise words in English, 但是中文则是用着重号.
font-variant-east-asian
Allows control of glyph substitution and sizing in East Asian text
一个简体字可能对应多个繁体字,如简体字「发」,其相应的繁体字可能为「發」或「髮」;一个繁体汉字对应多个简体汉字的情况与前者相比数量极少但仍需注意,如繁体字「乾」可能对应简体字「干」或「乾」。
font-language-override
To control the use of language-specific glyph substitutions and positioning
<!-- Macedonian lang code -->
<body lang="mk">
<h4>Члeн 9</h4>
<p>Никoj чoвeк нeмa дa бидe пoдлoжeн нa прoизвoлнo aпсeњe, притвoр или прoгoнувaњe.</p>
</body>
body {
/* Serbian OpenType language tag */
font-language-override: "SRB";
}
Example lifted from CSS Fonts Module Level 4
text-transform
Transforms text for styling purposes
If I want [flowers], I’m going to send them to myself.
Süße Soßen-Klöße genießen maßgeblich gefräßige preußische Nutznießer.
Ουδέν κακόν αμιγές καλού.
ァィゥェ ォヵㇰヶ
If an element generates zero boxes, was it really there at all?
If an element generates zero boxes, was it really there at all?
line-break |
allows choosing various levels of “strictness” for line breaking restrictions |
word-break |
controls what types of letters are glommed together to form unbreakable “words”, causing CJK characters to behave like non-CJK text or vice versa |
hyphens |
controls whether automatic hyphenation is allowed to break words in scripts that hyphenate |
overflow-wrap |
allows the UA to take a break anywhere in otherwise-unbreakable strings that would otherwise overflow |
Line breaking by Florian Rivoal @ dotCSS
If you don't give a lang attribute, you don't get automatic hyphenation.
—Florian Rivoal
Browsers use language-specific dictionaries to figure out where the hyphenation points should be.
writing-mode
text-orientation
& text-combine-upright
CSS should not be used for bi-directional styling
Because directionality is an integral part of the document structure, markup should be used to set the directionality for a document or chunk of information, or to identify places in the text where the Unicode bidirectional algorithm alone is insufficient to achieve desired directionality.
Physical directions for writing modes other than horizontal top-to-bottom may be confusing
writing-mode / direction | |||||||
horizontal-tb | vertical-rl | vertical-lr | |||||
ltr | rtl | ltr | rtl | ltr | rtl | ||
Edge
|
top
|
inset-block-start | inset-block-start | inset-inline-start | inset-inline-end | inset-inline-start | inset-inline-end |
right
|
inset-inline-end | inset-inline-start | inset-block-start | inset-block-start | inset-block-end | inset-block-end | |
bottom
|
inset-block-end | inset-block-end | inset-inline-end | inset-inline-start | inset-inline-end | inset-inline-start | |
left
|
inset-inline-start | inset-inline-end | inset-block-end | inset-block-end | inset-block-start | inset-block-start |
See the Pen CSS Logical properties demo for borders by Chen Hui Jing (@huijing) on CodePen.
Allows us to display ordered lists with international numbering systems
Font is PlovdivTypeface by Studio Punkt and Typedepot.