Margin 4-Value Shorthand Expansion

Expand four finite pixel margins in top, right, bottom, left order.

Description

Four-value margin shorthand follows clockwise physical-side order: top, right, bottom and left.

Four-value margin shorthand follows clockwise physical-side order: top, right, bottom and left. Negative margins are allowed in this numeric expansion and remain signed values.1

Expand four finite pixel margins in top, right, bottom, left order.

When to use Margin 4-Value Shorthand Expansion

Use this tool to expand four finite pixel margins in top, right, bottom, left order.

Choose the CSS values, dimensions or counts for this calculation. Supply resolved numeric measurements in matching units and the explicit reference box or writing mode where required.

How to use Margin 4-Value Shorthand Expansion and understand its results

  1. Choose the CSS values, dimensions or counts for this calculation. Supply resolved numeric measurements in matching units and the explicit reference box or writing mode where required.
  2. Enter first, second, third, fourth using the field table and calculation rules, then run the tool.
  3. Read top, right, bottom, left. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
firstFirst marginnumberRequired
secondSecond marginnumberRequired
thirdThird marginnumberRequired
fourthFourth marginnumberRequired

Enter four finite pixel margins in shorthand order. The tool returns one value for each physical side without performing arithmetic, rounding or unit conversion. Each input may be positive, zero or negative.

top = first; right = second; bottom = third; left = fourth

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
topTop marginnumber
rightRight marginnumber
bottomBottom marginnumber
leftLeft marginnumber
json
{
  "input": {
    "first": 1,
    "second": 2,
    "third": 3,
    "fourth": 4
  },
  "output": {
    "top": 1,
    "right": 2,
    "bottom": 3,
    "left": 4
  }
}

Limitations and assumptions

CSS strings, auto, percentages and calc expressions are unsupported. This does not model margin collapse, layout or the cascade. A writing-mode mapping is a separate step when logical-side values are needed.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use Physical→Logical Margin Mapper: Map four finite physical pixel margins to inline and block sides using writing mode and text direction. For a complementary task, use inset All-Four Offsets Shorthand: Expand one to four finite pixel inset values into top, right, bottom, and left offsets.

References

  1. Margin 4-Value Shorthand Expansion — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies