HTML rules Attribute

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

Definition and Usage

The rules attribute on <table> chose which internal borders (rules) to draw between cells or groups. Values: none (default), groups, rows, cols, and all.

MDN lists rules as deprecated. Authors must not use it. Style borders with CSS on the table and cells instead — often with border-collapse: collapse. Related legacy attributes: frame (outer sides) and border.

Deprecated / obsolete.

Do not ship rules on new pages. Recognize it in old markup, then replace with CSS border rules.

HTML Syntax

syntax.html
<!-- obsolete --> <table rules=" none|groups|rows|cols|all">
<!-- modern --> CSS borders on table / th / td

Legacy IDL: table.rules = "all" — do not use in new code.

Attribute Values

Historical meanings and the CSS approach:

ValueLegacy meaningModern CSS ideaTry it
noneNo internal rules (default)No cell borders (or only outer frame)Try it
rowsHorizontal lines between rowsborder-top / border-bottom on cellsTry it
colsVertical lines between columnsborder-left / border-right on cellsTry it
groupsLines between row/column groupsBorders on thead / tbody / colgroupTry it
allRules around every cellth, td { border: 1px solid … }Try it

Live Preview

Pick a legacy rules value. The demo uses CSS to show the intended look (reliable). The attribute itself is obsolete.

CSS simulation of what each rules value meant. Prefer CSS in production.

table
ItemQty
Apples4
Milk2

CSS stand-in for rules="all"

HTML Examples

Legacy vs modern. Prefer the CSS snippets for real projects.

Example 1 — rules="all" → CSS cell borders

Every cell gets a border. Use CSS, not the attribute.

HTML
<!-- obsolete -->
<table rules="all" border="1">…</table>

<!-- modern -->
<table class="grid">
  <tr><th scope="col">Name</th><th scope="col">Score</th></tr>
  <tr><td>Ada</td><td>95</td></tr>
</table>

<style>
  .grid { border-collapse: collapse; }
  .grid th, .grid td { border: 1px solid #333; padding: 0.35rem 0.5rem; }
</style>
Try It Yourself

How It Works

  1. Legacy: rules="all" asked for lines between every cell.
  2. Modern: put border on th / td.
  3. border-collapse joins adjacent borders cleanly.
  4. Drop rules and prefer CSS for control and consistency.

Example 2 — Rows-only or cols-only lines

Match old rows / cols with directional borders.

HTML
<!-- CSS stand-in for rules="rows" -->
<style>
  .rows-only { border-collapse: collapse; }
  .rows-only th, .rows-only td {
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    padding: 0.35rem 0.5rem;
  }
</style>
<table class="rows-only">
  <tr><th scope="col">A</th><th scope="col">B</th></tr>
  <tr><td>1</td><td>2</td></tr>
</table>
Try It Yourself

How It Works

  1. rules="rows" meant horizontal separators only.
  2. Top/bottom borders on cells recreate that look.
  3. rules="cols" maps to left/right borders instead.
  4. Same HTML — only CSS changes the pattern.

Example 3 — Group separators

Emulate rules="groups" with section borders on thead / tbody.

HTML
<style>
  .groups { border-collapse: collapse; border: 1px solid #333; }
  .groups th, .groups td { padding: 0.35rem 0.5rem; }
  .groups thead { border-bottom: 2px solid #333; }
</style>
<table class="groups">
  <thead>
    <tr><th scope="col">Item</th><th scope="col">Qty</th></tr>
  </thead>
  <tbody>
    <tr><td>Apples</td><td>4</td></tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. groups drew lines between thead / tbody / tfoot (and col groups).
  2. Border on thead separates the header from body data.
  3. No per-cell grid unless you add more CSS.
  4. Clearer than relying on obsolete rules.

Edge Cases & Pitfalls

Most issues are using rules in new HTML or confusing it with frame / border.

deprecated

Validators flag rules

Remove it when you touch legacy tables; restyle with CSS.

frame

rules ≠ frame

Internal lines vs outer sides — both deprecated; both → CSS.

border

HTML border on table is also legacy

Prefer the CSS border property on the elements you need.

ua

Rendering was never identical everywhere

Another reason CSS is the reliable path for borders.

Browser Support

rules is a deprecated HTML attribute on <table>. Do not use it in new projects.

✓ Deprecated — use CSS

rules

Legacy recognition varies. Style tables with CSS borders for consistent results.

N/A Authoring status
Google Chrome Legacy*
Prefer CSS
Mozilla Firefox Legacy*
Prefer CSS
Apple Safari Legacy*
Prefer CSS
Microsoft Edge Legacy*
Prefer CSS
Opera Legacy*
Prefer CSS
Samsung Internet Legacy*
Prefer CSS
Internet Explorer Yes
Legacy support
rules Deprecated

Bottom line: *May still parse for old pages. New tables: CSS only — never add rules.

Key Takeaways

  • Was: internal table border modes on <table>.
  • Values: none, groups, rows, cols, all.
  • Now: CSS border + border-collapse.
  • Related legacy: frame, HTML border — also CSS now.

One line: rules was for internal table lines — deprecated; use CSS borders.

Frequently Asked Questions

On table, rules chose which internal borders (rules) to draw: none, groups, rows, cols, or all. Default was none.
No. MDN lists it as deprecated. Style table borders with CSS (border, border-collapse) instead.
Use border-collapse: collapse and set border on th/td (and optionally on the table).
rules controlled internal lines between cells or groups. frame controlled which sides of the outer table frame were shown. Both are deprecated — use CSS.
Draw lines between row groups (thead, tbody, tfoot) and column groups (colgroup), not between every cell.
Support is uneven and not something to rely on. New pages should use CSS only.

Next: sandbox

Restrict iframe capabilities with the sandbox attribute.

sandbox 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