🎓 EASYTUTORGUIDE

Practical tutorials, tools, courses, digital skills, and business promotion.

★ Free Learning
Translate this lesson:
Arabic and Persian use RTL layout. CSS and HTML code remain LTR. Long translated text wraps on all device sizes.

CSS • Chapter 39 • Foundations to Production

Custom Properties

Every topic includes a CSS/HTML coding example, ten focused teaching examples, code explanation, expected result, practice, and responsive/translated-layout checks.

5 topics5 coding examples50 teaching examples10 Q&A
Estimated reading time0% read

39.1 Declaring CSS Variables

Declaring CSS Variables is part of the CSS system covered in Chapter 39. 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 Declaring CSS Variables in Chapter 39, 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 Declaring CSS Variables, 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 39, topic 1.

Concept in plain language

Declaring CSS Variables is part of the CSS system covered in Chapter 39. 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

  1. Example 1: Smallest useful case

    Build a minimal photo gallery for Declaring CSS Variables. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 39, topic 1, example 1.

  2. Example 2: Change one value

    Change one important CSS value in the pricing table example for Declaring CSS Variables. Predict the visual difference before reloading the page. Chapter 39, topic 1, example 2.

  3. Example 3: Narrow-screen test

    Test Declaring CSS Variables in the lesson sidebar at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 39, topic 1, example 3.

  4. Example 4: Translated-text test

    Translate the contact form into a language with longer labels while using Declaring CSS Variables. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 39, topic 1, example 4.

  5. 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 39, topic 1, example 5.

  6. Example 6: Accessibility test

    Check Declaring CSS Variables in the data table with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 39, topic 1, example 6.

  7. Example 7: Cascade test

    Add a competing rule to the media player and determine why the declaration for Declaring CSS Variables wins or loses using the browser's Styles and Computed panels. Chapter 39, topic 1, example 7.

  8. Example 8: Content-stress test

    Fill the notification with very long words, URLs, translated text, images, and nested controls. Adjust Declaring CSS Variables without hiding meaningful content. Chapter 39, topic 1, example 8.

  9. Example 9: Refactoring test

    Rewrite the language selector so Declaring CSS Variables uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 39, topic 1, example 9.

  10. Example 10: Production review

    Review Declaring CSS Variables in the course card for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 39, topic 1, example 10.

CSS/HTML coding example

<!-- HTML -->
<div class="card">Custom property tokens</div>

<style>
:root { --space:1rem; --brand:#6d28d9; }
</style>

Step-by-step code explanation

  1. Identify the selector and declaration that demonstrate Declaring CSS Variables.
  2. Read the HTML structure first so you know which box or relationship the CSS is styling.
  3. Custom properties store reusable values in the cascade.
  4. 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.
  5. 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 Declaring CSS Variables 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 39, topic 1.

Practice exercise

Build a fresh example for Declaring CSS Variables from Chapter 39. 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.

39.2 var Function

var Function is part of the CSS system covered in Chapter 39. 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 var Function in Chapter 39, 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 var Function, 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 39, topic 2.

Concept in plain language

var Function is part of the CSS system covered in Chapter 39. 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

  1. Example 1: Smallest useful case

    Build a minimal contact form for var Function. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 39, topic 2, example 1.

  2. Example 2: Change one value

    Change one important CSS value in the button group example for var Function. Predict the visual difference before reloading the page. Chapter 39, topic 2, example 2.

  3. Example 3: Narrow-screen test

    Test var Function in the data table at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 39, topic 2, example 3.

  4. Example 4: Translated-text test

    Translate the media player into a language with longer labels while using var Function. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 39, topic 2, example 4.

  5. 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 39, topic 2, example 5.

  6. Example 6: Accessibility test

    Check var Function in the language selector with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 39, topic 2, example 6.

  7. Example 7: Cascade test

    Add a competing rule to the course card and determine why the declaration for var Function wins or loses using the browser's Styles and Computed panels. Chapter 39, topic 2, example 7.

  8. Example 8: Content-stress test

    Fill the navigation bar with very long words, URLs, translated text, images, and nested controls. Adjust var Function without hiding meaningful content. Chapter 39, topic 2, example 8.

  9. Example 9: Refactoring test

    Rewrite the article so var Function uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 39, topic 2, example 9.

  10. Example 10: Production review

    Review var Function in the profile panel for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 39, topic 2, example 10.

CSS/HTML coding example

<!-- HTML -->
<article class="card">var() demo</article>

<style>
.card { padding:var(--space,1rem); color:var(--brand,#4c1d95); }
</style>

Step-by-step code explanation

  1. Identify the selector and declaration that demonstrate var Function.
  2. Read the HTML structure first so you know which box or relationship the CSS is styling.
  3. var() reads a custom property with an optional fallback.
  4. 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.
  5. 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 var Function 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 39, topic 2.

Practice exercise

Build a fresh example for var Function from Chapter 39. 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.

39.3 Fallback Values

Fallback Values is part of the CSS system covered in Chapter 39. 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 Fallback Values in Chapter 39, 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 Fallback Values, 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 39, topic 3.

Concept in plain language

Fallback Values is part of the CSS system covered in Chapter 39. 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

  1. Example 1: Smallest useful case

    Build a minimal media player for Fallback Values. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 39, topic 3, example 1.

  2. Example 2: Change one value

    Change one important CSS value in the notification example for Fallback Values. Predict the visual difference before reloading the page. Chapter 39, topic 3, example 2.

  3. Example 3: Narrow-screen test

    Test Fallback Values in the language selector at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 39, topic 3, example 3.

  4. Example 4: Translated-text test

    Translate the course card into a language with longer labels while using Fallback Values. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 39, topic 3, example 4.

  5. 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 39, topic 3, example 5.

  6. Example 6: Accessibility test

    Check Fallback Values in the article with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 39, topic 3, example 6.

  7. Example 7: Cascade test

    Add a competing rule to the profile panel and determine why the declaration for Fallback Values wins or loses using the browser's Styles and Computed panels. Chapter 39, topic 3, example 7.

  8. Example 8: Content-stress test

    Fill the search form with very long words, URLs, translated text, images, and nested controls. Adjust Fallback Values without hiding meaningful content. Chapter 39, topic 3, example 8.

  9. Example 9: Refactoring test

    Rewrite the dashboard so Fallback Values uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 39, topic 3, example 9.

  10. Example 10: Production review

    Review Fallback Values in the photo gallery for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 39, topic 3, example 10.

CSS/HTML coding example

<!-- HTML -->
<article class="card">Custom property example</article>

<style>
.card{color:var(--brand,#6d28d9)}
</style>

Step-by-step code explanation

  1. Identify the selector and declaration that demonstrate Fallback Values.
  2. Read the HTML structure first so you know which box or relationship the CSS is styling.
  3. The custom-property example demonstrates Fallback Values.
  4. 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.
  5. 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 Fallback Values 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 39, topic 3.

Practice exercise

Build a fresh example for Fallback Values from Chapter 39. 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.

39.4 Inheritance of Custom Properties

Inheritance of Custom Properties is part of the CSS system covered in Chapter 39. 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 Inheritance of Custom Properties in Chapter 39, 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 Inheritance of Custom Properties, 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 39, topic 4.

Concept in plain language

Inheritance of Custom Properties is part of the CSS system covered in Chapter 39. 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

  1. Example 1: Smallest useful case

    Build a minimal course card for Inheritance of Custom Properties. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 39, topic 4, example 1.

  2. Example 2: Change one value

    Change one important CSS value in the navigation bar example for Inheritance of Custom Properties. Predict the visual difference before reloading the page. Chapter 39, topic 4, example 2.

  3. Example 3: Narrow-screen test

    Test Inheritance of Custom Properties in the article at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 39, topic 4, example 3.

  4. Example 4: Translated-text test

    Translate the profile panel into a language with longer labels while using Inheritance of Custom Properties. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 39, topic 4, example 4.

  5. 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 39, topic 4, example 5.

  6. Example 6: Accessibility test

    Check Inheritance of Custom Properties in the dashboard with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 39, topic 4, example 6.

  7. Example 7: Cascade test

    Add a competing rule to the photo gallery and determine why the declaration for Inheritance of Custom Properties wins or loses using the browser's Styles and Computed panels. Chapter 39, topic 4, example 7.

  8. Example 8: Content-stress test

    Fill the pricing table with very long words, URLs, translated text, images, and nested controls. Adjust Inheritance of Custom Properties without hiding meaningful content. Chapter 39, topic 4, example 8.

  9. Example 9: Refactoring test

    Rewrite the lesson sidebar so Inheritance of Custom Properties uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 39, topic 4, example 9.

  10. Example 10: Production review

    Review Inheritance of Custom Properties in the contact form for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 39, topic 4, example 10.

CSS/HTML coding example

<!-- HTML -->
<article class="card">Custom property example</article>

<style>
:root{--text:#111827}.card{color:var(--text)}
</style>

Step-by-step code explanation

  1. Identify the selector and declaration that demonstrate Inheritance of Custom Properties.
  2. Read the HTML structure first so you know which box or relationship the CSS is styling.
  3. The custom-property example demonstrates Inheritance of Custom Properties.
  4. 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.
  5. 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 Inheritance of Custom Properties 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 39, topic 4.

Practice exercise

Build a fresh example for Inheritance of Custom Properties from Chapter 39. 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.

39.5 Theme Tokens

Theme Tokens is part of the CSS system covered in Chapter 39. 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 Theme Tokens in Chapter 39, 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 Theme Tokens, 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 39, topic 5.

Concept in plain language

Theme Tokens is part of the CSS system covered in Chapter 39. 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

  1. Example 1: Smallest useful case

    Build a minimal profile panel for Theme Tokens. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 39, topic 5, example 1.

  2. Example 2: Change one value

    Change one important CSS value in the search form example for Theme Tokens. Predict the visual difference before reloading the page. Chapter 39, topic 5, example 2.

  3. Example 3: Narrow-screen test

    Test Theme Tokens in the dashboard at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 39, topic 5, example 3.

  4. Example 4: Translated-text test

    Translate the photo gallery into a language with longer labels while using Theme Tokens. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 39, topic 5, example 4.

  5. 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 39, topic 5, example 5.

  6. Example 6: Accessibility test

    Check Theme Tokens in the lesson sidebar with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 39, topic 5, example 6.

  7. Example 7: Cascade test

    Add a competing rule to the contact form and determine why the declaration for Theme Tokens wins or loses using the browser's Styles and Computed panels. Chapter 39, topic 5, example 7.

  8. Example 8: Content-stress test

    Fill the button group with very long words, URLs, translated text, images, and nested controls. Adjust Theme Tokens without hiding meaningful content. Chapter 39, topic 5, example 8.

  9. Example 9: Refactoring test

    Rewrite the data table so Theme Tokens uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 39, topic 5, example 9.

  10. Example 10: Production review

    Review Theme Tokens in the media player for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 39, topic 5, example 10.

CSS/HTML coding example

<!-- HTML -->
<article class="card">Custom property example</article>

<style>
:root{--space-1:.5rem;--radius:1rem}.card{padding:var(--space-1);border-radius:var(--radius)}
</style>

Step-by-step code explanation

  1. Identify the selector and declaration that demonstrate Theme Tokens.
  2. Read the HTML structure first so you know which box or relationship the CSS is styling.
  3. The custom-property example demonstrates Theme Tokens.
  4. 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.
  5. 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 Theme Tokens 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 39, topic 5.

Practice exercise

Build a fresh example for Theme Tokens from Chapter 39. 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 39 review — 10 questions and answers

1. What should you inspect first when Declaring CSS Variables does not work as expected?

Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Declaring CSS Variables. Then reduce the example until the winning declaration is clear.

2. How should Declaring CSS Variables be checked before publishing?

Answer: Test Declaring CSS Variables 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 var Function does not work as expected?

Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for var Function. Then reduce the example until the winning declaration is clear.

4. How should var Function be checked before publishing?

Answer: Test var Function 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 Fallback Values does not work as expected?

Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Fallback Values. Then reduce the example until the winning declaration is clear.

6. How should Fallback Values be checked before publishing?

Answer: Test Fallback Values 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 Inheritance of Custom Properties does not work as expected?

Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Inheritance of Custom Properties. Then reduce the example until the winning declaration is clear.

8. How should Inheritance of Custom Properties be checked before publishing?

Answer: Test Inheritance of Custom Properties 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 Theme Tokens does not work as expected?

Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Theme Tokens. Then reduce the example until the winning declaration is clear.

10. How should Theme Tokens be checked before publishing?

Answer: Test Theme Tokens 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.