HTML char Attribute

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

Definition and Usage

The char attribute belonged on table cells such as <td> and <th>. It was meant to name the character that text should align on when align="char" — commonly a period (.) for decimals or currency.

Do not use it. MDN states that char does nothing. Prefer CSS text-align. Related charoff (offset from that character) also does nothing.

Deprecated · No effect.

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

Needed align="char".

Even historically, char was ignored unless align was set to char. Both attributes are deprecated.

HTML Syntax

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

Historical form only. Modern browsers do not perform character alignment from these attributes.

Attribute Values

Intended values and what to use instead:

Value / approachDescriptionTry it
.Typical intent: align on the decimal pointTry it
,Locales that use a comma as the decimal separatorTry it
: or otherAny single alignment character (never reliably rendered)Try it
CSS text-alignModern: left, right, center, justifyTry it
Practical decimalsRight-align, fixed decimals, or tabular numbersTry it

Live Preview

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

Legacy markup only. Modern browsers ignore char.

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

char="." — no visual change in modern browsers.

HTML Examples

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

Example 1 — Legacy align="char" (Do Not Ship)

How authors once requested decimal alignment. Expect no effect today.

HTML
<table border="1">
  <tr>
    <th>Item</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>Book</td>
    <td align="char" char=".">19.99</td>
  </tr>
  <tr>
    <td>Pen</td>
    <td align="char" char=".">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 (the decimal point).
  3. Browsers ignore it — MDN: the attribute does nothing.
  4. Deprecated. Do not copy into new templates.

Example 2 — Modern CSS text-align

Align columns with CSS instead of presentational attributes.

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 from the HTML.
  2. Use text-align: right (or left / center) on the column.
  3. Format values consistently (e.g. always two decimals) so columns look neat.
  4. Presentation stays in CSS — HTML stays semantic.

Example 3 — Neater Number Columns

Practical tips when you wanted “align on the decimal” historically.

HTML
<style>
  table.ledger {
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
  }
  table.ledger th,
  table.ledger td {
    border: 1px solid #888;
    padding: 0.35rem 0.6rem;
  }
  table.ledger td.amount {
    text-align: right;
    font-family: ui-monospace, monospace;
  }
</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 numeric columns so magnitudes line up visually.
  2. Same decimal places in the data (e.g. 3.50 not 3.5).
  3. tabular-nums / monospace keep digit widths steady.
  4. No char attribute — CSS and formatting do the job browsers never did for char.

Edge Cases & Pitfalls

The main pitfall is expecting char to change the layout.

deprecated

Does nothing

MDN is explicit: char has no effect. Do not debug “broken alignment” by tweaking it.

pair

Ignored without align="char"

Historically required. Today both attributes are obsolete — use CSS instead of restoring the pair.

charoff

charoff is also inert

The offset companion was never useful in practice. Skip both.

i18n

Decimal characters vary

Some locales use , instead of .. Formatting and CSS remain clearer than a dead HTML attribute.

css

True char alignment is rare

Even CSS never made “align on this character” a everyday feature. Prefer right-align and consistent number formatting.

Browser Support

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

✓ Deprecated · No effect

char

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

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

Bottom line: Treat every char= in old HTML as a no-op. Align columns with CSS.

Key Takeaways

  • Was: name a character for align="char" (often .).
  • Now: deprecated and inert — browsers do not align on it.
  • Replace with: CSS text-align plus consistent number formatting.
  • charoff: companion attribute — also does nothing.

One line: learn char to recognize old tables — ship CSS alignment instead.

Frequently Asked Questions

It was meant to name the character that table cell text should align on when align="char" — often a period (.) for decimal numbers.
No. MDN states that char does nothing. It is deprecated and was never reliably implemented for real layouts.
Historically td, th, and related table grouping elements that supported align. It was ignored unless align was set to char.
A companion deprecated attribute that was meant to offset content from the alignment character. MDN also says charoff does nothing.
Use CSS text-align (left, right, center, or justify). For money or decimals, format numbers consistently, use tabular figures, or right-align the column.
No. Both align and char are deprecated presentational attributes. Prefer CSS.

Next: charoff

The companion offset attribute — also deprecated and without effect.

charoff 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