css · level 3 · unit 4 · lesson 2
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Logical properties follow the text, not the screen edges.
English runs left to right, but Arabic and Hebrew run right to left. A property like margin-left is tied to the screen, so it lands on the wrong side when the page flips. A follows the text instead.
The is the way text runs along a line. The is the way paragraphs stack. So padding-inline sets both ends of a line, margin-block sets above and below, and inline-size replaces width.
-start means where the text begins. In English that is the left, but in a box with dir="rtl" it becomes the right.
<blockquote class="quote">Hello</blockquote>
<blockquote class="quote" dir="rtl">مرحبا</blockquote> .quote {
margin-inline: 0;
padding-inline-start: 16px;
border-inline-start: 6px solid #0f766e;
} Press show my page to see it here.
guess first
The same rule in a right-to-left box. Where is the border?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<p class="note" dir="rtl">ملاحظة مهمة</p> .note {
padding-inline-start: 12px;
border-inline-start: 8px solid crimson;
}
your turn
Your turn. Make a tag that works in any language.
Fill in two logical properties: 12px of padding at both ends of the line, and 4px above and below.
the page you’re styling
<span class="tag">News</span>
<span class="tag" dir="rtl">أخبار</span>your css
Press show my page to see it here.
- the tag has 12px at the leftnot checked yet
- the tag has 12px at the rightnot checked yet
- the tag has 4px abovenot checked yet
- the line ends use
padding-inlinenot checked yet
fix it
The gap sits on the wrong side of the star. Can you fix it?
the page you’re styling
<p dir="rtl"><span class="icon">★</span><span class="label">المفضلة</span></p>your css
Press show my page to see it here.
- the gap sits next to the starnot checked yet
- no gap on the far sidenot checked yet
- In right-to-left text the star comes first, on the right. Which side of the label faces it?
margin-leftis tied to the screen. You want the edge where this text starts.- Use
margin-inline-start: 8px;, then press run.
nailed it
your styles now read in every direction. :D
- Inline runs along the line; block runs down the page.
-startand-endfollow the text direction.- Logical properties make
dir="rtl"pages work.
new words in your collection
- logical property
- inline axis
- block axis
This lesson isn’t saved. A free account remembers every lesson you finish.