Logo

dev-resources.site

for different kinds of informations.

HTML table sticky header with borders

Published at
7/14/2022
Categories
html
table
header
css
Author
kzuraw
Categories
4 categories in total
html
open
table
open
header
open
css
open
Author
6 person written this
kzuraw
open
HTML table sticky header with borders

I recently had to create an HTML table with a sticky header. It turns out you need this piece of CSS to make it work:

thead {
  position: sticky;
  top: 0;
  background: white;
  text-align: left;
}
Enter fullscreen mode Exit fullscreen mode

Which is fine and awesome - but what if your header needs to have a border at the bottom? Adding border-bottom property won't work if header is sticky. After a few trial and error hours I found out (with help of Mateusz) that you can add empty table row under your table head:

<tr>
  <th style="height:1px; padding:0px; color:black" colspan="6"></th>
</tr>
Enter fullscreen mode Exit fullscreen mode

See this in action in this Codepen:

header Article's
30 articles in total
Favicon
Header in React
Favicon
Header in React
Favicon
Empty Excel Folders for Python programming
Favicon
Using cURL Custom Headers: A Simple Guide
Favicon
Comment ajouter un en-tΓͺte et un pied de page Γ  Word avec Python
Favicon
Solve the error "header files not found. no such file or directory".
Favicon
Understanding Word Header and Footer: Professional Advice for java developers
Favicon
How to Create a Resume Header [7+ Examples]
Favicon
HTML table sticky header with borders
Favicon
Java-How to Add or Remove Header and Footer in Word documents
Favicon
Remember to set Cache-Control headers on your secured pages
Favicon
CSS Shopping cart Icon with number of items.
Favicon
How to make a dynamic Twitter Header with Switchboard Canvas
Favicon
How to create header/footer (using HTML) in each page
Favicon
backdrop-filter: blur / header sticky
Favicon
Manage License Headers with Ease
Favicon
HTML tags | header
Favicon
[Java] Add Different Headers/Footers for Odd and Even Pages in Word
Favicon
SpringBoot RabbitMq Headers Exchange
Favicon
Insert Header and Footer to Word using Java
Favicon
Answer: How to specify column names while reading an Excel file using Pandas?
Favicon
Make a Material table header fix
Favicon
Sticky navbar from scratch using react
Favicon
So hard to make table header sticky
Favicon
How to remove IIS server information from the response header?
Favicon
Global Header in Swagger-Ui Spring-Boot
Favicon
HTTP Headers Explained
Favicon
Java add image and text header/footer to Excel
Favicon
Add Header and Footer to an Existing PDF Document in Java
Favicon
Security Headers to use on your webserver

Featured ones: