Skip to content

Abbreviate units of measurement (EK00050)

Abbreviated units keep measurements short and consistent. Write 5 px or 10 m instead of spelling out pixels or meters after a number in your documentation.

Abbreviating a unit after a number — 5 px rather than 5 pixels — keeps measurements short and consistent across your documentation. EkLine flags a spelled-out unit of measurement after a number and suggests the abbreviation (rule EK00050).

Why abbreviate units of measurement in documentation?

Section titled “Why abbreviate units of measurement in documentation?”

Measurements appear often in technical writing, and mixing “5 pixels” with “5 px” on different pages makes the content look unedited. Abbreviated units are shorter, scan faster in tables and code, and match how measurements appear in interfaces, specs, and libraries. One convention keeps your numbers predictable for readers.

EK00050 matches a spelled-out unit of measurement — such as meters, grams, pixels, inches, miles, or pounds — after a number and suggests the abbreviation.

  • Incorrect: Add a 5 pixels border around the element.
  • Correct: Add a 5 px border around the element.
  • Incorrect: The cable is 10 meters long.
  • Correct: The cable is 10 m long.

Replace the spelled-out unit with its abbreviation, such as m for meters, g for grams, or px for pixels.

Should you write “5 px” or “5 pixels”?

Section titled “Should you write “5 px” or “5 pixels”?”

Use the abbreviation, “5 px”. Abbreviated units are shorter, scan faster in tables and code, and match how measurements appear in interfaces and specs.

When should you keep the spelled-out unit?

Section titled “When should you keep the spelled-out unit?”

When the unit is part of prose rather than a measurement — for example, “the last few meters of the route” — keep the word and ignore the rule for that line.

PropertyValue
Rule IDEK00050
CategoryConsistency
Default severityError
Enabled by defaultYes

To keep a spelled-out unit on one line, add an inline comment with a reason:

<!-- ekline-ignore-next-line EK00050 -- descriptive prose, not a measurement -->
You are just a few meters from the finish.

To disable the rule across your project, add it to the ignore list in your configuration file.

  • EK00054 — Format data measurements consistently
  • EK00055 — Use numerals for time measurements