Unable to style table borders using CSS

I'm having trouble getting the borders to show up on my tables in my application. I added the "border: solid 2px black" line to my CSS, but nothing seems to be changing. Can anyone point out what I might be doing wrong? Here is my CSS:

table {
  margin-top: 0.75em;
  border: solid 2px black;
}

th {
  font-size: 1.2em;
  text-align: left;
  padding-left: 0;
}

th a {
  display: block;
  position: relative;
}

th a:link,
th a:visited,
th a:active,
th a:hover {
  color: #333;
  font-weight: 600;
  text-decoration: none;
  padding: 0;
}

th a:hover {
  color: #000;
}

th.asc a,
th.desc a {
  margin-right: .75em;
}

th.asc a:after,
th.desc a:after {
  display: block;
  position: absolute;
  right: 0em;
  top: 0;
  font-size: 0.75em;
}

th.asc a:after {
  content: '▲';
}

th.desc a:after {
  content: '▼';
}

td {
  padding: 0.25em 2em 0.25em 0em;
  border: 0 none;
}

tr.pager td {
  padding: 0 0.25em 0 0;
}
<table>
  <tr>
    <th>
      Project ID
    </th>
    <th>
      Test1
    </th>
    <th>
      Test2
    </th>
    <th>
      Test3
    </th>
    <th>
      Test4
    </th>
    <th>
      Test5
    </th>
  </tr>
</table>

Answer №1

After running the code, I noticed that the table now has a border! It's possible that there is another CSS code conflicting with your style, so try using !important to override it.

border: solid 2px black !important;


If you want to add borders to every cell in the table, you can use the following code:

table, th, td {
border: 1px solid black;
border-collapse: collapse;}

Answer №2

After some investigation, I discovered the issue was a simple one. All that was needed was to clear the cache by pressing Ctrl + F5. This action ultimately resolved the CSS changes I was encountering.

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

Embracing the power of AngularJS within the MVC Razor

As someone who is new to Angular and has been working on some basic projects, I am currently facing a challenge. I am attempting to transition some views to utilize Angular, but I have hit a roadblock. Is there anyone who can assist me in achieving the f ...

Image link in HTML / CSS not functional on one half of the image

My webpage has an image thumbnail with accompanying text positioned to the right. I have a hyperlink on the image that should open the full-size version when clicked. However, there seems to be an issue where the hyper link only activates on the lower hal ...

Using CSS3 to clear floats without altering the HTML structure

Despite searching for multiple solutions to this issue, I have yet to find one that works without requiring me to modify my HTML code. Here is the current HTML in question: <div class="name">Daiel</div> <div class="amount">30€</div ...

Creating a simulated dropdown menu using only CSS

I was able to create a select menu using only CSS, following some code I found. However, I am now facing an issue with overlaying divs. Whenever I hover or click on the "select menu", all the divs below it move down. I've attempted to adjust the z-i ...

The content loses functionality once I add an overlay color to the background image div

I'm facing an issue with a div that has a background image, text, and a button in the center. Whenever I add an overlay color on top of the background image, the text and button seem to be disabled or unclickable. My goal is to ensure that the Read M ...

Creating a visually appealing chart similar to Excel can be achieved using JavaScript with a whopping 64382 lines of JSON data. No need for Chart.js or any additional tools - simply rely on JavaScript, HTML, and CSS to

I have a project that is due in just a few hours and I need to create a detailed chart using a large set of 64382 lines of JSON data. My knowledge of javascript is limited, so I am struggling to come up with ideas on how to approach this task. While I have ...

Enhance Material UI BottomNavigationAction by adding a pseudo-element

Trying to enhance a selected item with an additional UI element using a pseudo-element. Specifically, looking to add a line above the menu item. https://i.stack.imgur.com/MZnmw.png The code I've implemented is not displaying the desired line: const ...

Swapping stylesheets using a hyperlink - a simple guide

Currently, I am creating a website that utilizes PHP, XHTML strict, and jQuery. The main goal is to ensure the site is adaptable for mobile and desktop devices by implementing the principles of Responsive Web Design. This involves serving different stylesh ...

How can we display or conceal text indicating the age of a patient based on the value returned from selectedPatient.age in a React application?

Hello, I am looking to dynamically display the age in years on the screen based on the value retrieved from selectedPatient.age, toggling between visible and hidden states. import React, { useContext } from 'react'; import { useHistory } from &ap ...

Building a Horizontal Line Component in ReactJS

Looking for help with my login page design. I have two login buttons - one for regular login and one for Google login. I want to add a stylish horizontal line with the word "OR" between the buttons, similar to the image in the link provided. https://i.sst ...

Tips for activating hover effect on child components by hovering over the parent container?

At the moment, I am tackling an issue with CSS in a nextJS web application. The problem lies in a parent div element that contains multiple child elements. My goal is for hovering over the parent div to trigger changes on the child elements as well. Here& ...

Full-Width Bootstrap Sticky Containerized

I am trying to create a sticky sidebar that fills the full width of the container in Bootstrap 4. I have written the code below, and while the sticky functionality works perfectly, the sidebar does not span the full width of the container. Can someone pl ...

Make multiple images in one row resize proportionally instead of wrapping them to the next line

My phone's screen is small and I want the three images to remain in the same row. In case they don't fit, they should shrink proportionately to maintain alignment (refer to image at the bottom). Consider the code snippet below: <div id="exam ...

Having issues with my toggler functionality. I attempted to place the JavaScript CDN both at the top and bottom of the code, but unfortunately, it is still not

I recently attempted to place the JavaScript CDN at the top of my code, but unfortunately, it did not have the desired effect. My intention was to make the navigation bar on my website responsive and I utilized a toggler in the process. While the navbar di ...

Revamp your Redux Form with a fresh new 'Field' label style

Is there a way to style the label of a Redux Form field? The Redux Form API does not provide information on how to apply styles to the label. Despite applying the classes.formField class, the label itself remains unstyled. Could this be an issue with inhe ...

The JSON string fails to deserialize and returns a null value

{ "apple": { "A": "xyz", "B": "abc", "C": "jkl" }, "banana": { "A": "lotus", "B": "oil", "C": &qu ...

The content in the div is not contained within a border in the css/html

I am struggling with a div wrapper that has a border, but the border is not wrapping around the content and I can't figure out why. Here is my issue on screen: This is what I want it to look like: Below is my HTML code: <div class="event_area_t ...

Eliminate Bootstrap's styling from HTML characters

The default heavy checkmark (✔) appears as "✔" Bootstrap 4.3 seems to be altering the appearance of the check, causing it to display as a thick-green one, which is not what I prefer -- see example below I want to remove Bootstrap's styli ...

increasing the size of a picture without resorting to a pop-up window

Struggling to implement a product details tab within a table that features a clickable image. When the image is clicked, it should enlarge but the width doesn't adjust accordingly. I'm using bootstrap 5.3 and can't seem to identify the root ...

Struggling with CSS on your website and need some help?

Working on a website project with my own design, I ran into an issue regarding the positioning of the menu style. Describing this problem can be challenging, so let's start by looking at some images. What it should look like: Current appearance ...