CSS • Chapter 18 • Foundations to Production
Logical Properties and Writing Modes
Every topic includes a CSS/HTML coding example, ten focused teaching examples, code explanation, expected result, practice, and responsive/translated-layout checks.
18.1 margin-inline
margin-inline is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For margin-inline in Chapter 18, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for margin-inline, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 18, topic 1.
Concept in plain language
margin-inline is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal contact form for margin-inline. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 18, topic 1, example 1.
Example 2: Change one value
Change one important CSS value in the button group example for margin-inline. Predict the visual difference before reloading the page. Chapter 18, topic 1, example 2.
Example 3: Narrow-screen test
Test margin-inline in the data table at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 18, topic 1, example 3.
Example 4: Translated-text test
Translate the media player into a language with longer labels while using margin-inline. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 18, topic 1, example 4.
Example 5: Arabic/Persian test
Switch the notification to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 18, topic 1, example 5.
Example 6: Accessibility test
Check margin-inline in the language selector with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 18, topic 1, example 6.
Example 7: Cascade test
Add a competing rule to the course card and determine why the declaration for margin-inline wins or loses using the browser's Styles and Computed panels. Chapter 18, topic 1, example 7.
Example 8: Content-stress test
Fill the navigation bar with very long words, URLs, translated text, images, and nested controls. Adjust margin-inline without hiding meaningful content. Chapter 18, topic 1, example 8.
Example 9: Refactoring test
Rewrite the article so margin-inline uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 18, topic 1, example 9.
Example 10: Production review
Review margin-inline in the profile panel for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 18, topic 1, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="demo margin-inline">CSS topic: margin-inline</div>
<style>
.margin-inline {
padding: 1rem;
border: 1px solid #94a3b8;
}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate margin-inline.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The selector targets the demonstration for margin-inline, and the declaration changes a visible part of its presentation.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates margin-inline without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 18, topic 1.
Practice exercise
Build a fresh example for margin-inline from Chapter 18. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
18.2 padding-block
padding-block is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For padding-block in Chapter 18, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for padding-block, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 18, topic 2.
Concept in plain language
padding-block is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal media player for padding-block. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 18, topic 2, example 1.
Example 2: Change one value
Change one important CSS value in the notification example for padding-block. Predict the visual difference before reloading the page. Chapter 18, topic 2, example 2.
Example 3: Narrow-screen test
Test padding-block in the language selector at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 18, topic 2, example 3.
Example 4: Translated-text test
Translate the course card into a language with longer labels while using padding-block. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 18, topic 2, example 4.
Example 5: Arabic/Persian test
Switch the navigation bar to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 18, topic 2, example 5.
Example 6: Accessibility test
Check padding-block in the article with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 18, topic 2, example 6.
Example 7: Cascade test
Add a competing rule to the profile panel and determine why the declaration for padding-block wins or loses using the browser's Styles and Computed panels. Chapter 18, topic 2, example 7.
Example 8: Content-stress test
Fill the search form with very long words, URLs, translated text, images, and nested controls. Adjust padding-block without hiding meaningful content. Chapter 18, topic 2, example 8.
Example 9: Refactoring test
Rewrite the dashboard so padding-block uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 18, topic 2, example 9.
Example 10: Production review
Review padding-block in the photo gallery for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 18, topic 2, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="box">Padded content</div>
<style>
.box { padding: 1rem 2rem; background: #eef2ff; }
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate padding-block.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- Padding creates space inside the border.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates padding-block without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 18, topic 2.
Practice exercise
Build a fresh example for padding-block from Chapter 18. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
18.3 inset-inline
inset-inline is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For inset-inline in Chapter 18, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for inset-inline, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 18, topic 3.
Concept in plain language
inset-inline is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal course card for inset-inline. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 18, topic 3, example 1.
Example 2: Change one value
Change one important CSS value in the navigation bar example for inset-inline. Predict the visual difference before reloading the page. Chapter 18, topic 3, example 2.
Example 3: Narrow-screen test
Test inset-inline in the article at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 18, topic 3, example 3.
Example 4: Translated-text test
Translate the profile panel into a language with longer labels while using inset-inline. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 18, topic 3, example 4.
Example 5: Arabic/Persian test
Switch the search form to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 18, topic 3, example 5.
Example 6: Accessibility test
Check inset-inline in the dashboard with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 18, topic 3, example 6.
Example 7: Cascade test
Add a competing rule to the photo gallery and determine why the declaration for inset-inline wins or loses using the browser's Styles and Computed panels. Chapter 18, topic 3, example 7.
Example 8: Content-stress test
Fill the pricing table with very long words, URLs, translated text, images, and nested controls. Adjust inset-inline without hiding meaningful content. Chapter 18, topic 3, example 8.
Example 9: Refactoring test
Rewrite the lesson sidebar so inset-inline uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 18, topic 3, example 9.
Example 10: Production review
Review inset-inline in the contact form for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 18, topic 3, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="demo inset-inline">CSS topic: inset-inline</div>
<style>
.inset-inline {
padding: 1rem;
border: 1px solid #94a3b8;
}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate inset-inline.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The selector targets the demonstration for inset-inline, and the declaration changes a visible part of its presentation.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates inset-inline without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 18, topic 3.
Practice exercise
Build a fresh example for inset-inline from Chapter 18. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
18.4 border-inline
border-inline is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For border-inline in Chapter 18, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for border-inline, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 18, topic 4.
Concept in plain language
border-inline is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal profile panel for border-inline. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 18, topic 4, example 1.
Example 2: Change one value
Change one important CSS value in the search form example for border-inline. Predict the visual difference before reloading the page. Chapter 18, topic 4, example 2.
Example 3: Narrow-screen test
Test border-inline in the dashboard at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 18, topic 4, example 3.
Example 4: Translated-text test
Translate the photo gallery into a language with longer labels while using border-inline. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 18, topic 4, example 4.
Example 5: Arabic/Persian test
Switch the pricing table to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 18, topic 4, example 5.
Example 6: Accessibility test
Check border-inline in the lesson sidebar with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 18, topic 4, example 6.
Example 7: Cascade test
Add a competing rule to the contact form and determine why the declaration for border-inline wins or loses using the browser's Styles and Computed panels. Chapter 18, topic 4, example 7.
Example 8: Content-stress test
Fill the button group with very long words, URLs, translated text, images, and nested controls. Adjust border-inline without hiding meaningful content. Chapter 18, topic 4, example 8.
Example 9: Refactoring test
Rewrite the data table so border-inline uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 18, topic 4, example 9.
Example 10: Production review
Review border-inline in the media player for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 18, topic 4, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="row"><div>A</div><div class="featured">Featured</div></div>
<style>
.featured { order:-1; }
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate border-inline.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- order changes visual order, so it must not replace meaningful source order.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates border-inline without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 18, topic 4.
Practice exercise
Build a fresh example for border-inline from Chapter 18. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
18.5 writing-mode
writing-mode is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For writing-mode in Chapter 18, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for writing-mode, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 18, topic 5.
Concept in plain language
writing-mode is part of the CSS system covered in Chapter 18. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal photo gallery for writing-mode. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 18, topic 5, example 1.
Example 2: Change one value
Change one important CSS value in the pricing table example for writing-mode. Predict the visual difference before reloading the page. Chapter 18, topic 5, example 2.
Example 3: Narrow-screen test
Test writing-mode in the lesson sidebar at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 18, topic 5, example 3.
Example 4: Translated-text test
Translate the contact form into a language with longer labels while using writing-mode. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 18, topic 5, example 4.
Example 5: Arabic/Persian test
Switch the button group to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 18, topic 5, example 5.
Example 6: Accessibility test
Check writing-mode in the data table with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 18, topic 5, example 6.
Example 7: Cascade test
Add a competing rule to the media player and determine why the declaration for writing-mode wins or loses using the browser's Styles and Computed panels. Chapter 18, topic 5, example 7.
Example 8: Content-stress test
Fill the notification with very long words, URLs, translated text, images, and nested controls. Adjust writing-mode without hiding meaningful content. Chapter 18, topic 5, example 8.
Example 9: Refactoring test
Rewrite the language selector so writing-mode uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 18, topic 5, example 9.
Example 10: Production review
Review writing-mode in the course card for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 18, topic 5, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="demo writing-mode">CSS topic: writing-mode</div>
<style>
.writing-mode {
padding: 1rem;
border: 1px solid #94a3b8;
}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate writing-mode.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The selector targets the demonstration for writing-mode, and the declaration changes a visible part of its presentation.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates writing-mode without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 18, topic 5.
Practice exercise
Build a fresh example for writing-mode from Chapter 18. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
Chapter 18 review — 10 questions and answers
1. What should you inspect first when margin-inline does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for margin-inline. Then reduce the example until the winning declaration is clear.
2. How should margin-inline be checked before publishing?
Answer: Test margin-inline on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
3. What should you inspect first when padding-block does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for padding-block. Then reduce the example until the winning declaration is clear.
4. How should padding-block be checked before publishing?
Answer: Test padding-block on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
5. What should you inspect first when inset-inline does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for inset-inline. Then reduce the example until the winning declaration is clear.
6. How should inset-inline be checked before publishing?
Answer: Test inset-inline on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
7. What should you inspect first when border-inline does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for border-inline. Then reduce the example until the winning declaration is clear.
8. How should border-inline be checked before publishing?
Answer: Test border-inline on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
9. What should you inspect first when writing-mode does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for writing-mode. Then reduce the example until the winning declaration is clear.
10. How should writing-mode be checked before publishing?
Answer: Test writing-mode on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.