Position the cells in the middle of the bottom row within the table

Indeed, this layout is based on tables. It's a legacy design, so removing the table structure may not be feasible. Nevertheless, I am curious to learn about table alignment, hence posing this somewhat unconventional question.

Imagine a 3x3 table with values from 1 to 8. The last row contains only 2 elements, and I want those centered.

Snippet of HTML code:

<table>
    <tr><td>1</td><td>2</td><td>3</td></tr>
    <tr><td>4</td><td>5</td><td>6</td></tr>
    <tr><td>7</td><td>8</td></tr>
</table>

I have attempted using the CSS rule tr { text-align: center }, but it seems there might be some table structure overriding the center alignment and I need to figure out which style property to override.

Here's a Fiddle link with various CSS attempts that didn't achieve the desired result: http://jsfiddle.net/sdqtg7kr/

Answer №1

To ensure that the bottom td elements are centered, consider modifying the display property of these elements from table-cell to inline-block.

See Updated Demo

td {
    border-color: red;
    border-style: solid;
    border-width: thin;
    display: inline-block;
}

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

`My GitHub webpage is having trouble displaying images online`

I am experiencing difficulty with GitHub loading the images in my images folder. Strangely, it loads the background image without any issues, and when I launch the page offline, all the images load perfectly. I have checked that the images only start with ...

What is the best way to stop a jQuery event listener on a button within a form from triggering upon the user hitting the Enter key?

Here is an example of a form containing a button: <form> <input type="text"> <button>Click Me</button> <input type="submit" value="Submit"/> </form> Using the following JavaScript: $('form').subm ...

Retrieve the content of an element within a freshly launched window

I am looking to utilize JavaScript to open an html file and input some data into specific elements. My attempt so far has been: var info_window = window.open('info_print.html') info_window.document.getElementById('new_info').innerHTML ...

The styling of the React component is not being applied as expected by the .Css file

My title component seems to be having trouble applying the CSS styles as expected. I'd like it to have a green background, but for some reason, it's displaying as white. Below is the Component Js file: import React from "react"; funct ...

Positioning <tr> elements with absolute precision within a intricate layout

I am faced with the challenge of developing a complex UI control. The structure consists of a left-side TreeTable component, implemented using a <table> element, and a right-side SVG component that displays data corresponding to each row of the left ...

disable input box stationary

Is there a way to make a checkbox stay disabled even after refreshing the page? Currently, when I click the checkbox it disables, but upon refreshing the page, it goes back to being enabled. $( "input[type='checkbox']").click(function(event){ ...

Verify the compatibility of the device with ScreenOrientation.lock() function - An error occurred indicating that screen.orientation.lock() is not supported on this particular device

I've been trying to implement ScreenOrientation.lock() according to the documentation, but I'm having trouble getting it to work correctly. https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/lock When I use window.screen.orienta ...

Is there a way to extract the visible text from an HTML TextNode without including the HTML tags?

My current challenge involves converting a DOM node and all of its children into plain text markup of a custom design. Utilizing node.childNodes allows me to retrieve a list of all content, which can then be recursively transformed into my desired string f ...

Adjust the <h1> tag's size using responsive Bootstrap design

Is it possible to adjust the font size of the <h1> tag specifically for small and extra small screens? The default size of the <h1> tag is suitable for medium screens but appears very large on small and extra small screens. I would like to cu ...

Integrate JavaScript with WordPress

How can I get this functioning properly within Wordpress? I have been attempting to connect everything together, but it doesn't appear to be working. Is this the correct way to do it, or am I overlooking something? <script type="text/javascript" s ...

Utilize CSS to select the child div within the app container

When I am developing a website with Angular, my code typically looks like this: <div class="main"> <div class="container"> <app-name> <div class="app-child-div"></div> < ...

Connecting pages through index.html within the hosting file manager directory

I have just started my coding journey and recently signed up for ipage hosting. After uploading my .html files to a directory named "Website", I encountered an issue while trying to link multiple pages to the index.html home page. I tried using the code ...

Angular Material DatePicker: Day and Month selection without including the Year

Is there a way to customize an Angular Date Picker to show only Month and Day without the Year option? The provided link demonstrates a Month and Year picker, but I am looking to modify it for Month and Day selection. Changing YYYY to DD does not yield th ...

By utilizing ng-init and ng-model, the form is assigned a value

Just diving into the world of angularjs and looking to incorporate some of its functionality into my web application. I have a specific idea in mind for creating a form where, as I type, the application displays a preview of the content - similar to how i ...

Vuelidate is unfalteringly honest and always holds true, even when all conditions are satisfied

After entering a name into the text field, I am unable to proceed to the next card because !this.$v.$invalid never changes to false. I'm not sure what I'm overlooking here. It's worth noting that errors do show up properly when clicking on ...

Looking for solutions to streamline the deployment of your JavaScript, CSS, and HTML files automatically?

Is there a tool for automating my project workflow to manage the folder structure below on Mac? During the build process, use project.js but deploy only project.min.js Use project.less during the build process, but deploy only project.min.css Or do I ne ...

The CSS center alignment is functioning properly on some pages, however, it seems to be malfunction

I have noticed that the CSS centering is effective on this page: However, it seems to not be working on this page: Despite both HTML pages utilizing the same CSS link, the centering issue persists on one page. Any assistance in resolving this discrepancy ...

How can I optimize Javascript and CSS that are being used on my website but are not physically hosted on my website?

On my website, I have a plugin called "Contact Us" that was created and is being operated by Dropifi. Lately, I've been working on optimizing my site for SEO/Speed using Google's PageSpeed Insights tool. I enabled compression with GZip for all el ...

Designing Checkboxes and Radio Buttons

I am seeking a way to customize the appearance of checked and unchecked checkboxes using images without modifying the HTML structure. I would prefer not to add labels, classes, or IDs to the elements. The provided example only works in Webkit browsers, s ...

Can HTML5 be used to store IDs in PHP chat applications?

I'm in the process of developing a chat application with PHP. Everything is functioning properly, but I have encountered a potential loophole. I am implementing AJAX to fetch chat data as the user scrolls, similar to platforms like Facebook and Twitte ...