You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Twenty Seventeen主题头部多余<br>标签导致空白问题求助

Fixing Unwanted White Space & Auto-Generated <br> Tags in Twenty Seventeen Theme

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:49:38