HTML charoff Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The charoff attribute belonged on table cells such as <td> and <th>. It was meant to offset content by a number of characters from the alignment character set by char, when align="char".

Do not use it. MDN states that charoff does nothing. Prefer CSS text-align for alignment and padding when you need spacing.

Deprecated · No effect.

Presentational HTML that was never reliably implemented. Documented for reading legacy markup only — not for new pages.

Part of a trio.

Historically needed align="char" plus char. All three are deprecated; none of them drive modern layout.

HTML Syntax

syntax.html
<td|th align="char" char="." charoff=" offset">

Historical form only. Modern browsers do not apply a character offset from this attribute.

Attribute Values

Intended values and what to use instead:

Value / approachDescriptionTry it
0, 2, 5…Intended character count offset from charTry it
Signed offsetSome older docs allowed a leading + / - directionTry it
CSS text-alignModern: horizontal alignment without char / charoffTry it
CSS paddingReal spacing control instead of a character offsetTry it

Live Preview

Change the legacy charoff value. Expect no layout change — that is the lesson.

Legacy markup only. Modern browsers ignore charoff.

Amount column
ItemAmount
Tea12.50
Cake3.5
Tax1.25

charoff="0" — no visual change in modern browsers.

HTML Examples

Example 1 is historical. Examples 2–3 show practical CSS replacements.

Example 1 — Legacy charoff (Do Not Ship)

How authors once requested an offset from the alignment character. Expect no effect today.

HTML
<table border="1">
  <tr>
    <th>Item</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>Book</td>
    <td align="char" char="." charoff="2">19.99</td>
  </tr>
  <tr>
    <td>Pen</td>
    <td align="char" char="." charoff="2">2.5</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. align="char" was supposed to enable character alignment.
  2. char="." named the alignment character.
  3. charoff="2" was meant to offset by two characters from that point.
  4. Browsers ignore it — MDN: the attribute does nothing. Deprecated.

Example 2 — Modern CSS text-align

Align columns with CSS instead of align / char / charoff.

HTML
<style>
  table.prices {
    border-collapse: collapse;
  }
  table.prices th,
  table.prices td {
    border: 1px solid #888;
    padding: 0.35rem 0.6rem;
  }
  table.prices td.num {
    text-align: right;
  }
</style>

<table class="prices">
  <tr>
    <th>Item</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>Book</td>
    <td class="num">19.99</td>
  </tr>
  <tr>
    <td>Pen</td>
    <td class="num">2.50</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Drop align, char, and charoff from the HTML.
  2. Use text-align: right (or left / center) on the column.
  3. Format numbers consistently so the column looks neat.
  4. Presentation stays in CSS — HTML stays semantic.

Example 3 — Spacing with CSS padding

When you wanted an “offset,” use real spacing — not a character count attribute.

HTML
<style>
  table.ledger {
    border-collapse: collapse;
  }
  table.ledger th,
  table.ledger td {
    border: 1px solid #888;
    padding: 0.35rem 0.6rem;
  }
  table.ledger td.amount {
    text-align: right;
    padding-right: 1.5rem;
  }
</style>

<table class="ledger">
  <tr>
    <th>Item</th>
    <th>Amount</th>
  </tr>
  <tr>
    <td>Tea</td>
    <td class="amount">12.50</td>
  </tr>
  <tr>
    <td>Cake</td>
    <td class="amount">3.50</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Right-align the numeric column with text-align.
  2. Add padding-right when you need visual inset — a real length, not a character offset.
  3. No charoff — CSS spacing is predictable across browsers.
  4. Keep values formatted (e.g. two decimals) for a clean column.

Edge Cases & Pitfalls

The main pitfall is expecting charoff to move text.

deprecated

Does nothing

MDN is explicit: charoff has no effect. Changing the number will not fix “broken” alignment.

pair

Depends on dead siblings

It only made sense with align="char" and char. All three are obsolete — migrate to CSS.

dom

DOM may still expose it

Some engines map a chOff-style property for compatibility. That does not mean layout changes.

css

Offset ≠ padding

A “character offset” was never a substitute for CSS spacing. Use padding / margin for inset.

cleanup

Safe to delete

When modernizing old tables, remove charoff (and char / presentational align) without changing appearance.

Browser Support

charoff is a deprecated HTML attribute. Engines may parse it, but they do not implement a character offset.

✓ Deprecated · No effect

charoff

Documented as doing nothing. Not recommended for new work — use CSS text-align and padding.

0% Useful browser behavior
Google Chrome Parses · no offset
No effect
Mozilla Firefox Parses · no offset
No effect
Apple Safari Parses · no offset
No effect
Microsoft Edge Parses · no offset
No effect
Opera Parses · no offset
No effect
Internet Explorer Legacy / incomplete
No effect
charoff Deprecated — no layout effect

Bottom line: Treat every charoff= in old HTML as a no-op. Align and space cells with CSS.

Key Takeaways

  • Was: offset from the char alignment character (with align="char").
  • Now: deprecated and inert — browsers do not apply the offset.
  • Replace with: CSS text-align and padding as needed.
  • char: companion attribute — also does nothing. See the char tutorial.

One line: learn charoff to recognize old tables — ship CSS alignment and spacing instead.

Frequently Asked Questions

It was meant to offset table cell content by a number of characters from the alignment character named by char, when align was set to char.
No. MDN states that charoff does nothing. It is deprecated and was never reliably implemented.
char named the alignment character (often "."). charoff was supposed to shift content left or right from that character. Both are inert today.
Historically a length — typically an integer character count, sometimes with a percentage form in older docs. None of that changes layout now.
Use CSS text-align for horizontal alignment. Use padding or margin when you need spacing, not a character offset attribute.
Safe to remove when modernizing. Leaving it does not help layout; prefer CSS.

Next: charset

Declare the character encoding for your document — still essential today.

charset tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful