Styling with CSS or using tables: What should you choose?

Is there a way to replicate the frame=void functionality in CSS, or will I need to manually add frame=void to each table I create in the future?

<table border=1 rules=all frame=void>

I attempted to search for a solution online, but unfortunately, my efforts yielded no relevant results.

Answer №1

Using the old HTML presentational attributes is not recommended in modern web development. It is advised to avoid using any attributes on elements except for class, id, data-*, and specific attributes on input, audio, video, or img tags.

To achieve the same visual result, you can use CSS:

table {
    border-collapse: collapse;
    border-style:hidden;
}
table td {
    border-width: 1px;
    border-style: inset;
    border-color:black;
}

You can see a demonstration of this solution here: http://jsfiddle.net/HknDE/35/

Answer №2

Learn how to style tables using CSS and the border property:

table { border:none; }

CSS rules take precedence over traditional HTML attributes, as demonstrated in the example below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

    <title>CSS Styling for Tables</title>
    <style type="text/css">
        table {
            border:none;
        }
    </style>

</head>
<body>

    <h2>No Frame Attribute</h2>
    <table>
        <tbody>
            [Table rows and cells with numerical values]
        </tbody>
     </table>

    <h2>Frame = &quot;box&quot;</h2>
    <table frame="box">
        <tbody>
            [Table rows and cells with numerical values]
        </tbody>
     </table>

    <h2>Frame = &quot;void&quot;</h2>
    <table frame="void">
        <tbody>
            [Table rows and cells with numerical values]
        </tbody>
     </table>

</body>
</html>

Despite having different values for the frame attribute, all three tables above render identically due to the CSS styling overriding HTML attributes.

Answer №3

To remove the border from a table, simply set the tables border property to 0px. If you wish to keep inner borders, apply borders to the tr and td elements instead.

table { border:0px; }
tr { border-bottom:1px; }
tr.last { border-bottom:0px; }
td { border-right:1px; }
td.last { border-right:0px; }

You can also try something similar to this approach...

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

differences in rendering of flexbox align-items: center between Chrome and Firefox

As I was attempting to center a div inside another div using flexbox, an inconsistency in rendering between Firefox and Chrome caught my attention. In the scenario, there are 3 divs, each with properties display:flex, justify-content:center, and align-ite ...

Adding a dynamic click event in HTML using IONIC 4

I've created a function using Regex to detect URL links and replace them with a span tag. The replacement process is working fine, but I'm facing an issue where when I include (click)="myFunction()" in the span, it doesn't recognize the cli ...

Creating a vertical triangle pointing to the right as the border of a div element

Currently, I'm working on a mockup that includes the following elements. I am attempting to ensure that the triangular right end of the "Delay Your Payments" div matches the mockup exactly. To achieve this, I aim to use CSS without relying on sliced ...

Tips for effective page management

After creating a navbar in my project, I've come to the realization that it requires a component for each page and subpage. This seems redundant especially when dealing with multiple navigation options like shown in this image. Is it necessary to crea ...

What is the best way to incorporate and organize the templateHyper folder within an established web project directory?

Can anyone offer advice on how to properly integrate and organize the 'templateHyper' (Bootstrap template) folder within my web project? I've been developing a project using C#, JavaScript, HTML, and Bootstrap's templateHyper. I'm ...

Loading CSS files conditionally in Angular2's index.html

Currently, my index.html page features a dark theme: <base href="/"> <html> <head> <title>XXX</title> </head> <body> <link rel="stylesheet" type="text/css" href="assets/dark_room.css"> <my-app ...

Arrange the header and input within a div using flexbox to achieve different alignments

I need help aligning the header section vertically and ensuring responsiveness. Using margin-top isn't fully responsive, so I want to align the header at the beginning of the input field. { margin: 0px; padding: 0px; color: white; } #h ...

I'm attempting to create a dropdown menu, but I'm struggling to keep it open when I hover over an option

Seeking assistance as a beginner in coding. I am struggling with creating a dropdown menu option on my website. The issue is that the menu closes whenever I attempt to move my mouse to select other options. It seems to work fine when using the run option h ...

It's a mystery unraveling the source of CSS margins and padding

Could someone please help me analyze this webpage? I am trying to make the center of the page white up to the navigation bar, at the bottom of the page, and horizontally up to the shadows on both sides. I'm not sure where this extra padding is coming ...

Navigate through each element with a specific class name in a block of HTML code using

Currently, I am dealing with an HTML string that is being retrieved through AJAX. Let's assume it looks like this: var htmlString = '<div class="post"></div><div class="post"></div>'; I want to find a way to iterat ...

Top approach for creating/previewing a website using PHP, CSS, and MYSQL

When creating a website that will eventually be hosted on a remote server, what is the most effective way to code and test? Here are some examples of what I mean: - Develop locally on your computer and access files from there. Should libraries and databa ...

Tips for properly formatting a fixed table header

I'm currently facing an issue with the sticky header style in my data table. I have created a simple Angular component along with a specific directive: sticky.directive.ts @Directive({ selector: '[sticky]' }) export class StickyDirecti ...

Utilize the CakePHP form helper to include an HTML element within a form element

I am attempting to generate a basic html output that resembles the following <button class="searchbutton" id="search_button" type="submit">--> <i class="icon-search"></i> Search</button> when using Cake PHP's form h ...

Leveraging jQuery functions with dynamically generated DOM elements in JavaScript

On my website, I have a button that dynamically generates a dropdown menu, a textfield, and two buttons when clicked. The purpose of the textfield is to track the quantity selected, while the two buttons allow users to increase or decrease the value by 1. ...

Type Fury: A Multiplayer Gaming Hub for Speed Typists and Puzzle Solvers

Curious about creating a website that allows users to log in and participate in competitions against each other. Any tips on where to start or recommendations for existing frameworks would be greatly appreciated. Appreciate your help in advance! ...

Utilizing jQuery's POST Method to Fetch JSON Data on a Website

I've developed a Java REST API and now I want to retrieve JSON data on my website (which is built using HTML & CSS) by utilizing jQuery. The method to be used is POST, and here is the structure of my JSON: { "sessionID" : "25574", "interactiv ...

Cannot see the toggler button in Bootstrap 4 Navbar

I recently implemented the toggler button (hamburger icon) code in my HTML, but I'm facing an issue where the hamburger icon doesn't appear and looks blank when I resize my screen or view it on a smaller viewport. Here's the snippet of my H ...

Dealing with HTML fitting issues on screen dimensions

I'm currently working on a unique application that focuses on tracking and storing running/cycling routes through the integration of OSM/Google Maps. My goal is to have the application function seamlessly without any need for page scrolling, ensuring ...

The hover state of a div will not be lost if its parent element is not being hovered over

When hovering over the second, third, or fourth item, hidden text will appear on the left side. If you hover your cursor over the hidden text, it will disappear again. I want to be able to hover over the second item, move my cursor to "hide", and click o ...

Troubleshooting issues with applying styles in Vue framework when configured with webpack

I'm facing an issue with setting up the Vue framework using webpack. Specifically, I'm having trouble with styles not being applied when included in the <style> tag within single file components. Despite following several tutorials on this ...