Chapter 7, Exercise 3: Multilingual article page
================================================
(Not tested across several browsers. The Japanese and Arabic font names are
invented placeholders: replace them with fonts you have a licence for.)
--- article.html (skeleton) ---
Greetings Around the World
People say hello in many ways.
こんにちは
مرحبا
In French we say Bonjour.
--- article.css ---
/* Body: rem so the text follows the reader's browser font-size setting */
body {
font-size: 1rem;
line-height: 1.5;
/* Latin stack: a system stack first, a generic family last */
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
color: #1f2328; /* well above 4.5:1 on white */
background: #ffffff;
}
/* Column: caps the measure in ch, still fits a phone at 200% zoom */
.article {
max-width: 65ch; /* comfortable line length on wide screens */
margin-inline: auto; /* centre the column */
padding-inline: 1rem; /* breathing room on narrow screens */
overflow-wrap: break-word; /* long words never break the layout */
hyphens: auto; /* uses the lang attribute for rules */
text-align: left; /* ragged right: no justified rivers */
}
/* Japanese passages: a stack that has the right glyphs */
:lang(ja) {
font-family: "Example Gothic JP", "Yu Gothic", "Hiragino Sans", sans-serif;
line-height: 1.7; /* these scripts often need more room */
}
/* Arabic passages: right to left, with Arabic-capable fonts */
:lang(ar) {
font-family: "Example Naskh", "Segoe UI", Tahoma, sans-serif;
line-height: 1.8;
}
[dir="rtl"] {
text-align: right; /* start edge of an RTL paragraph */
}
/* French quotation marks with non-breaking spaces */
:lang(fr) {
quotes: "«\00a0" "\00a0»";
}
/* Motion: respect readers who ask the system to reduce movement */
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
transition: none !important;
scroll-behavior: auto !important;
}
}
Notes
- text-align: right on the RTL block could also be written text-align: start,
which follows the writing direction automatically (check support for your
target browsers).
- The 65ch cap only limits the width; the padding keeps phones comfortable,
and zooming to 200% simply makes the column fill the screen.
- Test by zooming to 200%, resizing to phone width, and switching the browser
default font size up. Nothing should need sideways scrolling.