Let's explore an alternative way to achieve border-collapse:collapse with border-radius in CSS to have a collapsed, rounded corner table.
Making rounded corners can be accomplished using border-radius:10px. Some example CSS:
To reduce the CSS and require targeting a combination of table, th, and td tags it can be handy to apply border-collapse:collapse so the browser draws a single border and not one for each the table, tr, and td tags.
When applying the combination of collapse with the border radius, some td elements were not being rounded. The solution is to target the specific ones, in this case the first and last td elements:
Published on Jun 25, 2019 Tags: The Ultimate CSS Tutorial for Beginner Programmers
Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article
that you just finished reading.
No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner
or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in
and improve your skillset with any of the tutorials below.
How can I use border-radius to create a collapsed table with rounded corners?
table {
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px
}
Solution to a collapsed rounded corner table
table tr:last-child td:first-child {
border-bottom-left-radius: 10px;
}
table tr:last-child td:last-child {
border-bottom-right-radius: 10px;
}
Related Posts
Tutorials
Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.