HTML rules Attribute

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

Introduction

The rules attribute on <table> once controlled which internal grid lines were drawn — between rows, columns, groups, or all cells. Values include none, rows, cols, groups, and all. Important: rules is obsolete in HTML5 and modern browsers often ignore it. Use CSS borders on th and td instead. This tutorial explains rules for reading legacy HTML and understanding how it differs from validation “rules” in other technologies.

What You’ll Learn

01

Internal borders

Grid lines.

02

table only

Scope.

03

5 values

none to all.

04

Obsolete

HTML5.

05

.rules

Legacy JS.

06

Use CSS

Modern way.

Purpose of rules Attribute

In HTML 4, the rules attribute let authors choose which internal borders appeared inside a table — horizontal lines only (rows), vertical only (cols), lines between row/column groups (groups), every cell edge (all), or none at all (none).

It was often used together with the legacy border attribute on <table> to control the outer frame versus inner grid lines. Today, CSS gives full control over table borders with predictable results across browsers.

⚠️
Obsolete — use CSS in new projects

Do not rely on rules for production table styling. Use border-collapse: collapse and cell borders in CSS instead.

📝 Syntax

Legacy syntax on <table> (historical reference):

rules.html
<table border="1" rules="rows">
  <thead>...</thead>
  <tbody>...</tbody>
</table>

<!-- Modern equivalent -->
<table class="data-table">...</table>

Syntax Rules

  • Valid only on <table> elements.
  • Value is one of: none, groups, rows, cols, all.
  • Default is none when omitted.
  • Historically paired with border and frame on the same table.
  • groups expects structural groups like thead, tbody, colgroup.
  • JavaScript: tableElement.rules = "cols" (string property).
  • Not related to JSON Schema rules or form validation logic.

💎 Values

The rules attribute accepts these keyword values:

  • rules="none" — No internal borders (default).
  • rules="rows" — Borders between rows only.
  • rules="cols" — Borders between columns only.
  • rules="groups" — Borders between row groups and column groups.
  • rules="all" — Borders between all rows and columns.
rules-values.html
<table rules="rows">...</table>   <!-- horizontal lines -->
<table rules="cols">...</table>   <!-- vertical lines -->
<table rules="all">...</table>    <!-- full grid -->
<table rules="groups">...</table> <!-- group separators -->

How it Works

With rules="rows", the browser was meant to draw horizontal dividers between table rows. In modern browsers this effect is unreliable or absent — CSS achieves the same result consistently.

⚡ Quick Reference

ValueLegacy effectToday
noneNo internal linesDefault; use CSS if needed
rowsHorizontal dividersCSS border-bottom on tr/td
colsVertical dividersCSS border-right on cells
groupsBetween thead/tbody/colgroupCSS on group sections
allFull internal gridCSS border + border-collapse
table.rulesJS string propertyLittle visual effect now

Applicable Elements

ElementSupports rules?Notes
<table>Yes (legacy)Only standard element for rules
<td>, <th>NoStyle cells with CSS borders
<textarea>NoUse rows for textarea height
<form>NoNot a form validation attribute

Legacy rules vs modern CSS

GoalLegacy HTMLModern CSS
Row dividersrules="rows"td { border-bottom: 1px solid #cbd5e1; }
Column dividersrules="cols"td { border-right: 1px solid #cbd5e1; }
Full gridrules="all"table { border-collapse: collapse; } td, th { border: 1px solid #cbd5e1; }
Outer frame onlyframe + bordertable { border: 1px solid #cbd5e1; }
Browser supportInconsistent / ignoredReliable everywhere

Examples Gallery

Legacy rules="rows" markup, dynamic table.rules in JavaScript, and the modern CSS border replacement.

👀 Live Preview

Table styled with CSS (the reliable modern approach). Legacy rules may not render in your browser:

NameAge
John30
Jane25

Use CSS borders instead of obsolete rules for production tables.

Example — rules="rows" (legacy)

Historical markup for horizontal internal borders:

rules-rows.html
<table border="1" rules="rows">
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>30</td>
    </tr>
    <tr>
      <td>Jane</td>
      <td>25</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

rules="rows" was intended to show horizontal lines between rows only. Modern browsers often render all borders from border="1" instead, or no special rules styling at all.

Dynamic Values with JavaScript

Legacy DOM property table.rules:

dynamic-rules.html
<table id="dynamicTable" border="1">...</table>

<script>
  document.getElementById("dynamicTable").rules = "cols";
</script>
Try It Yourself

How It Works

table.rules = "cols" was meant to switch to column-only dividers. For dynamic styling today, toggle CSS classes on the table instead.

Example — Modern CSS replacement

Achieve reliable row borders with CSS:

css-table-borders.html
<style>
  .data-table {
    border-collapse: collapse;
    width: 100%;
    max-width: 360px;
  }
  .data-table th,
  .data-table td {
    border: 1px solid #cbd5e1;
    padding: 0.55rem 0.75rem;
    text-align: left;
  }
  .data-table th {
    background: #f1f5f9;
  }
</style>

<table class="data-table">
  <thead>
    <tr><th>Name</th><th>Age</th></tr>
  </thead>
  <tbody>
    <tr><td>John</td><td>30</td></tr>
    <tr><td>Jane</td><td>25</td></tr>
  </tbody>
</table>
Try It Yourself

How It Works

CSS border-collapse: collapse plus cell borders gives you full control — the correct approach for all new table designs.

♿ Accessibility

  • Borders aid readability — Visible grid lines help sighted users track rows; achieve this with CSS, not obsolete rules.
  • Do not rely on rules — Assistive technology does not expose rules semantics.
  • Use table headers — Pair styled tables with <th> and scope for screen readers.
  • Add a caption<caption> describes the table purpose.
  • Contrast matters — Ensure border colors meet contrast guidelines when they carry meaning.

🧠 How rules Worked

1

Author sets rules

Pick rows, cols, all, groups, or none.

Markup
2

Browser drew grid

Internal lines per keyword (HTML 4).

Legacy UA
3

HTML5 obsoletes it

Presentational attrs dropped.

HTML5
=

Use CSS borders

Reliable styling today.

Browser Support

The rules attribute is obsolete. Browsers may still parse it in the DOM, but it has little or no visual effect in modern user agents.

⚠️ Obsolete · Use CSS instead

rules is legacy only

Style table borders with CSS for consistent cross-browser results.

~10% Practical support
Modern browsers Often ignored
Obsolete
DOM property May still exist
No effect
CSS borders Fully supported
Use instead
rules attribute (visual use) Obsolete

Bottom line: Learn rules for legacy HTML — style tables with CSS in all new projects.

💡 Best Practices

✅ Do

  • Use CSS border-collapse and cell borders for table grids
  • Learn rules only when reading old HTML 4 tables
  • Replace legacy rules with CSS when refactoring sites
  • Use thead, tbody, and th scope for structure
  • Read the <table> tag guide for modern patterns

❌ Don’t

  • Add rules to new table markup
  • Expect consistent borders from rules across browsers
  • Confuse table rules with form or JSON validation rules
  • Rely on border="1" alone for production design
  • Forget accessibility when styling borders for readability

Conclusion

The rules attribute once controlled internal table border lines with keywords like rows, cols, and all.

It is obsolete in HTML5. For every practical purpose today, use CSS to style table borders with full control and reliable browser support.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about rules

Bookmark these when reading legacy tables.

5
Core concepts
🔢 02

5 keywords

none to all.

Values
03

Obsolete

HTML5.

Status
🎨 04

Use CSS

Modern fix.

Today
🚫 05

Not validation

Not JSON rules.

Gotcha

❓ Frequently Asked Questions

It specified which internal borders to draw inside a table — between rows, columns, groups, or all cells. It is obsolete today.
No. rules is obsolete. Use CSS borders on table cells instead.
none (default), groups, rows, cols, and all.
No. HTML rules is a legacy table presentation attribute. Form validation and JSON Schema “rules” are unrelated concepts.
tableElement.rules = "rows" — the property exists but rarely changes appearance in modern browsers.
CSS: border-collapse: collapse on the table and border on th and td elements.

Learn legacy tables, build with CSS

Understand obsolete rules markup, then style borders with CSS for reliable table layouts.

Try CSS borders →

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.

3 people found this page helpful