Tables
Tables in Drupal 9 are fickle and require workarounds to make them look similar to Table in Drupal 7. To do this, we have to include custom styling to change its design.
Table without custom styling
Table with custom styling
Our custom styling adds back gridlines and removes the horizontal scroll so all the content fits on the page without the need to scroll.
Add custom styling
- Add Table paragraph type to page.
- Set Table column and row, then fill in with content.
- Add Embed (Full HTML) paragraph type
Fill in Embed (Full HTML) with code snippet.
Copy the code below & paste in.
<style>
table {
display: block;
overflow-x: auto;
white-space: auto;
}
table th {
font-weight: bold;
}
table td {
white-space: normal;
}
table th, table td {
border: 1px solid #AEB4B9;
}
</style>
Move the Embed (Full HTML) paragraph type to the bottom of the content block.
If you added the Embed (Full HTML) last, it will already be at the bottom. If you did not, you must move it to the bottom or it will create a gap between your content.
But, the Embed (Full HTML) will stylize the table regardless of it is above or below the Table paragraph type.
- Set Current State of page to Publish, then click Save to finalize all edits.