Archived topic
Align Table Text to Center
5 replies · Started by Hendry on June 4, 2020
Hello, i am having trouble in aligning my custom html table text to be centered.
i tried this css:
table,th,td,caption{text-align:center}
but it makes my table text that i create with wordpress table element become centered also.
is there any css can i use so only my the table with class element aligned center?
Hi there,
you can add a class to your HTML and target that eg.
<table class="custom-table">
<!-- Rest of table code -->
</table>
then you should be able to target that class:
.custom-table {
text-align: center;
}
i tried this code before with class .dounkey-table-center, but it still does not work
Try this:
table.dounkey-table-center,
table.dounkey-table-center th,
table.dounkey-table-center td,
table.dounkey-table-center caption {
text-align: center;
}
Thank you, it works
You're welcome