Design Technologist · AI-Assisted CSS Engineering

Logical Properties and Flexbox gutters for internationalized layouts.

This Week 03 showcase documents how semantic settings-card HTML becomes a responsive LTR/RTL interface by replacing physical CSS assumptions with Logical Properties, parent-owned Flexbox gaps, and human audit checks.

01Problem
02CSS Concepts
03Raw HTML
04AI Prompt
05Audit
06Final Result
07Verification
01

Why physical CSS breaks translated interfaces

Directional spacing works in one language direction, but it becomes fragile when the component is reused in another writing system.

Before

A profile settings card can appear correct in English while hiding brittle CSS underneath. Physical margins, paddings, borders, and text alignment do not understand the document's writing direction, so the same component can feel reversed or misaligned when translated.

Modern approach

Logical Properties describe spacing through inline and block directions. Flexbox gaps let the parent own element-to-element spacing. Together, the same class names can support an English card and an Arabic card without duplicate RTL styles or JavaScript.

Physical spacing Child margins Fixed text alignment Duplicate RTL CSS Unverified mirroring
02

The CSS concepts behind direction-aware components

Six coordinated ideas turn one semantic structure into a resilient translated interface.

03

The translation-ready HTML before layout engineering

The markup already carries LTR and RTL direction metadata, but browser defaults still stack the content without a card system.

before.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Week 03: Logical Properties Lab</title>
</head>
<body>

  <div class="app-layout">
    <!-- COMPONENT 1: English (Left-to-Right) Settings Card -->
    <section class="settings-card" dir="ltr">
      <header class="settings-card__header">
        <h2 class="settings-card__title">Profile Settings</h2>
        <p class="settings-card__subtitle">Manage your public directory information.</p>
      </header>

      <div class="settings-card__profile-section">
        <img src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150" alt="Avatar" class="profile-avatar">
        <div class="profile-info">
          <h3 class="profile-info__name">Sasha Dupont</h3>
          <span class="profile-info__status">Active Editor</span>
        </div>
        <button class="btn btn--secondary">Change Photo</button>
      </div>

      <footer class="settings-card__actions">
        <button class="btn btn--text">Cancel</button>
        <button class="btn btn--primary">Save Changes</button>
      </footer>
    </section>

    <!-- COMPONENT 2: Arabic (Right-to-Left) Settings Card -->
    <!-- (Using the exact same CSS classes as Component 1!) -->
    <section class="settings-card" dir="rtl">
      <header class="settings-card__header">
        <h2 class="settings-card__title">إعدادات الملف الشخصي</h2>
        <p class="settings-card__subtitle">إدارة معلومات الدليل العام الخاص بك.</p>
      </header>

      <div class="settings-card__profile-section">
        <img src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150" alt="Avatar" class="profile-avatar">
        <div class="profile-info">
          <h3 class="profile-info__name">ساشا دوبونت</h3>
          <span class="profile-info__status">محرر نشط</span>
        </div>
        <button class="btn btn--secondary">تغيير الصورة</button>
      </div>

      <footer class="settings-card__actions">
        <button class="btn btn--text">إلغاء</button>
        <button class="btn btn--primary">حفظ التغييرات</button>
      </footer>
    </section>
  </div>

</body>
</html>

Browser defaults only

Profile Settings

Manage your public directory information.

Sasha Dupont — Active Editor

Avatar · Change Photo

Cancel · Save Changes

إعدادات الملف الشخصي

إدارة معلومات الدليل العام الخاص بك.

ساشا دوبونت — محرر نشط

Avatar · تغيير الصورة

إلغاء · حفظ التغييرات

04

How the AI prompt became an auditable contract

The prompt converts the assignment rules into specific checks for Logical Properties, Flexbox gaps, directionality, and output boundaries.

Layer 1 — Lock the structure

Keep the supplied semantic HTML and class names intact.

Layer 2 — Define layout parents

Assign Flexbox responsibilities to the app, profile row, actions row, and buttons.

Layer 3 — Require parent gaps

Use gap for sibling spacing instead of margins on individual children.

Layer 4 — Enforce logical CSS

Use inline and block properties for spacing, sizing, and borders.

Layer 5 — Preserve translation behavior

Use text-align: start and let dir mirror the two cards without duplicate selectors.

Layer 6 — Demand verification

Require responsive, accessibility, overflow, reduced-motion, and code-audit checks.

AI prompt
Act as a senior CSS systems engineer. Generate a production-ready stylesheet for the supplied semantic settings-card HTML without replacing its structural class system.

Architecture requirements:

1. Preserve the supplied app-layout, settings-card, settings-card__header, settings-card__profile-section, profile-avatar, profile-info, settings-card__actions, and button class names.

2. Build the layout with Flexbox parent containers. Use gap on each Flexbox parent for element-to-element spacing instead of placing margins on individual children.

3. Use Internationalized Logical Properties for all spacing, sizing, and borders. Prefer padding-block, padding-inline, margin-block, margin-inline, border-block-end, inline-size, min-inline-size, and max-inline-size.

4. Do not use physical spacing or border declarations. The generated stylesheet must avoid physical directional property names in margins, paddings, borders, and positioning.

5. Align translated text with text-align: start so both English and Arabic content keep the correct reading edge.

6. Ensure the English card and Arabic card use the same class names and the same CSS rules. The dir attribute must be enough to mirror avatar placement, profile text flow, and action button order.

7. Make the cards responsive with flexible wrapping, shrink-safe children, controlled avatar sizing, accessible button target sizes, and no page-level horizontal overflow.

8. Include visible focus states, readable contrast, reduced-motion handling, and comments explaining the Logical Properties and Flexbox gap strategy.

9. Return only CSS. Do not add JavaScript, duplicate class names for RTL, or rewrite the HTML structure.

Return only the complete CSS stylesheet.
05

Auditing the generated internationalized CSS

The draft is accepted only after the stylesheet proves that spacing is logical, parent-owned, and mirrored by direction.

audited CSS excerpt
.app-layout {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xl);
  align-items: stretch;
  justify-content: center;
  padding-block: var(--space-xl);
  padding-inline: var(--space-lg);
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  inline-size: min(100%, 32rem);
  padding-block: var(--space-lg);
  padding-inline: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: start;
}

.settings-card__profile-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.profile-info {
  flex: 1 1 12rem;
  min-inline-size: 0;
}

.settings-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: var(--space-sm);
  border-block-start: 1px solid var(--color-border);
  padding-block-start: var(--space-md);
}
code audit target
CSS audit search terms:

left
right
top
bottom

Expected result inside spacing, padding, border, and positioning declarations:

No matches.
Verified: one class system

The English and Arabic cards use the same HTML classes and the same CSS selectors.

Verified: parent gaps

The app wrapper, profile row, and action row use gap for sibling spacing.

Verified: Logical Properties

padding-inline, padding-block, and border-block-start express layout intent.

Verified: text alignment

text-align: start keeps English and Arabic copy aligned to the reading edge.

Corrected: no duplicate RTL rules

The dir attributes carry the direction change without a second stylesheet branch.

Verified: shrink-safe content

min-inline-size: 0 allows translated names and labels to wrap inside the card.

Verified: responsive wrapping

Cards and internal rows wrap instead of creating page-level overflow.

Verified: visible focus

Buttons retain practical target sizes and focus indicators for keyboard users.

06

The final LTR and RTL settings cards after the audit

The avatar, profile text, photo action, and footer buttons mirror through the native direction algorithm while keeping the same classes.

Profile Settings

Manage your public directory information.

Avatar

Sasha Dupont

Active Editor

إعدادات الملف الشخصي

إدارة معلومات الدليل العام الخاص بك.

Avatar

ساشا دوبونت

محرر نشط

One CSS path

The LTR and RTL cards share the same selectors, spacing tokens, and component rules.

One spacing owner

gap belongs to the Flexbox parents, while padding-inline and padding-block describe the component surfaces.

One symmetry test

The browser mirrors inline flow from the dir attribute without duplicated layout code.

Avatar mirrors Actions mirror Text aligns to start No child margin gutters Same classes
07

Technical verification before deployment

The final page is accepted only after the component behavior, source code, and portfolio integration are inspected.

  1. Confirm the English card uses dir="ltr" and the Arabic card uses dir="rtl".
  2. Inspect the avatar placement and verify it appears at the inline start for each card.
  3. Confirm the photo action sits on the opposite inline edge without custom RTL selectors.
  4. Confirm the action buttons mirror naturally through direction-aware Flexbox behavior.
  5. Inspect computed styles and verify display: flex is active on the app, profile, and action containers.
  6. Confirm spacing between flex children is controlled by parent gap.
  7. Search the stylesheet for left, right, top, and bottom; the generated CSS should return no matches.
  8. Confirm text-align: start is used for translated content.
  9. Resize near 320px and verify cards wrap without unintended page-level horizontal scrolling.
  10. Zoom to 200% and confirm text, buttons, and translated labels remain usable.
  11. Navigate with the keyboard and verify visible focus on each button and showcase link.
  12. Switch the saved portfolio theme and confirm the page chrome remains readable.
  13. Confirm every supplied MDN reading link appears exactly once in Section 02.

AI drafted the CSS. Human auditing verified direction-aware spacing, source constraints, accessibility, and portfolio preservation.