Cursor rule
.cursor/rules/table-accessibility.mdcTable element accessibility compliance
Cursor rules
Quality
40/100
Scores the file, not the repository.Length
1,061 words
1 headings · 7 code blocksRepository
428
— · pushed 17 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Table Element Accessibility Standards78Ensures table elements follow WCAG compliance and provide proper structure for screen reader navigation and data relationships.910<rule>11name: table_accessibility_standards12description: Enforce table element accessibility standards per WCAG 1.3.1 Info and Relationships requirements13filters:14 - type: file_extension15 pattern: "\\.(vue|jsx|tsx|html|liquid|php|js|ts)$"1617actions:18 - type: enforce19 conditions:20 # Table headers must use th elements21 - pattern: "(?i)<table[^>]*>.*<td[^>]*>.*</td>.*<td[^>]*>.*</td>"22 pattern_negate: "<th[^>]*>"23 message: "Data tables must use th elements for headers. Use th for header cells and td for data cells."2425 # Missing scope attribute on th elements26 - pattern: "(?i)<th[^>]*>"27 pattern_negate: "scope=\"(col|row|colgroup|rowgroup)\""28 message: "Table header cells should have scope attribute set to 'col', 'row', 'colgroup', or 'rowgroup' for proper associations."2930 # Data cells not associated with headers31 - pattern: "(?i)<td[^>]*>"32 pattern_negate: "(scope=\"(col|row)\"|headers=\"[^\"]+\"|<th[^>]*scope)"33 message: "Table data cells must be associated with their corresponding header cells via scope or headers attributes."3435 # Layout table with headers36 - pattern: "(?i)<table[^>]*class=\"[^\"]*(?:layout|grid|position)[^\"]*\"[^>]*>"37 pattern_negate: "(role=\"table\"|data-table)"38 message: "Layout tables should not contain header elements. Use role='table' for data tables or remove headers from layout tables."3940 # Missing caption or accessible name41 - pattern: "(?i)<table[^>]*>"42 pattern_negate: "(<caption|aria-label|aria-labelledby)"43 message: "Data tables should have a caption element or aria-label/aria-labelledby for accessibility."4445 # Empty caption46 - pattern: "(?i)<caption[^>]*>\\s*</caption>"47 message: "Table caption should contain meaningful text describing the table's purpose."4849 # Generic caption text50 - pattern: "(?i)<caption[^>]*>\\s*(table|data|information)\\s*</caption>"51 message: "Table caption should be specific and descriptive, not generic."5253 # Missing table structure elements54 - pattern: "(?i)<table[^>]*>.*<tr[^>]*>.*<td[^>]*>"55 pattern_negate: "(<thead|<tbody|<tfoot)"56 message: "Complex tables should use thead, tbody, and tfoot elements for proper structure."5758 # Incorrect role usage59 - pattern: "(?i)role=\"(table|rowgroup|cell|columnheader|rowheader)\""60 pattern_negate: "(<table|<tbody|<thead|<tfoot|<td|<th)"61 message: "Table roles should only be used when native HTML table elements are not available."6263 # Missing headers attribute for complex associations64 - pattern: "(?i)<td[^>]*>"65 pattern_negate: "(headers=\"[^\"]+\"|scope=\"(col|row)\")"66 message: "Data cells in complex tables should have headers attribute referencing their associated header IDs."6768 # Missing ID on header cells for headers attribute69 - pattern: "(?i)<td[^>]*headers=\"[^\"]+\"[^>]*>"70 pattern_negate: "<th[^>]*id=\"[^\"]+\"[^>]*>"71 message: "Header cells referenced by headers attribute must have unique ID attributes."7273 # Nested tables without proper isolation74 - pattern: "(?i)<table[^>]*>.*<table[^>]*>"75 pattern_negate: "(role=\"table\"|aria-label|aria-labelledby)"76 message: "Nested tables should have proper accessible names and structure to avoid confusion."7778 # Table without proper row structure79 - pattern: "(?i)<table[^>]*>"80 pattern_negate: "<tr[^>]*>"81 message: "Tables must contain tr (table row) elements for proper structure."8283 # Missing table role when using ARIA84 - pattern: "(?i)role=\"(rowgroup|cell|columnheader|rowheader)\""85 pattern_negate: "role=\"table\""86 message: "When using table ARIA roles, the table element must have role='table'."8788 - type: suggest89 message: |90 **WCAG 1.3.1 Table Accessibility Requirements:**9192 **Table Headers:**93 - **Header Tag:** Table headers MUST be designated with `th` elements94 - **Meaningful Header:** Header text MUST accurately describe the category of corresponding data cells95 - **Header Associations:** Data cells MUST be associated with their corresponding header cells96 - **Scope Attribute:** Use `scope="col"` and `scope="row"` for simple tables97 - **Complex Associations:** Use `headers` and `id` attributes for complex header relationships9899 **Tabular Data:**100 - **Tables:** Tabular data SHOULD be represented in a `table` element101 - **Data Relationships:** WCAG 1.3.1 requires data to be associated with their labels102103 **Caption Requirements:**104 - **Caption:** Data tables SHOULD have a `caption` element or accessible name105 - **Meaningful Caption:** Caption SHOULD describe the table's identity or purpose106 - **Unique Caption:** Each table SHOULD have a unique caption within the page context107108 **Layout Tables:**109 - **Avoid Layout Tables:** Tables SHOULD NOT be used for purely visual layout110 - **No Headers in Layout:** Layout tables MUST NOT contain header elements111112 **HTML Markup Requirements:**113 - **Native Elements:** Use semantic HTML `table`, `caption`, `tr`, `th`, `td`, `thead`, `tbody`, `tfoot`114 - **ARIA Roles:** Only use table roles when native HTML is not available115116 **Implementation Patterns:**117118 **Basic Data Table:**119```html120 <table>121 <caption>Monthly Sales Report - Q1 2024</caption>122 <thead>123 <tr>124 <th scope="col">Month</th>125 <th scope="col">Revenue</th>126 <th scope="col">Units Sold</th>127 </tr>128 </thead>129 <tbody>130 <tr>131 <td>January</td>132 <td>$45,000</td>133 <td>1,200</td>134 </tr>135 <tr>136 <td>February</td>137 <td>$52,000</td>138 <td>1,350</td>139 </tr>140 </tbody>141 </table>142```143144 **Complex Table with Multiple Headers:**145```html146 <table>147 <caption>Product Performance by Region and Quarter</caption>148 <thead>149 <tr>150 <th scope="col" rowspan="2">Product</th>151 <th scope="colgroup" colspan="2">Q1 2024</th>152 <th scope="colgroup" colspan="2">Q2 2024</th>153 </tr>154 <tr>155 <th scope="col">North</th>156 <th scope="col">South</th>157 <th scope="col">North</th>158 <th scope="col">South</th>159 </tr>160 </thead>161 <tbody>162 <tr>163 <th scope="row">Widget A</th>164 <td>150</td>165 <td>200</td>166 <td>175</td>167 <td>225</td>168 </tr>169 <tr>170 <th scope="row">Widget B</th>171 <td>300</td>172 <td>250</td>173 <td>325</td>174 <td>275</td>175 </tr>176 </tbody>177 </table>178```179180 **Table with Headers Attribute:**181```html182 <table>183 <caption>Employee Directory</caption>184 <thead>185 <tr>186 <th id="name">Name</th>187 <th id="department">Department</th>188 <th id="email">Email</th>189 <th id="phone">Phone</th>190 </tr>191 </thead>192 <tbody>193 <tr>194 <td headers="name">John Smith</td>195 <td headers="department">Engineering</td>196 <td headers="email">john.smith@company.com</td>197 <td headers="phone">555-0101</td>198 </tr>199 <tr>200 <td headers="name">Jane Doe</td>201 <td headers="department">Marketing</td>202 <td headers="email">jane.doe@company.com</td>203 <td headers="phone">555-0102</td>204 </tr>205 </tbody>206 </table>207```208209 **ARIA Table (when native HTML not available):**210```html211 <div role="table" aria-label="Product Inventory">212 <div role="rowgroup">213 <div role="row">214 <div role="columnheader" scope="col">Product</div>215 <div role="columnheader" scope="col">Stock</div>216 <div role="columnheader" scope="col">Price</div>217 </div>218 </div>219 <div role="rowgroup">220 <div role="row">221 <div role="cell">Widget A</div>222 <div role="cell">150</div>223 <div role="cell">$25.00</div>224 </div>225 <div role="row">226 <div role="cell">Widget B</div>227 <div role="cell">200</div>228 <div role="cell">$30.00</div>229 </div>230 </div>231 </div>232```233234 **Table Structure Guidelines:**235236 **Simple Tables:**237 - Use `th` with `scope="col"` for column headers238 - Use `th` with `scope="row"` for row headers239 - Include meaningful `caption` element240241 **Complex Tables:**242 - Use `thead`, `tbody`, `tfoot` for structure243 - Use `headers` and `id` attributes for complex associations244 - Consider using `colgroup` and `rowgroup` for grouped headers245246 **Layout Tables (Avoid):**247```html248 <!-- ❌ Bad: Using table for layout -->249 <table>250 <tr>251 <td>Header</td>252 <td>Content</td>253 </tr>254 </table>255256 <!-- ✅ Good: Using CSS for layout -->257 <div class="layout-container">258 <header>Header</header>259 <main>Content</main>260 </div>261```262263 **Caption Best Practices:**264```html265 <!-- ✅ Good: Specific and descriptive -->266 <table>267 <caption>Monthly Sales Performance - Q1 2024</caption>268 <!-- table content -->269 </table>270271 <!-- ❌ Bad: Generic caption -->272 <table>273 <caption>Data Table</caption>274 <!-- table content -->275 </table>276```277278 **Scope Attribute Usage:**279```html280 <!-- Column headers -->281 <th scope="col">Product Name</th>282 <th scope="col">Price</th>283284 <!-- Row headers -->285 <th scope="row">Widget A</th>286 <th scope="row">Widget B</th>287288 <!-- Group headers -->289 <th scope="colgroup" colspan="2">Q1 2024</th>290 <th scope="rowgroup" rowspan="3">Product Category</th>291```292293 **Testing and Validation:**294 - Test with screen readers to verify header associations295 - Verify table navigation works properly296 - Check that captions are announced correctly297 - Test keyboard navigation through table cells298 - Validate scope attributes are used appropriately299 - Ensure complex tables have proper header associations300301 **Common Mistakes to Avoid:**302 - Using `td` elements for headers instead of `th`303 - Missing scope attributes on header cells304 - Using tables for layout purposes305 - Generic or meaningless captions306 - Missing accessible names for tables307 - Incorrect use of ARIA table roles308 - Nested tables without proper isolation309 - Missing header associations in complex tables310 - Using layout tables with header elements311312metadata:313 priority: high314 version: 1.0315</rule>316
Also in Shopify/horizon
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| Shopify/horizon.cursor/rules/accordion-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/animation-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/blocks.mdc · 428 | Cursor rules | stylearchtypesdatabase+2 | 62/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/breadcrumb-accessibility.mdc · 428 | Cursor rules | ui | 36/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/carousel-accessibility.mdc · 428 | Cursor rules | ui | 32/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/cart-drawer-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/chat-window-accessibility.mdc · 428 | Cursor rules | styleui | 24/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/color-contrast-accessibility.mdc · 428 | Cursor rules | lint-formatui | 44/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/color-swatch-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/commit-messages.mdc · 428 | Cursor rules | setuplint-formattypesgit | 62/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/css-standards.mdc · 428 | Cursor rules | stylearchuiperformance+3 | 49/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/disclosure-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/dropdown-navigation-accessibility.mdc · 428 | Cursor rules | styleui | 36/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/flip-card-accessibility.mdc · 428 | Cursor rules | styleui | 36/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/form-accessibility.mdc · 428 | Cursor rules | ui | 32/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/javascript-standards.mdc · 428 | Cursor rules | stylearchtypesui+2 | 54/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/landmark-accessibility.mdc · 428 | Cursor rules | ui | 40/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/liquid.mdc · 428 | Cursor rules | buildstyletypesdatabase+2 | 77/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/locales.mdc · 428 | Cursor rules | arch | 49/100 | 3 days ago | |
| Shopify/horizon.cursor/rules/localization.mdc · 428 | Cursor rules | style | 54/100 | 3 days ago |
Diff against .cursor/rules/accordion-accessibility.mdc Diff against .cursor/rules/animation-accessibility.mdc Diff against .cursor/rules/blocks.mdc Diff against .cursor/rules/breadcrumb-accessibility.mdc Diff against .cursor/rules/carousel-accessibility.mdc Diff against .cursor/rules/cart-drawer-accessibility.mdc Diff against .cursor/rules/chat-window-accessibility.mdc Diff against .cursor/rules/color-contrast-accessibility.mdc Diff against .cursor/rules/color-swatch-accessibility.mdc Diff against .cursor/rules/commit-messages.mdc Diff against .cursor/rules/css-standards.mdc Diff against .cursor/rules/disclosure-accessibility.mdc Diff against .cursor/rules/dropdown-navigation-accessibility.mdc Diff against .cursor/rules/flip-card-accessibility.mdc Diff against .cursor/rules/form-accessibility.mdc Diff against .cursor/rules/javascript-standards.mdc Diff against .cursor/rules/landmark-accessibility.mdc Diff against .cursor/rules/liquid.mdc Diff against .cursor/rules/locales.mdc Diff against .cursor/rules/localization.mdc
