Adding space between the cells on the far left and far right of the table and the border

I need some advice on creating a table in HTML where the borders of the leftmost and right most cells do not extend all the way to the edges of the table. Here's an example:

| ____ |

In this example, the top border of the cells is continuous within each cell but does not reach the outer border of the table. Any tips on how to achieve this would be greatly appreciated.

Answer №1

Instead of styling the border/padding directly on the table cell, try placing a DIV inside the cell and applying the styles to the DIV instead.

Answer №2

I'm uncertain about which of these instances aligns with your requirements. It appears that your explanation contradicts the visuals you provided, but feel free to test these options.

<div style="width:250px;padding:10px; border-left: solid black 1px;border-right: solid black 1px;">
<table width="100%" style="border-top: solid black 1px;border-bottom: solid black 1px;">
    <tr>
        <td>cell 1:1</td>
        <td>cell 1:2</td>
        <td>cell 1:3</td>
    <tr>
    <tr>
        <td>cell 2:1</td>
        <td>cell 2:2</td>
        <td>cell 2:3</td>
    <tr>
</table>
</div>
<br /><br />
<div style="width:250px;padding:10px; border-top: solid black 1px;border-bottom: solid black 1px;">
<table width="100%" style="border-left: solid black 1px;border-right: solid black 1px;">
    <tr>
        <td>cell 1:1</td>
        <td>cell 1:2</td>
        <td>cell 1:3</td>
    <tr>
    <tr>
        <td>cell 2:1</td>
        <td>cell 2:2</td>
        <td>cell 2:3</td>
    <tr>
</table>
</div>

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

Bootstrap the registration form to center it in the layout

https://i.sstatic.net/IWSHz.png Here is the code snippet: <div class="col-md-4 col-md-offset-3">. I am new to Bootstrap and trying to center a form that is currently on the left. I have experimented with different col-md and col-xl numbers, but have ...

Menus that mimic the style of Google Translate's select options

I'm looking to design an HTML select menu using CSS in a similar fashion to Google Translate's style on Google Translate. I've searched for tutorials online, but they all involve jQuery. Is there a way to achieve something similar using only ...

Achieving successful functionality with position:relative in IE9

Having difficulty with the position: relative property in IE9. Check out this demo for reference: <div style="overflow:scroll;height:120px;"> <table id="table" width="100%"> <tr style="position:relative;background-color:#1b72a4;"> ...

Is there a way to link two HTML files containing jQuery within an HTML index file?

I'm currently working on creating an index page for a pair of HTML files that utilize jquery. Let's break down the structure of these files: Emps1, Emps2: These are two HTML tables that start off empty. TabA_stats, TabB_stats: Each HTML file ha ...

a pathway leading to the user's profile

I have successfully implemented a code that displays a list of people who are at level 8, which can be seen below Now, I want to make it so that when a user clicks on the username of the individuals listed, they will be redirected to their profile page. H ...

Is there a method to identify the quantity of audio channels within a <video> element? (HTML5)

I would like to connect an AnalyserNode to each audio channel of a video element in order to perform audio visualization. Currently, my code is functioning properly except for the fact that both AudioContext and MediaElementAudioSourceNode consistently re ...

Tips for updating the id of a tag using JavaScript?

Html Code:- {% for post in posts %} <article class="media content-section"> <div class="media-body"> <h2><a id="post_title" class="article-title" href="{% url 'post-detail' post.slug %}">{{ post.title }}&l ...

Enhancing Your Website with Interactive Highlighting Tags

Looking at the following html: Let's see if we can <highlight data-id="10" data-comment="1"> focus on this part only </highlight> and ignore the rest My goal is to emphasize only the highlight section. I know how to emphasize a span ...

Is there a way for me to discover the identity of the victor?

There are 4 divs that move at different, random speeds each time. I am trying to determine which one is the fastest or reaches the goal first. Additionally, there is a betting box where you can choose a horse to bet on. I need to compare the winner with my ...

Scrolling horizontally within SVG graphics

Check out this JSFiddle body { background-color: #111111; color: #ffffff; /*max-width: 100%;*/ overflow-x: hidden; } .row { max-width: 100rem; } .svgrow { min-width: 70rem; } .svgrow svg { overflow-x: auto; } I am trying to ma ...

Reversed Sink CSS3 Animation moving to the left side

Currently, I am working on creating an animation that gives the illusion of a div sinking backward and then being pushed to the left once it has finished falling back. Although I am using CSS3 for this project, I am not very familiar with the animation pr ...

HTML/CSS: There is a sentence that has no spaces that is exiting outside a div

HTML: <div> bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb </div> CSS: div { width: 150px; border: 1px solid blue } DEMO: http://example.com QUESTION: How can we solve this issue? ...

Issues with implementing the Skeleton feature in the Alert module

Having an issue with a Skeleton component not taking full width inside an Alert component. It seems to be occupying less space than expected. https://i.stack.imgur.com/cMLEy.png Here is the relevant code snippet: <Alert icon={<NotificationsIcon s ...

Dynamically update CSS class properties with another

I have incorporated a bootstrap CSS tooltip class that is defined as follows: .tooltip{display:none;color:#000;text-align:left;} .tooltip.in{opacity:0.9;z-index:1030;height:auto;display:block} .tooltip.top{margin-top:-10px;text-align:center} ...

Adjusting div to not be absolutely positioned

Trying to create a div with animated borders, but it only works when positioned absolutely in the center. For illustration, here is the HTML and CSS code: .bb, .bb::before, .bb::after { position: absolute; top: 0; bottom: 0; left: 0; right: 0; ...

Switching from the .html extension to the absence of .html in Angular

I currently have this htaccess file set up: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] #R ...

The success callback method is no longer correctly referencing the variable due to a change in the AJAX request

Imagine you have a table in your HTML file with the following rows, where {{ }} represent variables: <tr id="{{ object.id }}"> <td class="name">{{ object.name }}</td> </tr> <tr id="{{ object.id }}"> <td class="nam ...

Adding a new element with Jquery when a dropdown option is selected

What is causing this issue to not function properly? <script> $(document).ready(function(){ $('#custom_field option').click(function(){ $('#custom_field_input').append('<tr><td></td> ...

retrieve the image name of the background using jQuery

How can I use jQuery to extract only the background image name from a div with a background image? I currently get 'http://localhost/xampp/uconnect/images/tour-networks-ss.png' but I only want 'tour-networks-ss.png' Any assistance wi ...

What is the procedure for automatically playing the next audio track in HTML5 after the current one finishes playing

When trying to play a single MP3 file, the code below is designed to skip to a specific part of the track and then start playing from that position. However, despite the cursor moving to the correct spot in the MP3, it fails to play upon clicking the Sta ...