October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
CSS tables

How to Remove Unwanted Space in wkhtmltopdf Table Rows

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start by resetting the table’s spacing and cell metrics: collapse borders, set border spacing and cell padding to zero, and give cells an explicit line height. Then check inherited styles and page-break behavior. If the gap appears only in wkhtmltopdf—not in a current browser—it may be a renderer-specific issue rather than a spacing rule you have overlooked.

Reset table spacing and cell metrics

Use this as a diagnostic baseline. It removes the most common sources of unintended row height while keeping the table’s normal display behavior:

table {
  border-collapse: collapse;
  border-spacing: 0;
}

table td,
table th {
  padding: 0;
  line-height: 1.2;
  vertical-align: top;
}

tr,
td,
th {
  page-break-inside: avoid;
}

Apply it to the affected table first, rather than changing every table in a large document. If the table already has a class, scope the rules to it—for example, .invoice-table td—so unrelated tables keep their intended styling. Regenerate the PDF after the change and compare the same rows before and after.

The 1.2 line-height is a starting point, not a universal ideal. Use the smallest value that remains legible with the chosen font and content, and inspect the rendered PDF: font metrics and wrapped text affect the resulting line boxes. If zero padding makes the table hard to read, add back only the amount of padding the design needs.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
  • Convert your PDF files into Word, Excel & Co. the easy way
  • Convert scanned documents thanks to our new 2022 OCR technology
  • Adjustable conversion settings
  • No subscription! Lifetime license!
  • Compatible with Windows 11, 10, 8.1, 7 - Internet connection required

Remove HTML spacing attributes

Inspect the table markup for legacy cellpadding or cellspacing attributes. Remove them, or set them to zero while diagnosing:

<table cellpadding="0" cellspacing="0">

CSS and markup can both influence the table’s spacing. A CSS reset may not reveal the cause if an attribute or a more specific stylesheet rule is still setting a nonzero value.

Find which style is making the row tall

A table row’s height is not just the height of the text. CSS 2.1’s table-height rules account for cell heights, borders, and spacing, so padding, border treatment, and line-height can all contribute to the visible gap. See the CSS 2.1 table model for the underlying layout rules.

Rank #2
Doxillion Free Document Converter – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
  • Convert over 50 document file formats.
  • Preview your files from Doxillion before converting them.
  • Use batch conversion to convert thousands of files at once.
  • Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
  • Burn your converted or original files directly to disc.
  1. Check the cascade. Inspect styles for table, tbody, tr, td, and th. Look for inherited or more specific rules that set padding, margins, border spacing, font size, or line-height.
  2. Check the content. A cell with wrapped text, a larger font, or a taller inline element can make the entire row taller. Compare the cells in the same row rather than looking only at the cell where the gap is easiest to see.
  3. Check the computed result. In browser developer tools, inspect the computed styles for the affected elements. This can show whether another selector overrides the reset. Browser inspection is useful for finding CSS conflicts, but it does not guarantee wkhtmltopdf will lay out the page identically.
  4. Change one variable at a time. Apply the diagnostic rules, regenerate the PDF, then adjust only the property that restores a gap. This is more reliable than adding multiple overrides whose effects are difficult to separate.

Margins are worth checking, but table cells do not behave like ordinary block boxes in every respect. Focus on the computed table and cell properties, plus the font and line metrics of the content inside them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check whether the whitespace is a wkhtmltopdf rendering difference

If the table looks right in a current browser but has oversized line-height or misaligned values in the PDF, the CSS may not be the whole explanation. A 2020 report for wkhtmltopdf 0.12.6 with patched Qt described extra white space and row values that did not align as they did in Chrome. That is evidence of a renderer-specific problem in that reported setup, not proof that every wkhtmltopdf version or table will behave the same way.

Reduce the issue to a small HTML file containing the affected table, its CSS, and representative text. Generate a PDF from that file and compare it with the browser rendering. If the whitespace persists only in wkhtmltopdf after spacing and line-height have been normalized, you have a focused reproduction for diagnosing the renderer rather than an expanding set of page-wide CSS overrides.

Rank #3
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
  • LIFETIME License for 1 Windows PC or Laptop. 5GB MobiDrive Cloud Storage Included.

Handle gaps at page breaks and rowspan cells

A gap that appears only near a page boundary needs a different diagnosis from a gap between every row. A documented wkhtmltopdf issue describes a rowspan cell exceeding the adjacent row’s height before a page break. That can look like ordinary row spacing even though the trigger is pagination.

  1. Confirm the location. Check whether the extra height occurs throughout the table or only where it crosses a page boundary.
  2. Test break avoidance. The diagnostic CSS applies page-break-inside: avoid to rows and cells. Test it on the affected table and inspect the result; pagination constraints may change where content fits.
  3. Isolate rowspans. If a cell spans multiple rows, make a reduced example with that cell and the neighboring rows. Test the page break with and without the span to see whether the issue follows it.
  4. Preserve table semantics. Avoid changing tr to display: block as a first-line fix. That changes the element’s table formatting behavior and can lead to problems such as double borders.

Break-avoidance rules are a test, not a guarantee that every row will stay together in every PDF. Verify the page layout after applying them, especially around long tables and spanning cells.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Stabilize columns and text scaling

If row heights seem to change along with column widths, text wrapping may be part of the problem. Make column widths explicit with a <colgroup>, or test table-layout: fixed when the design has known column widths. Fixed layout can make the intended widths more predictable, but it can also cause content to wrap or overflow differently, so check the final output rather than assuming it will remove all extra height.

Rank #4
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
  • Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.
  • Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
  • Read & Annotate. Enjoy intuitive reading modes and powerful tools to comment, highlight, and mark up PDFs.
  • Create & Manage PDFs. Create new PDFs, combine multiple files, scan documents, and compress for easy sharing.
  • Fill & Sign Forms. Complete forms and digitally sign documents with secure e-signature tools.
<table class="report-table">
  <colgroup>
    <col style="width: 30%">
    <col style="width: 70%">
  </colgroup>
  <thead>
    <tr><th>Item</th><th>Details</th></tr>
  </thead>
  <tbody>
    <tr><td>Example</td><td>A fixed column layout can help test wrapping.</td></tr>
  </tbody>
</table>
.report-table {
  width: 100%;
  table-layout: fixed;
}

A wkhtmltopdf troubleshooting suggestion also recommends testing font-size: 100% where text scaling appears to produce alignment or height mismatches. Use it as a controlled test on the affected content, not as an unexplained global rule. If it changes the result, compare the computed font size and line-height in the browser and the generated PDF.

Compare remedies by symptom

What you see What to test first Why
Similar gaps between rows throughout the table Border collapse, border spacing, cell padding, line-height, and inherited styles These values directly affect the table and cell geometry.
Whitespace only near a page boundary page-break-inside: avoid and a reduced example of the affected rows Pagination can expose a break-related problem, particularly with rowspans.
One row is tall and its text wraps differently Column widths, font size, line-height, and the content of each cell Wrapping and cell content affect the row’s required height.
Browser output is correct, but the PDF is not A minimal reproduction in wkhtmltopdf; then consider a maintained renderer if the defect persists The difference may be renderer-specific rather than a general CSS error.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common mistakes and troubleshooting

The reset seems to have no effect

Check the computed styles and the specificity of existing rules. A more specific selector, inline style, or later stylesheet declaration may override the reset. Scope your test to the affected table and inspect table, tbody, tr, and the cells rather than repeatedly adding broader rules.

The gap gets smaller but does not disappear

Check line-height, font size, and content wrapping after checking padding and border spacing. A row must accommodate its tallest cell. If the visible space is actually within a cell’s text area, reducing table spacing alone will not remove it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
  • ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
  • MAXIMUM FUNCIONALITY – create interactive forms, compare PDFs, bates numbering, find and replace text or colors, convert documents, OCR engine, comment, highlight, fill out and print forms, document protection and others
  • EASY TO INSTALL AND USE – well-structured user-interface, in-program instructions, free tech support whenever you need it
  • GREAT VALUE FOR MONEY - why spend a fortune if you can have maximum functionality at a reasonable price - this also fits the requirements of companies very well

The problem moves or worsens after a page-break rule

Check the page boundary and any spanning cells. Keep the change scoped to the table under test and inspect nearby pages as well as the original gap. Avoid using display: block on table rows to force pagination; it changes the table layout model rather than directly fixing the source of unwanted spacing.

Widths or row heights vary unpredictably

Try explicit columns or fixed table layout, and check whether text scaling is involved. A rule that improves column consistency can alter wrapping, so verify both widths and row heights in the resulting PDF.

Only wkhtmltopdf remains wrong

The wkhtmltopdf repository was archived and made read-only on January 2, 2023. Persistent renderer defects may therefore not receive upstream fixes. Keep a reduced reproduction, and if the output is still unacceptable after the CSS and pagination checks, evaluate a maintained HTML-to-PDF renderer before investing in increasingly complex workarounds. The project’s usage documentation remains useful for command-line options and HTML examples.

Or skip the browser setup

If your goal is to capture a clean visual reference of a web page while diagnosing a table, ScreenshotNeo can return a screenshot or PDF from one GET request. It does not repair wkhtmltopdf’s table layout; use it to capture a webpage, not as a substitute for testing the HTML-to-PDF renderer that produces your affected document. ScreenshotNeo is a website screenshot API and MCP server for developers, made by Yorker Media. See ScreenshotNeo and its API documentation.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Quick Recap

Bestseller No. 1
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
Convert your PDF files into Word, Excel & Co. the easy way; Convert scanned documents thanks to our new 2022 OCR technology
$29.99
Bestseller No. 2
Doxillion Free Document Converter – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
Doxillion Free Document Converter – Converts DOCX, DOC, PDF, WPS and Many More Files Quickly [Download]
Convert over 50 document file formats.; Preview your files from Doxillion before converting them.
Bestseller No. 3
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.; CREATE, COMBINE, SCAN and COMPRESS PDFs
$99.99
Bestseller No. 4
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.; Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
$99.99
Bestseller No. 5
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
$29.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.