exclude the outer border from the last row of the table

Is it possible to create a table with only an outer border and exclude the bottom row, so that the bottom border of the second last row gives the appearance of being the final row? I am limited to using CSS as this is on Wordpress and I cannot make changes to the HTML. Please refer to the image below:

The "coupon code" and "update basket" sections actually represent the final row.

***** EDIT ***** Here is the HTML (that cannot be edited):

<table class="shop_table cart" cellspacing="0">
    <thead>
        <tr>
            <th class="product-remove">&nbsp;</th>
            <th class="product-thumbnail">&nbsp;</th>
            <th class="product-name">Product</th>
            <th class="product-price">Price</th>
            <th class="product-quantity">Quantity</th>
            <th class="product-subtotal">Total</th>
        </tr>
    </thead>
    <tbody>

                        <tr class="cart_item">

                    <td class="product-remove">
                        <a href="http://uc.petekirkwood.co.uk/basket/?remove_item=02522a2b2726fb0a03bb19f2d8d9524d&amp;_wpnonce=967f1478b0" class="remove" title="Remove this item">×</a>                   </td>

                    <td class="product-thumbnail">
                        <a href="http://uc.petekirkwood.co.uk/shop//tedbaker/test-product-copy"><img width="180" height="135" src="http://uc.petekirkwood.co.uk/wp-content/uploads/2015/04/TedBaker_TravelDocHolderCoral_5-180x135.jpg" class="attachment-shop_thumbnail wp-post-image" alt="TedBaker_TravelDocHolderCoral_5"></a>                  </td>

                    <td class="product-name">
                        <a href="http://uc.petekirkwood.co.uk/shop//tedbaker/test-product-copy">Test Product (Copy) </a>                    </td>

                    <td class="product-price">
                        <span class="amount">£10.00</span>                  </td>

                    <td class="product-quantity">
                        <div class="quantity"><input type="number" step="1" min="0" name="cart[02522a2b2726fb0a03bb19f2d8d9524d][qty]" value="3" title="Qty" class="input-text qty text" size="4"></div>
                    </td>

                    <td class="product-subtotal">
                        <span class="amount">£30.00</span>                  </td>
                </tr>
                        <tr>
            <td colspan="6" class="actions">

                                    <div class="coupon">

                        <label for="coupon_code">Coupon:</label> <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="Coupon code"> <input type="submit" class="button" name="apply_coupon" value="Apply Coupon">


                    </div>

                <input type="submit" class="button" name="update_cart" value="Update Basket">


                <input type="hidden" id="_wpnonce" name="_wpnonce" value="967f1478b0"><input type="hidden" name="_wp_http_referer" value="/basket/?removed_item=1">         </td>
        </tr>

            </tbody>
</table>

Answer №1

To choose the penultimate selection

tr:nth-first-child {/*the first choice*/
  border-bottom: 2px solid black
}
tr:nth-last-child(2) { /*the second-to-last selection*/
  border-bottom: 2px solid black
}
tr:not(:last-child){/* everything except for the last one */
  border-left: 2px solid black;
  border-right: 2px solid black
}

Answer №2

If you're having trouble with the table border not excluding the last row, consider removing that row and replacing it with a different element such as a div or another table.

Alternatively, you can try this workaround:

table {
    border-collapse: collapse;
}
table tr:first-child td,
table tr:last-child td {
    border-top: 1px solid black;
}
table tr:nth-last-child(n+2) td:first-child {
    border-left: 1px solid black;
}
table tr:nth-last-child(n+2) td:last-child {
    border-right: 1px solid black;
}

Check out the DEMO here!




UPDATE based on feedback

I have included the table header row now.

It was discovered that using border-collapse: collapse and border-radius together is problematic. Instead, add cellspacing="0" to your table's HTML tag.

table {
    /*border-collapse: collapse;*/
    /* To use rounded borders and border-collaspe together,
    add cellspacing="0" to your table */
}
table tr:first-child th { /* for the first row */
    border-top: 1px solid black;
}
table tr:nth-last-child(2) td { /* second-to-last row */
    border-bottom: 1px solid black;
}

table tr:nth-last-child(n+2) td:first-child,
table thead tr th:first-child { /* all left cells, except the last one */
    border-left: 1px solid black;
}
table tr:nth-last-child(n+2) td:last-child, 
table thead tr th:last-child { /* all right cells, except the last one */
    border-right: 1px solid black;
}
table tr:first-child th:first-child { /* top-left cell */
    border-radius: 10px 0 0 0;
}
table tr:first-child th:last-child { /* top-right cell */
    border-radius: 0 10px 0 0;
}
table tr:nth-last-child(2) td:first-child { /* bottom-left cell */
    border-radius: 0 0 0 10px;
}
table tr:nth-last-child(2) td:last-child { /* bottom-right cell */
    border-radius: 0 0 10px 0;
}

UPDATED Fiddle Available Here!
Fiddle specific to your HTML structure

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you please provide the CSS code that would style this table in a similar manner?

I am interested in utilizing the design of this table, but how can I update it to meet CSS standards and HTML5 equivalents? <html> <head></head> <body> <table border="1" bordercolor="#000000" style="background-color:#ffffff" w ...

arranging three divs in a row, with one div expanding to fill the entire height while the other two divs evenly split the remaining

I am attempting to create a content row consisting of 4 divs: 1 container div 3 divs within the container: 1 image - taking up the full height 2 text - sharing the height, but each on a separate line. It should resemble the following: https://i.sstatic.n ...

Optimizing mobile page layouts with CSS

I'm putting in a lot of effort to ensure that my simple form page is optimized for mobile devices. Although the form is visible, I find myself having to zoom in quite a bit in order to read it. Here's an example: ...

Legend alignment issue in Firefox disrupting Flexbox functionality

My fieldset has a legend containing text and a button. I am attempting to use flexbox to right-align the button within the legend. This setup works correctly in Chrome, but encounters issues in Firefox. I have managed to replicate the problem with a simpl ...

My website is currently experiencing issues with all of the CSS references not working. This problem applies to both external and internal CSS files and consistently

I'm encountering 404 errors when trying to load both internal and external files on a website through my browser. My code snippet looks like this: <link rel="stylesheet" type = "text/css" href='anoceanofsky.css'/> Despite clearing m ...

Upon clicking the 'Add Image' button, TINYMCE dynamically incorporates an input

I am in search of creative solutions to address an issue I'm facing. Currently, I am utilizing TINYMCE to incorporate text into my webpage. However, I would like to enhance this functionality by having a feature that allows me to add an image along w ...

Transform website code into email-friendly HTML code

Is there any software available that can convert web HTML and CSS files to email HTML with inline CSS? This would allow the email to be viewable on various email clients such as Outlook, Thunderbird, Gmail, Yahoo, Hotmail, etc. I want to write my code lik ...

What is preventing me from accessing the hidden article using the URL with the hashname?

I've been searching for a solution, but so far nothing seems to work for me. I have a page with header and content sections. The content section is currently not visible. When I click on an item in the navigation menu, I want to hide the header and di ...

Adhesive Bottom Navigation, Top Banner, and Full-Height Page Content

Trying to create a header, sticky footer, and content section with 100% height, but facing issues with the middle height. Below is the code and jsfiddles provided. Using HTML 4.0 strict in IE7 without the option to change. jsfiddle without 100% height: ht ...

Tips for updating the styleurls link dynamically by clicking a button and maintaining the changes

In the midst of developing an angular 2 project, I am currently working on integrating theme settings. Within my project, I have crafted three distinct component.scss files: red.component.scss, yellow.component.scss, and blue.component.scss. My goal is t ...

What could be causing the styled-component's flex value to not update?

I have a sidebar and main content on my website layout. The main content occupies most of the screen space, while the sidebar should only take up a small portion. Both elements are within a flexbox container, with the sidebar and main content as child divs ...

Creating Sleek Rounded Corners with Pure CSS in Older Versions of Internet Explorer (Compatible with jQuery)

Looking for a seamless solution to render rounded corners on browsers that do not support CSS3 without the delay typically seen with JQuery plugins. The use of .htc files with www.css3pie.com seems like the best option so far, but there is still a delay c ...

How can the output directory of the CSS file generated by Compass/Webby be modified?

I need assistance in getting my *.css file to be outputted in the output/css directory instead of the stylesheets directory. How can I achieve this? Here's what I've already attempted: Compass.configuration do |config| config.project_path = F ...

Div containing scrollable content with overlaid child element

I am facing an issue with a scrollable div that contains a table, where I am trying to append a loader component as a child to cover the div when it's scrolled. However, the loader only covers the initial size of the div. Here is an example similar t ...

The error occurred at line 12 in the app.js file, where it is unable to access properties of an undefined object, specifically the 'className' property. This occurred within an anonymous function in an HTMLDivElement

I am facing an issue with my website where I have buttons on the right side. I want to use JavaScript to change the style of the button when it is clicked. When the page loads, the home button should have a background-color: green. However, when another bu ...

Move the menu position in Bootstrap 4 navbar

<div class="fixed-top"> <div class="collapse" id="navbarToggleExternalContent"> <div class="bg-dark p-4"> <h5 class="text-white h4">Hidden content</h5> <span class="text-muted">Toggleable via the ...

Switching downlink to top link when scrolling downwards

I have a downward scrolling link on my homepage that moves the page down when clicked by the user. However, I am struggling to make it change to a "back to top" link as soon as the user scrolls 10 pixels from the top. Additionally, I am having trouble with ...

Is there a way to showcase specific page categories in Wordpress?

Can someone help me figure out how to display individual posts for a specific page? For example, I want the URL of my single service post to be like this: I attempted to create a "single-service.php" file, but it keeps redirecting me to my static front p ...

Having problems with Javascript and CSS not playing well together?

I have implemented a button from this source, but it does not appear correctly on my page. You can view the screenshot here. It seems like there is a conflict between the saved changes and the CSS. How can I resolve this issue? In addition, I am facing ...

I would like to terminate the property when processing it on a mobile device

<div class="col-sm-24 embed-responsive"> <iframe width="100%" src="http://www.youtube.com/embed/${item.snippet.resourceId.videoId}"></iframe> </div> .embed-responsive iframe { height: 185px; margin-top: -4%; paddin ...