Twenty Seventeen主题头部多余<br>标签导致空白问题求助
It looks like the core issue here is that you're manually adding a full HTML document structure (<!DOCTYPE html>, <html>, <head>) to your template, but the Twenty Seventeen theme already handles this automatically via its modular template system. When you duplicate these root-level tags, you're creating a conflict that leads to malformed HTML—those extra <br> tags are the browser's messy attempt to parse overlapping, invalid markup, which generates the unwanted white space.
Here's how to fix this properly:
1. Remove the full HTML wrapper
You don’t need to write the entire <html> or <head> section yourself. Twenty Seventeen’s header.php file already outputs all necessary head content (including title tags, styles, scripts, and meta data) when you call it via WordPress’s template functions.
2. Create a proper custom template file
Instead of raw HTML, make a custom template in your theme directory (e.g., single-column-template.php) with this structure:
<?php /* Template Name: Single Column Template */ // Load the theme's default header (includes valid <head> structure) get_header(); ?> <header class="custom-page-header"> Interested in our website and technology reviews? Want further? Submit the form below. </header> <main class="custom-page-content"> <!-- Your main content here --> </main> <?php // Load the theme's default footer to complete the page structure get_footer(); ?>
3. Customize the page title correctly
Skip manually adding a <title> tag—WordPress handles this via hooks. To set a custom title for this template, add this code right after the template comment:
add_filter('document_title_parts', 'custom_single_column_title'); function custom_single_column_title($title_parts) { $title_parts['title'] = 'Single Column Template'; return $title_parts; }
4. Why your CSS didn’t work
The CSS you tried targets elements inside .site-content, but the white space wasn’t coming from there—it stemmed from broken HTML parsing caused by duplicate root tags. Fixing the template structure will eliminate those auto-generated <br> tags and the associated white space entirely, no extra CSS needed.
Once you’ve set up this template, assign it to your page via the WordPress editor (under Page Attributes > Template) and the issue should be resolved.
内容的提问来源于stack exchange,提问作者timv

