Performance: Table caption placement
This affects the visual stability and rendering speed of tables by controlling when and how captions are displayed.
<table>
<caption>Monthly Sales</caption>
<tbody>
<tr><td>Data</td></tr>
</tbody>
</table><table>
<caption>Monthly Sales</caption>
<tbody>
<tr><td>Data</td></tr>
</tbody>
</table>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Caption inside <tbody> | Invalid DOM structure | Multiple reflows due to layout shifts | Higher paint cost from re-painting shifted content | [X] Bad |
| Caption directly inside <table> | Valid DOM structure | Single reflow on load | Minimal paint cost with stable layout | [OK] Good |
<caption> tag be placed in a Bootstrap table to add a descriptive title?<caption> tag must be inside the <table> element to be valid and recognized by browsers. It should come immediately after the opening <table> tag, before <thead> or <tbody>.<table> element, before any <thead> or <tbody> -> Option C<table> element, before any <thead> or <tbody> [OK].caption-top to place captions above and .caption-bottom to place captions below the table. The class .caption-bottom moves the caption below the table..caption-bottom -> Option B.caption-bottom [OK]<table class="table">
<caption class="caption-top">Monthly Sales</caption>
<thead>
<tr><th>Product</th><th>Sales</th></tr>
</thead>
<tbody>
<tr><td>Apples</td><td>100</td></tr>
</tbody>
</table>caption-top, which Bootstrap uses to place captions above the table. With caption-top, the caption text "Monthly Sales" will appear visually above the table rows and headers.<table class="table">
<thead>
<caption>User Data</caption>
<tr><th>Name</th><th>Age</th></tr>
</thead>
<tbody>
<tr><td>Alice</td><td>30</td></tr>
</tbody>
</table><caption> tag must be a direct child of the <table> element, not inside <thead> or <tbody>. The caption is placed inside <thead>, which is invalid HTML and will cause rendering issues..caption-top and .caption-bottom classes do not toggle automatically based on screen size. Place two captions with different classes and use Bootstrap's responsive display classes (like d-none d-sm-block) to show one above on large screens and below on small screens..caption-top and one with .caption-bottom, then hide/show with responsive utilities -> Option APass the test and this pattern moves unknown