The charoff attribute is used in HTML to specify the offset of the alignment character in a table cell. It works together with align="char" and the char attribute to fine-tune where content aligns relative to a chosen character—such as shifting decimal-aligned numbers a few pixels from the decimal point.
What You’ll Learn
01
Offset
Pixels or %.
02
With char
Partner attr.
03
align char
Required pair.
04
Table cells
td, th.
05
charOff
DOM property.
06
Deprecated
Use CSS.
Fundamentals
Purpose of charoff Attribute
The primary purpose of the charoff attribute is to adjust the horizontal position of text aligned on a character within a table cell. After you choose an alignment character with char, charoff moves the alignment point by a specified number of pixels or a percentage of the cell width. This helps fine-tune the visual presentation of tabular data in legacy HTML documents.
💡
Requires align="char" and char
charoff only has meaning when used with align="char" and a char value. It does not replace left, center, or right alignment on its own.
Foundation
📝 Syntax
Add charoff alongside align="char" and char on a table cell:
charoff.html
<tdalign="char"char="."charoff="10">12.5</td>
Syntax Rules
Use with align="char" and char on the same element.
Value is a length in pixels (e.g. 10) or a percentage (e.g. 5%).
Positive values offset from the left side of the cell toward the alignment character.
Applies to table elements: td, th, col, and related sections.
For modern layouts, use CSS padding or text-align instead.
Reference
💎 Values
The charoff attribute accepts numerical values to determine the offset from the alignment character. The most common value types include:
Pixels — A plain number such as 10 means 10 pixels of offset.
Percentage — A value like 5% offsets by a percentage of the cell’s width.
In this example, the first <td> uses align="char", char=".", and charoff="10". The browser aligns content on the decimal point and then applies a horizontal offset of 10 pixels from that alignment position.
Dynamic Values with JavaScript
You can also dynamically set the charoff attribute using JavaScript. This can be useful when you want to adjust the alignment offset based on user interactions or other dynamic factors:
index.html
<tdid="dynamicCell"align="char"char=":">Value: 100:200</td><script>// Dynamically set charoff for a table cell
document.getElementById("dynamicCell").charOff = "5%";
</script>
In this script, the charOff property of the cell with id dynamicCell is set to 5%, shifting the alignment offset by five percent of the cell width. Note the capital O in the DOM property name charOff.
A11y
♿ Accessibility
Offset is visual only — Screen readers announce cell text, not charoff positioning.
Use clear headers — Pair aligned columns with <th scope="col"> labels.
Do not rely on charoff — Since support is deprecated, use CSS for layouts users depend on.
Keep content readable — Large offsets can push text awkwardly on narrow screens.
Test with real data — Verify numeric columns remain scannable without charoff rendering.
🧠 How charoff Works
1
Author sets char trio
Add align="char", char, and charoff on a table cell.
Markup
2
Browser finds char point
The layout engine locates the alignment character in the cell content.
Parsing
3
Offset is applied
charoff shifts the alignment position by pixels or a percentage.
Layout
=
📊
Fine-tuned column alignment
In modern projects, CSS padding and text-align replace charoff.
Compatibility
Browser Support
The charoff attribute is deprecated in HTML5. Most modern browsers no longer apply visible character offsets, even though legacy markup may still parse.
⚠️ HTML4 legacy · Deprecated
Limited modern rendering
Use CSS padding and text-align for reliable table cell positioning.
LegacyLimited support
Google ChromeAttribute parsed
Deprecated
Mozilla FirefoxAttribute parsed
Deprecated
Apple SafariAttribute parsed
Deprecated
Microsoft EdgeAttribute parsed
Deprecated
charoff attributeDeprecated
Bottom line: Learn charoff for legacy HTML tables, but use CSS padding and alignment for new numeric columns.
Pro Tips
💡 Best Practices
✅ Do
Always pair charoff with align="char" and char
Use CSS padding for offset control in new tables
Experiment with small pixel values when reading legacy markup
Document deprecated attributes in maintained codebases
Test tables across browsers when charoff is required
❌ Don’t
Use charoff alone without align="char" and char
Expect visible offset in all modern browsers
Confuse charoff with the unrelated charset attribute
Use charoff for general left/center/right alignment
Rely on charoff for responsive financial dashboards
Use the charoff attribute sparingly and only when necessary to adjust alignment of text within table cells.
Experiment with different charoff values to achieve the desired visual presentation of tabular data in legacy documents.
Test your tables across different browsers to ensure consistent alignment behavior.
Wrap Up
Conclusion
The charoff attribute provides a means to adjust the horizontal offset of character-aligned text within HTML table cells. Used with align="char" and char, it offered fine-grained control over numeric and delimited column formatting in legacy HTML.
For modern development, CSS padding, text-align, and font-variant-numeric deliver reliable results. Learn charoff to understand older markup, then prefer CSS in new projects.