The char attribute is a legacy HTML table attribute used with align="char" to specify a single character on which cell content should align. It was designed so numeric columns could line up on a decimal point or other delimiter, making tabular data easier to scan.
What You’ll Learn
01
One character
Usually ..
02
With align
align="char".
03
Table cells
td, th.
04
charoff
Offset partner.
05
setAttribute
JS dynamic.
06
Deprecated
Use CSS.
Fundamentals
Purpose of char Attribute
The primary purpose of the char attribute is to define which character acts as the alignment anchor when align="char" is set on a table cell or column. This lets numbers in a column share a common vertical alignment point—most often the decimal point—so values like 12.5, 9.75, and 100.2 read cleanly in financial or scientific tables.
💡
Not for list bullets
char is a table attribute. It does not customize bullet points or list markers in <ul> or <ol> lists. Use CSS list-style-type for that.
Foundation
📝 Syntax
Add align="char" and char together on a table cell or header:
char.html
<tdalign="char"char=".">12.5</td>
Syntax Rules
Must be used with align="char" on the same element.
Value is a single character, such as . (decimal), ,, or $.
Applies to table elements: td, th, tr, col, and related table sections.
Pair with charoff to shift the alignment position by pixels.
For modern layouts, use CSS text-align: right and font-variant-numeric: tabular-nums.
Reference
💎 Values
The char attribute accepts a single character value. The character defines the alignment anchor when align="char" is active. Common choices include:
. — Decimal point alignment for numeric scores, prices, or measurements.
, — Thousands separator alignment in locale-specific number formats.
$ or € — Currency symbol alignment in financial tables.
In this example, each score cell uses align="char" with char=".". The browser is instructed to align content on the decimal point so numeric values in the Score column share a common alignment anchor.
Dynamic Values with JavaScript
You can dynamically set the char attribute using JavaScript, which is useful when building tables from data at runtime:
index.html
<thid="scoreHeader">Score</th><script>// Select the header cell
let scoreHeader = document.getElementById("scoreHeader");
// Dynamically add char alignment
scoreHeader.setAttribute("align", "char");
scoreHeader.setAttribute("char", ".");
</script>
In this script, the header cell with id scoreHeader receives align="char" and char="." at runtime via setAttribute. Both attributes must be set for character alignment to apply.
A11y
♿ Accessibility
Alignment aids comprehension — Well-aligned numeric columns help all users compare values quickly.
Do not rely on char alone — Screen readers read cell text, not visual alignment. Use clear headers and captions.
Prefer semantic tables — Use <th scope="col"> for column headers so assistive tech understands structure.
Use CSS for reliable layout — Since char is deprecated, CSS alignment is more predictable across browsers.
Test with real data — Ensure mixed-length numbers remain readable on small screens.
🧠 How char Works
1
Author sets align and char
Add align="char" and a single-character char value on table cells.
Markup
2
Browser finds anchor character
The layout engine locates the specified character in each cell’s text content.
Parsing
3
Cells align on that point
Content in the column shares a vertical alignment line at the chosen character.
Layout
=
📊
Aligned numeric column
In modern projects, CSS text-align and font-variant-numeric replace char.
Compatibility
Browser Support
The char attribute is deprecated in HTML5. Most modern browsers no longer apply visible character alignment, even though legacy markup may still parse.
⚠️ HTML4 legacy · Deprecated
Limited modern rendering
Use CSS text-align: right and font-variant-numeric: tabular-nums for numeric columns.
LegacyLimited support
Google ChromeAttribute parsed
Deprecated
Mozilla FirefoxAttribute parsed
Deprecated
Apple SafariAttribute parsed
Deprecated
Microsoft EdgeAttribute parsed
Deprecated
char attributeDeprecated
Bottom line: Learn char for legacy HTML tables, but use CSS alignment for new numeric columns.
Pro Tips
💡 Best Practices
✅ Do
Use CSS text-align: right for numeric columns
Pair char with align="char" when reading legacy markup
Use font-variant-numeric: tabular-nums for even digit width
Apply alignment consistently across an entire column
Document deprecated attributes when maintaining old tables
❌ Don’t
Use char on list elements (ul, ol, li)
Expect visible alignment in all modern browsers
Omit align="char" when setting char
Rely on char for responsive financial dashboards
Confuse char with the unrelated charset attribute
Use the char attribute sparingly and only when maintaining legacy table markup.
Ensure the character you choose is meaningful and present in the cell content (e.g., a decimal point in numeric values).
Test table appearance across browsers, since character alignment support varies widely in modern engines.
Wrap Up
Conclusion
The char attribute provides a way to align table cell content on a specific character when combined with align="char". It was especially useful for decimal-aligned numeric columns in legacy HTML documents.
For modern development, CSS properties such as text-align and font-variant-numeric deliver reliable numeric column formatting. Learn char to understand older markup, then prefer CSS in new projects.