Home HTML Attributes charoff HTML charoff Attribute Definition
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.
Syntax
HTML Syntax <td|th align="char" char="." charoff=" offset ">
Historical form only. Modern browsers do not apply a character offset from this attribute.
Values
Attribute Values Intended values and what to use instead:
Value / approach Description Try it 0, 2, 5…Intended character count offset from char Try itSigned offset Some older docs allowed a leading + / - direction Try itCSS text-align Modern: horizontal alignment without char / charoff Try itCSS padding Real spacing control instead of a character offset Try it
Try it
Live Preview Change the legacy charoff value. Expect no layout change — that is the lesson.
Code
HTML Examples Example 1 is historical. Examples 2–3 show practical CSS replacements.
1. Legacy charoff 2. CSS text-align 3. CSS padding Example 1 — Legacy charoff (Do Not Ship) How authors once requested an offset from the alignment character. Expect no effect today.
<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> Looks like a normal table — charoff does not shift content in modern browsers.
How It Works align="char" was supposed to enable character alignment.char="." named the alignment character.charoff="2" was meant to offset by two characters from that point.Browsers ignore it — MDN: the attribute does nothing. Deprecated.Example 2 — Modern CSS text-align Align columns with CSS instead of align / char / charoff.
<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> Open Try It Yourself to see right-aligned prices with CSS.
How It Works Drop align, char, and charoff from the HTML.Use text-align: right (or left / center) on the column.Format numbers consistently so the column looks neat.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.
<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 shows right align plus extra padding-right.
How It Works Right-align the numeric column with text-align.Add padding-right when you need visual inset — a real length, not a character offset.No charoff — CSS spacing is predictable across browsers.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.
Compatibility
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.
Remember
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 What was the HTML charoff attribute for? 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.
Does charoff do anything in browsers today? No. MDN states that charoff does nothing. It is deprecated and was never reliably implemented.
How does charoff relate to char? char named the alignment character (often "."). charoff was supposed to shift content left or right from that character. Both are inert today.
What values did charoff take? Historically a length — typically an integer character count, sometimes with a percentage form in older docs. None of that changes layout now.
What should I use instead? Use CSS text-align for horizontal alignment. Use padding or margin when you need spacing, not a character offset attribute.
Should I keep charoff in old tables? 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 Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion