Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /Css
  4. /Logical Properties
Your Progress0%
0 of 40 completed

CSS Topics

Getting Started

  • What is CSS?
  • CSS Syntax and Rules
  • How to Add CSS
  • CSS Comments and Organization

Selectors & Specificity

  • Basic Selectors
  • Combinators
  • Pseudo-classes
  • Pseudo-elements
  • Specificity and the Cascade

Colors & Typography

  • Color Values
  • Backgrounds and Gradients
  • Font Properties
  • Text Styling

Box Model & Layout Basics

  • The Box Model
  • Width, Height, and Sizing
  • Display Property
  • Positioning

Flexbox

  • Flexbox Fundamentals
  • Flex Container Properties
  • Flex Item Properties

CSS Grid

  • Grid Fundamentals
  • Grid Template Areas
  • Responsive Grids

Responsive Design

  • Media Queries Basics
  • Mobile-First Design
  • Responsive Units
  • Container Queries

Advanced Styling

  • Transforms
  • Transitions
  • Animations
  • Filters and Blend Modes
  • CSS Variables

Modern CSS Features

  • CSS Functions
  • Modern Layout Features
  • Logical Properties
  • CSS Nesting

Best Practices & Performance

  • CSS Organization
  • Performance Optimization
  • Browser Compatibility
  • Debugging CSS

Logical Properties

Writing mode-aware properties for internationalization

CSS logical properties are writing mode-aware alternatives to physical properties like left, right, top, and bottom. Instead of being tied to the physical screen, they adapt to the text direction and writing mode of your content. This makes your CSS automatically work with right-to-left (RTL) languages like Arabic and Hebrew, vertical writing modes like Japanese, and any future writing directions—all without changing a single line of CSS.

Physical vs Logical Properties

Understanding the difference between physical and logical properties is key to creating truly international designs.

Physical Properties (Old Way)

  • Based on screen directions: top, right, bottom, left
  • Fixed to physical layout
  • Don't adapt to writing mode
  • Require separate styles for RTL
  • Examples: margin-left, padding-top, border-right

Logical Properties (Modern Way)

  • Based on content flow: inline, block, start, end
  • Adapt to writing mode automatically
  • Work with any text direction
  • Single codebase for all languages
  • Examples: margin-inline-start, padding-block-end

Key Concepts

  • Inline axis: Direction text flows (horizontal in English, vertical in some Asian languages)
  • Block axis: Direction blocks stack (vertical in English, horizontal in some Asian languages)
  • Start: Beginning of text/block direction
  • End: End of text/block direction

In English (LTR, horizontal):
Inline = horizontal (left to right)
Block = vertical (top to bottom)
Start = left (inline) or top (block)
End = right (inline) or bottom (block)

Inline and Block Dimensions

Logical properties use inline for the text direction and block for the stacking direction.

inline-block.css
/* Width and Height - Logical equivalents */

/* Physical (old) */
.element {
  width: 300px;
  height: 200px;
}

/* Logical (modern) */
.element {
  inline-size: 300px;   /* Width in LTR horizontal text */
  block-size: 200px;    /* Height in LTR horizontal text */
}

/* Min and Max sizes */

/* Physical */
.element {
  max-width: 800px;
  min-height: 200px;
}

/* Logical */
.element {
  max-inline-size: 800px;
  min-block-size: 200px;
}

/* Why use logical? */
/* If writing-mode changes to vertical, 
   inline-size becomes height and block-size becomes width */

/* Vertical writing mode */
.vertical-text {
  writing-mode: vertical-rl;
  inline-size: 300px;   /* Now controls height! */
  block-size: 200px;    /* Now controls width! */
}

Logical Dimension Properties

PropertyValuesDescription
inline-sizelength or %Logical width (horizontal in LTR)
block-sizelength or %Logical height (vertical in LTR)
min-inline-sizelength or %Logical min-width
max-inline-sizelength or %Logical max-width
min-block-sizelength or %Logical min-height
max-block-sizelength or %Logical max-height

inline-size and block-size

Logical Margin and Padding

Logical margin and padding use inline, block, start, and end instead of left, right, top, bottom.

margin-padding.css
/* Margin - Physical vs Logical */

/* Physical (old) */
.element {
  margin-top: 1rem;
  margin-right: 2rem;
  margin-bottom: 1rem;
  margin-left: 2rem;
}

/* Logical (modern) */
.element {
  margin-block-start: 1rem;    /* top in LTR */
  margin-inline-end: 2rem;     /* right in LTR */
  margin-block-end: 1rem;      /* bottom in LTR */
  margin-inline-start: 2rem;   /* left in LTR */
}

/* Shorthand properties */

/* Physical */
.element {
  margin: 1rem 2rem;           /* top/bottom left/right */
  padding: 1rem 2rem 3rem;     /* top left/right bottom */
}

/* Logical */
.element {
  margin-block: 1rem;          /* block-start and block-end */
  margin-inline: 2rem;         /* inline-start and inline-end */
  padding-block: 1rem 3rem;    /* block-start block-end */
  padding-inline: 2rem;        /* inline-start and inline-end */
}

/* Individual sides */
.element {
  margin-inline-start: 2rem;   /* Left in LTR, Right in RTL */
  padding-block-end: 1rem;     /* Bottom in horizontal text */
}

/* Why this matters for RTL */

/* Physical - breaks in RTL */
.button {
  margin-left: 1rem;           /* Always left, wrong in RTL! */
}

/* Logical - works in RTL */
.button {
  margin-inline-start: 1rem;   /* Left in LTR, Right in RTL ✓ */
}

Logical Margin Properties (Same for Padding)

PropertyValuesDescription
margin-inline-startlengthStart of inline axis (left in LTR)
margin-inline-endlengthEnd of inline axis (right in LTR)
margin-block-startlengthStart of block axis (top in horizontal)
margin-block-endlengthEnd of block axis (bottom in horizontal)
margin-inlinestart endShorthand for inline-start and inline-end
margin-blockstart endShorthand for block-start and block-end

Logical Margins Adapt to Direction

🌍 RTL Language Support:

Using logical properties means your CSS automatically adapts to RTL languages like Arabic, Hebrew, Persian, and Urdu. No need for separate RTL stylesheets or dir="rtl" overrides. Just set direction: rtl and everything flips!

Logical Border Properties

Border properties also have logical equivalents that adapt to writing direction.

borders.css
/* Border - Physical vs Logical */

/* Physical (old) */
.element {
  border-left: 2px solid blue;
  border-right: 2px solid red;
  border-top: 2px solid green;
  border-bottom: 2px solid yellow;
}

/* Logical (modern) */
.element {
  border-inline-start: 2px solid blue;   /* left in LTR */
  border-inline-end: 2px solid red;      /* right in LTR */
  border-block-start: 2px solid green;   /* top */
  border-block-end: 2px solid yellow;    /* bottom */
}

/* Border width, style, color */
.element {
  border-inline-start-width: 2px;
  border-inline-start-style: solid;
  border-inline-start-color: blue;
}

/* Border radius - logical */

/* Physical */
.element {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/* Logical */
.element {
  border-start-start-radius: 8px;   /* top-left in LTR */
  border-start-end-radius: 8px;     /* top-right in LTR */
  border-end-start-radius: 8px;     /* bottom-left in LTR */
  border-end-end-radius: 8px;       /* bottom-right in LTR */
}

/* Practical example: Card with accent border */
.card {
  border-inline-start: 4px solid var(--accent-color);
  /* Left border in LTR, right border in RTL */
  padding-inline: 1.5rem;
  padding-block: 1rem;
  border-radius: 8px;
}

Logical Border Properties

Logical Position Properties

The inset property is a logical shorthand for positioning elements.

position.css
/* Position - Physical vs Logical */

/* Physical (old) */
.element {
  position: absolute;
  top: 1rem;
  right: 2rem;
  bottom: 1rem;
  left: 2rem;
}

/* Logical (modern) */
.element {
  position: absolute;
  inset-block-start: 1rem;    /* top */
  inset-inline-end: 2rem;     /* right in LTR */
  inset-block-end: 1rem;      /* bottom */
  inset-inline-start: 2rem;   /* left in LTR */
}

/* Inset shorthand */
.element {
  position: absolute;
  inset: 1rem;                /* All sides */
  inset: 1rem 2rem;           /* block inline */
  inset: 1rem 2rem 3rem 4rem; /* block-start inline-end block-end inline-start */
}

/* Individual inset properties */
.element {
  inset-inline: 2rem;         /* inline-start and inline-end */
  inset-block: 1rem;          /* block-start and block-end */
}

/* Practical example: Overlay */
.overlay {
  position: fixed;
  inset: 0;                   /* Cover entire viewport */
  background: rgba(0, 0, 0, 0.5);
}

/* Centered with inset */
.centered {
  position: absolute;
  inset: 0;
  margin: auto;
  inline-size: 300px;
  block-size: 200px;
}

Logical Inset Properties

Logical Text Alignment

Text alignment also has logical values that adapt to writing direction.

text-align.css
/* Text align - Physical vs Logical */

/* Physical (old) */
.element {
  text-align: left;   /* Always left, wrong in RTL */
  text-align: right;  /* Always right */
}

/* Logical (modern) */
.element {
  text-align: start;  /* Left in LTR, Right in RTL */
  text-align: end;    /* Right in LTR, Left in RTL */
}

/* Float - logical */

/* Physical */
.element {
  float: left;
  float: right;
}

/* Logical */
.element {
  float: inline-start;  /* Left in LTR, Right in RTL */
  float: inline-end;    /* Right in LTR, Left in RTL */
}

/* Clear - logical */
.element {
  clear: inline-start;
  clear: inline-end;
  clear: both;
}

Logical Text Alignment

Complete Practical Example

A complete component using logical properties that automatically adapts to any writing direction.

Complete Logical Properties Example (Switch LTR/RTL)

Physical to Logical Conversion

Quick reference for converting physical properties to their logical equivalents.

Physical → Logical Property Mapping

PropertyValuesDescription
widthinline-sizeHorizontal in LTR
heightblock-sizeVertical in LTR
margin-leftmargin-inline-startStart of inline axis
margin-rightmargin-inline-endEnd of inline axis
margin-topmargin-block-startStart of block axis
margin-bottommargin-block-endEnd of block axis
padding-leftpadding-inline-startStart of inline axis
border-leftborder-inline-startStart of inline axis
leftinset-inline-startPosition start inline
topinset-block-startPosition start block
text-align: lefttext-align: startAlign to start

Key Takeaways

  • Logical properties: Adapt to writing direction automatically
  • inline-size: Width in horizontal text
  • block-size: Height in horizontal text
  • inline axis: Text flow direction
  • block axis: Block stacking direction
  • start/end: Replace left/right for direction-awareness
  • inset: Logical shorthand for positioning
  • Use logical properties for international sites
  • Single codebase works for LTR and RTL
  • Better for vertical writing modes (Asian languages)
  • Future-proof for new writing directions
  • Supported in all modern browsers

What's Next?

Now that you understand logical properties for internationalization, you're ready to learn about CSS Nesting. In the next lesson, we'll explore native CSS nesting—writing nested selectors without preprocessors, making your CSS more organized and maintainable.

Logical properties are essential for modern, international websites. Start using margin-inline-start instead of margin-left, inline-size instead of width, and your CSS will automatically work with any language and writing direction. It's the same amount of code—just future-proof!

Know someone who'd find this guide helpful? Please share!

Previous
Modern Layout Features
Next
CSS Nesting

Never Miss a New CSS Tutorial

Join 1,000+ developers learning CSS step-by-step. Get new tutorials, styling tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

CSS Tutorials

0 of 40 completed

Your Progress0%

Topics

Getting Started

  • What is CSS?
  • CSS Syntax and Rules
  • How to Add CSS
  • CSS Comments and Organization

Selectors & Specificity

  • Basic Selectors
  • Combinators
  • Pseudo-classes
  • Pseudo-elements
  • Specificity and the Cascade

Colors & Typography

  • Color Values
  • Backgrounds and Gradients
  • Font Properties
  • Text Styling

Box Model & Layout Basics

  • The Box Model
  • Width, Height, and Sizing
  • Display Property
  • Positioning

Flexbox

  • Flexbox Fundamentals
  • Flex Container Properties
  • Flex Item Properties

CSS Grid

  • Grid Fundamentals
  • Grid Template Areas
  • Responsive Grids

Responsive Design

  • Media Queries Basics
  • Mobile-First Design
  • Responsive Units
  • Container Queries

Advanced Styling

  • Transforms
  • Transitions
  • Animations
  • Filters and Blend Modes
  • CSS Variables

Modern CSS Features

  • CSS Functions
  • Modern Layout Features
  • Logical Properties
  • CSS Nesting

Best Practices & Performance

  • CSS Organization
  • Performance Optimization
  • Browser Compatibility
  • Debugging CSS
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo