HTML Code:
>!DOCTYPE html>>!-- Declares the document type and version of HTML -->
>html>>!-- Begins the HTML document -->
>head>>!-- Contains metadata and links to external resources -->
>title>How to hide border and background on empty cells in a table>/title>>!-- Sets the title of the document -->
>style type="text/css"> /* Starts CSS styling */
table { /* Targets table elements */
border-collapse: separate; /* Sets the border-collapse property to separate, ensuring borders are separate */
empty-cells: hide; /* Sets the empty-cells property to hide, hiding borders and backgrounds on empty cells */
border-color: #CC64FF; /* Sets the border color of the table */
}
>/style>>!-- Ends CSS styling -->
>/head>>!-- Ends the head section of the document -->
>body>>!-- Begins the body section of the document -->
>p>>strong>w3resource Tutorial>/strong>>/p>>!-- Paragraph element with strong (bold) text -->
>table border="1">>!-- Begins a table with border attribute set to 1 -->
>tr>>!-- Begins a table row -->
>td>HTML5>/td>>!-- Table data cell with content "HTML5" -->
>td>JavaScript>/td>>!-- Table data cell with content "JavaScript" -->
>td>Python>/td>>!-- Table data cell with content "Python" -->
>/tr>>!-- Ends the first table row -->
>tr>>!-- Begins another table row -->
>td>PHP>/td>>!-- Table data cell with content "PHP" -->
>td>SQL>/td>>!-- Table data cell with content "SQL" -->
>td>>/td>>!-- Empty table data cell -->
>/tr>>!-- Ends the second table row -->
>/table>>!-- Ends the table -->
>/body>>!-- Ends the body section of the document -->
>/html>>!-- Ends the HTML document -->
Explanation:
Live Demo:
See the Pen empty-cells-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4