HTML char Attribute

Beginner
⏱️ 4 min read
📚 Updated: Jun 2026
🎯 2 Examples
Tables & Layout

Introduction

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.

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.

📝 Syntax

Add align="char" and char together on a table cell or header:

char.html
<td align="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.

💎 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.
  • : — Time values such as 9:30 or 12:05.
char-values.html
<th align="char" char=".">Score</th>
<td align="char" char=".">12.5</td>
<td align="char" char=".">100.2</td>

<!-- CSS alternative -->
<style>
  .numeric { text-align: right; font-variant-numeric: tabular-nums; }
</style>

⚡ Quick Reference

AttributePurposeCSS Alternative
char="."Align on decimal pointtext-align: right; font-variant-numeric: tabular-nums;
align="char"Enables char alignmentRequired partner attribute
charoffPixel offset from charPadding or CSS positioning
Elementstd, th, col, etc.Style cells or columns
Value typeSingle characterN/A (CSS has no direct char anchor)
HTML5 statusDeprecatedUse CSS for new code

Applicable Elements

ElementSupported?Notes
<td>, <th>Yes (legacy)Most common use: numeric cell columns
<col>, <colgroup>Yes (legacy)Apply alignment to entire columns
<tr>, <tbody>, <thead>, <tfoot>Yes (legacy)Inherited by descendant cells in older specs
<ul>, <ol>, <li>NoNot a list attribute
<div>NoTable-only legacy attribute

Examples Gallery

Implementation example with decimal char alignment and dynamic JavaScript setAttribute.

👀 Live Preview

Score column with align="char" and char="." (visual effect may vary in modern browsers):

NameScore
Alice12.5
Bob9.75
Carol100.2

Modern browsers may not visibly align on the character. Use CSS text-align: right for reliable numeric columns.

Implementation Example

Let’s look at a simple example of how to use the char attribute in an HTML table:

index.html
<table border="1">
  <tr>
    <th>Name</th>
    <th align="char" char=".">Score</th>
  </tr>
  <tr>
    <td>Alice</td>
    <td align="char" char=".">12.5</td>
  </tr>
  <tr>
    <td>Bob</td>
    <td align="char" char=".">9.75</td>
  </tr>
  <tr>
    <td>Carol</td>
    <td align="char" char=".">100.2</td>
  </tr>
</table>
Try It Yourself

How It Works

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
<th id="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>
Try It Yourself

How It Works

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.

♿ 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.

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.

Legacy Limited support
Google Chrome Attribute parsed
Deprecated
Mozilla Firefox Attribute parsed
Deprecated
Apple Safari Attribute parsed
Deprecated
Microsoft Edge Attribute parsed
Deprecated
char attribute Deprecated

Bottom line: Learn char for legacy HTML tables, but use CSS alignment for new numeric columns.

💡 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.

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.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about char

Bookmark these before working with legacy HTML tables.

5
Core concepts
📝 02

With align

align="char".

Syntax
03

One char

Often ..

Values
⚙️ 04

setAttribute

JS dynamic.

Script
⚠️ 05

Deprecated

Use CSS.

Modern

❓ Frequently Asked Questions

It specifies a single character on which cell content aligns when used with align="char".
No. char is a table attribute for td, th, and related table elements—not for ul or ol list markers.
A period (.) is commonly used to align decimal numbers in a column.
It is deprecated. Modern browsers may not render character alignment visibly. Use CSS instead.
Call element.setAttribute("align", "char") and element.setAttribute("char", ".") on the target cell.
td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

Align table cells on a character

Practice the legacy char attribute with decimal-aligned score columns and compare it with modern CSS numeric formatting.

Try table example →

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.

5 people found this page helpful