I'm using vBulletin to style a forum which primarily uses tables to style the site. How would I go about using padding on a tbody
to space the content away from the border?
Here you can see a picture of my main site where the content is pushed 5px away from the border:
Whereas on vBulletin, adding padding on tbody
doesn't push the content away:
Another way of applying some margin on a <tbody> element is to use a ::before or ::after pseudo element. This way we basically add a new (empty) row which we can use to add some space at the beginning of our <tbody> elements.
You may use more than one <tbody> per table as long as they are all consecutive. This lets you divide the rows in large tables into sections, each of which may be separately formatted if so desired.
Quoting the HTML 4 spec: "The TBODY start tag is always required except when the table contains only one table body and no table head or foot sections. The TBODY end tag may always be safely omitted."
Nope, this is not possible. According to the spec, the TBODY element can contain only TR elements.
Method 1
You have a couple different options:
tbody:before {
content: '';
display: block;
height: 20px;
}
Adding this basically "inserts" content before the end. It's sort of a "quick-n-dirty" fix.
Method 2
Another option is giving your table
a border-collapse: collapse
and then giving your tbody
a border value:
table {
border-collapse: collapse;
}
table tbody {
border-right: 20px solid transparent;
}
Both of these methods have drawbacks, however. The before selector might not work in IE7, and requires a !DOCTYPE
to work in IE8. The second method can sometimes be a bit touchy, depending on the rest of your css. Be sure to have a !DOCTYPE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With