header.php in WordPress Themes — a practical guide to WordPress header.php with clear examples you can reuse in real projects.
WordPress Theme Development Series (13/96). Prefer one article? Read the complete WordPress theme development tutorial.
Short description
Always call `wp_head()` before `</head>` and open the document structure cleanly.
header.php sketch
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<header class="site-header">
<a href="<?php echo esc_url(home_url('/')); ?>"><?php bloginfo('name'); ?></a>
<?php wp_nav_menu(['theme_location' => 'primary']); ?>
</header>