Easy Tutorial
❮ Prop Style Flex Prop Style Textoverflow ❯

td/thch Attribute


Definition and Usage

The ch attribute sets or returns the alignment character for the cell.

All cells in the same column are aligned based on this character.

Syntax

Set ch attribute:

Return ch attribute:

Note The property attribute has no default value.


Browser Support

All major browsers support the ch attribute. However, no major browsers implement the functionality of this attribute.


Example

Align the "Savings" column with the "." character:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>tutorialpro.org(tutorialpro.org)</title> 
<script>
function displayResult(){
    var c=document.getElementById("myCol");
    alert("The alignment character for the second column is: " + c.ch);
}
</script>
</head>
<body>

<table border="1">
    <colgroup>
        <col>
        <col id="myCol" align="char" char=".">
      </colgroup>
      <tr>
        <th>Month</th>
        <th>Savings</th>
      </tr>
      <tr>
        <td>January</td>
        <td>$100.00</td>
      </tr>
      <tr>
        <td>February</td>
        <td>$10.00</td>
      </tr>
</table>
<br> 
<button type="button" onclick="displayResult()">Get Alignment Character</button>
<p><b>Note:</b> Not all major browsers support the `char` attribute.</p>

</body>
</html>

❮ Prop Style Flex Prop Style Textoverflow ❯