header.php

📦 WordPress
✨ The Prompt Phrase
header.php

💻 Code Preview

📦 All-in-One Code
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>header.php - Interactive Tutorial</title>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg-primary: #0f0f23;
            --bg-secondary: #1a1a2e;
            --bg-card: #16213e;
            --accent-purple: #a855f7;
            --accent-blue: #3b82f6;
            --accent-green: #10b981;
            --accent-pink: #ec4899;
            --text-primary: #f8fafc;
            --text-secondary: #cbd5e1;
            --text-muted: #94a3b8;
            --border-color: #334155;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Poppins', sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.6;
            overflow-x: hidden;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        /* Hero Section */
        .hero {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
            position: relative;
            overflow: hidden;
        }

        .hero::before {
            content: '';
            position: absolute;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
            background-size: 50px 50px;
            animation: moveGrid 20s linear infinite;
        }

        @keyframes moveGrid {
            0% { transform: translate(0, 0); }
            100% { transform: translate(50px, 50px); }
        }

        .hero-content {
            text-align: center;
            z-index: 1;
            animation: fadeInUp 1s ease;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .hero h1 {
            font-size: 4rem;
            font-weight: 700;
            margin-bottom: 20px;
            text-shadow: 0 0 30px rgba(0,0,0,0.3);
        }

        .hero .code-highlight {
            background: rgba(0,0,0,0.3);
            padding: 10px 30px;
            border-radius: 15px;
            font-family: 'Fira Code', monospace;
            display: inline-block;
            backdrop-filter: blur(10px);
        }

        .hero p {
            font-size: 1.5rem;
            margin-top: 20px;
            opacity: 0.9;
        }

        .scroll-indicator {
            position: absolute;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            animation: bounce 2s infinite;
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
            40% { transform: translateX(-50%) translateY(-10px); }
            60% { transform: translateX(-50%) translateY(-5px); }
        }

        /* Progress Bar */
        .progress-bar {
            position: fixed;
            top: 0;
            left: 0;
            height: 4px;
            background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue), var(--accent-green));
            z-index: 1000;
            transition: width 0.3s ease;
        }

        /* Section Styles */
        section {
            padding: 80px 0;
            opacity: 0;
            transform: translateY(30px);
            transition: all 0.6s ease;
        }

        section.visible {
            opacity: 1;
            transform: translateY(0);
        }

        .section-header {
            text-align: center;
            margin-bottom: 60px;
        }

        .section-header h2 {
            font-size: 3rem;
            background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 15px;
        }

        .section-header p {
            color: var(--text-secondary);
            font-size: 1.2rem;
        }

        /* Card Styles */
        .card {
            background: var(--bg-card);
            border-radius: 20px;
            padding: 40px;
            margin-bottom: 30px;
            border: 1px solid var(--border-color);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
            transform: scaleX(0);
            transition: transform 0.3s ease;
        }

        .card:hover::before {
            transform: scaleX(1);
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.3);
        }

        .card h3 {
            font-size: 1.8rem;
            margin-bottom: 20px;
            color: var(--accent-purple);
        }

        /* Code Block */
        .code-block {
            background: #1e1e1e;
            border-radius: 15px;
            padding: 25px;
            margin: 20px 0;
            position: relative;
            font-family: 'Fira Code', monospace;
            overflow-x: auto;
        }

        .code-block .copy-btn {
            position: absolute;
            top: 15px;
            right: 15px;
            background: var(--accent-purple);
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: all 0.3s ease;
        }

        .code-block .copy-btn:hover {
            background: var(--accent-blue);
            transform: scale(1.05);
        }

        .code-block pre {
            margin: 0;
            color: #e0e0e0;
        }

        .code-line {
            display: block;
            padding: 2px 0;
        }

        .comment { color: #6a9955; }
        .keyword { color: #569cd6; }
        .function { color: #dcdcaa; }
        .string { color: #ce9178; }
        .tag { color: #4ec9b0; }

        /* Grid Layout */
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 30px;
            margin: 40px 0;
        }

        .grid-item {
            background: var(--bg-card);
            padding: 30px;
            border-radius: 15px;
            border: 1px solid var(--border-color);
            transition: all 0.3s ease;
        }

        .grid-item:hover {
            border-color: var(--accent-purple);
            transform: translateY(-5px);
        }

        .grid-item .icon {
            font-size: 3rem;
            margin-bottom: 15px;
        }

        /* Tabs */
        .tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 30px;
            flex-wrap: wrap;
        }

        .tab-btn {
            background: var(--bg-secondary);
            color: var(--text-secondary);
            border: 1px solid var(--border-color);
            padding: 12px 24px;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1rem;
        }

        .tab-btn:hover {
            border-color: var(--accent-purple);
        }

        .tab-btn.active {
            background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
            color: white;
            border-color: transparent;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
            animation: fadeIn 0.5s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        /* Quiz Styles */
        .quiz-question {
            background: var(--bg-card);
            padding: 30px;
            border-radius: 15px;
            margin-bottom: 20px;
            border: 1px solid var(--border-color);
        }

        .quiz-options {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }

        .quiz-option {
            background: var(--bg-secondary);
            padding: 15px 20px;
            border-radius: 10px;
            border: 2px solid var(--border-color);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .quiz-option:hover {
            border-color: var(--accent-purple);
            transform: translateX(5px);
        }

        .quiz-option.correct {
            border-color: var(--accent-green);
            background: rgba(16, 185, 129, 0.1);
        }

        .quiz-option.incorrect {
            border-color: #ef4444;
            background: rgba(239, 68, 68, 0.1);
        }

        .quiz-feedback {
            margin-top: 20px;
            padding: 15px;
            border-radius: 10px;
            display: none;
        }

        .quiz-feedback.show {
            display: block;
            animation: fadeIn 0.5s ease;
        }

        .quiz-feedback.correct {
            background: rgba(16, 185, 129, 0.1);
            border: 1px solid var(--accent-green);
            color: var(--accent-green);
        }

        .quiz-feedback.incorrect {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid #ef4444;
            color: #ef4444;
        }

        /* Summary Card */
        .summary-card {
            background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.1));
            border: 2px solid var(--accent-purple);
            border-radius: 20px;
            padding: 40px;
            margin: 40px 0;
        }

        .summary-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 30px;
        }

        .summary-item {
            background: var(--bg-card);
            padding: 20px;
            border-radius: 10px;
            border-left: 4px solid var(--accent-purple);
        }

        .summary-item strong {
            color: var(--accent-purple);
            display: block;
            margin-bottom: 10px;
        }

        /* Footer */
        footer {
            background: var(--bg-secondary);
            padding: 40px 20px;
            text-align: center;
            border-top: 1px solid var(--border-color);
        }

        footer p {
            color: var(--text-muted);
        }

        .badge {
            display: inline-block;
            background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 0.9rem;
            margin: 5px;
        }

        /* Tooltip */
        .tooltip {
            position: relative;
            display: inline-block;
            border-bottom: 2px dotted var(--accent-purple);
            cursor: help;
        }

        .tooltip .tooltiptext {
            visibility: hidden;
            background: var(--bg-card);
            color: var(--text-primary);
            text-align: center;
            padding: 10px 15px;
            border-radius: 10px;
            border: 1px solid var(--accent-purple);
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
            white-space: nowrap;
        }

        .tooltip:hover .tooltiptext {
            visibility: visible;
            opacity: 1;
        }

        /* Confetti */
        .confetti {
            position: fixed;
            width: 10px;
            height: 10px;
            background: var(--accent-purple);
            position: absolute;
            animation: confetti-fall 3s linear forwards;
        }

        @keyframes confetti-fall {
            to {
                transform: translateY(100vh) rotate(360deg);
                opacity: 0;
            }
        }

        /* Responsive */
        @media (max-width: 768px) {
            .hero h1 {
                font-size: 2.5rem;
            }

            .hero p {
                font-size: 1.2rem;
            }

            .section-header h2 {
                font-size: 2rem;
            }

            .grid {
                grid-template-columns: 1fr;
            }
        }

        /* Warning/Mistake Box */
        .warning-box {
            background: rgba(239, 68, 68, 0.1);
            border-left: 4px solid #ef4444;
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
        }

        .success-box {
            background: rgba(16, 185, 129, 0.1);
            border-left: 4px solid var(--accent-green);
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
        }

        .info-box {
            background: rgba(59, 130, 246, 0.1);
            border-left: 4px solid var(--accent-blue);
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
        }

        /* Live Demo */
        .demo-container {
            background: var(--bg-secondary);
            border-radius: 15px;
            padding: 30px;
            margin: 30px 0;
            border: 2px solid var(--border-color);
        }

        .demo-preview {
            background: white;
            color: #333;
            padding: 20px;
            border-radius: 10px;
            margin-top: 20px;
            min-height: 200px;
        }
    </style>
</head>
<body>
    <div class="progress-bar" id="progressBar"></div>

    <!-- Hero Section -->
    <section class="hero">
        <div class="hero-content">
            <h1>🎯 Master WordPress</h1>
            <div class="code-highlight">header.php</div>
            <p>Your Gateway to WordPress Theme Development</p>
        </div>
        <div class="scroll-indicator">
            <span style="font-size: 2rem;">⬇️</span>
        </div>
    </section>

    <!-- What Is It Section -->
    <section id="what-is-it">
        <div class="container">
            <div class="section-header">
                <h2>🤔 What Is header.php?</h2>
                <p>Let's break down this essential WordPress file</p>
            </div>

            <div class="card">
                <h3>📄 The Foundation of Every WordPress Page</h3>
                <p><strong>header.php</strong> is a <span class="tooltip">template file<span class="tooltiptext">A PHP file that controls how content appears</span></span> in WordPress themes that contains the HTML structure for the top portion of your website. It's like the "head" of your website - everything users see first!</p>
                
                <div class="info-box">
                    <strong>🎨 Think of it like this:</strong>
                    <p>If your website is a house, <code>header.php</code> is the roof, front door, and entrance hall. Every visitor passes through it first!</p>
                </div>

                <div class="grid">
                    <div class="grid-item">
                        <div class="icon">🏠</div>
                        <h4>Location</h4>
                        <p>Found in your theme's root directory:<br><code>/wp-content/themes/your-theme/</code></p>
                    </div>
                    <div class="grid-item">
                        <div class="icon">🔧</div>
                        <h4>File Type</h4>
                        <p>PHP template file that outputs HTML</p>
                    </div>
                    <div class="grid-item">
                        <div class="icon">🎯</div>
                        <h4>Purpose</h4>
                        <p>Controls the header section across all pages</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Why Use It Section -->
    <section id="why-use-it">
        <div class="container">
            <div class="section-header">
                <h2>💡 Why Use header.php?</h2>
                <p>The power of centralized header management</p>
            </div>

            <div class="grid">
                <div class="card">
                    <h3>♻️ DRY Principle</h3>
                    <p><strong>Don't Repeat Yourself!</strong> Instead of writing the same header code on every page, write it once in header.php and include it everywhere.</p>
                </div>

                <div class="card">
                    <h3>🚀 Easy Updates</h3>
                    <p>Change your logo, navigation, or meta tags in ONE place, and it updates across your entire website instantly!</p>
                </div>

                <div class="card">
                    <h3>🎨 Consistent Design</h3>
                    <p>Ensures every page has the same header structure, maintaining brand consistency and user experience.</p>
                </div>

                <div class="card">
                    <h3>🔍 SEO Benefits</h3>
                    <p>Centralize meta tags, structured data, and critical SEO elements for better search engine visibility.</p>
                </div>

                <div class="card">
                    <h3>📱 Responsive Control</h3>
                    <p>Manage mobile navigation, viewport settings, and responsive behavior from a single file.</p>
                </div>

                <div class="card">
                    <h3>🔌 Plugin Integration</h3>
                    <p>Plugins can hook into the header, adding tracking codes, styles, and scripts automatically.</p>
                </div>
            </div>
        </div>
    </section>

    <!-- How It Works Section -->
    <section id="how-it-works">
        <div class="container">
            <div class="section-header">
                <h2>⚙️ How Does It Work?</h2>
                <p>Step-by-step breakdown of header.php magic</p>
            </div>

            <div class="card">
                <h3>🔄 The WordPress Template Hierarchy Flow</h3>
                
                <div class="info-box">
                    <strong>Step 1: Page Request</strong>
                    <p>User visits your WordPress site → WordPress loads the appropriate template file (index.php, page.php, single.php, etc.)</p>
                </div>

                <div class="info-box">
                    <strong>Step 2: Header Inclusion</strong>
                    <p>Template file calls <code>get_header()</code> → WordPress includes header.php</p>
                </div>

                <div class="info-box">
                    <strong>Step 3: Header Rendering</strong>
                    <p>header.php executes → Outputs HTML, calls <code>wp_head()</code> hook → Plugins add their code</p>
                </div>

                <div class="info-box">
                    <strong>Step 4: Content Display</strong>
                    <p>Main template continues → Displays page content → Calls footer.php</p>
                </div>
            </div>

            <div class="card">
                <h3>📝 Basic Structure of header.php</h3>
                
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">📋 Copy</button>
                    <pre><code><span class="tag">&lt;!DOCTYPE html&gt;</span>
<span class="tag">&lt;html</span> <span class="keyword">&lt;?php</span> <span class="function">language_attributes</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="tag">&lt;head&gt;</span>
    <span class="tag">&lt;meta</span> charset=<span class="string">"&lt;?php bloginfo('charset'); ?&gt;"</span><span class="tag">&gt;</span>
    <span class="tag">&lt;meta</span> name=<span class="string">"viewport"</span> content=<span class="string">"width=device-width, initial-scale=1"</span><span class="tag">&gt;</span>
    <span class="keyword">&lt;?php</span> <span class="function">wp_head</span>(); <span class="keyword">?&gt;</span> <span class="comment">&lt;!-- Critical WordPress hook --&gt;</span>
<span class="tag">&lt;/head&gt;</span>

<span class="tag">&lt;body</span> <span class="keyword">&lt;?php</span> <span class="function">body_class</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="keyword">&lt;?php</span> <span class="function">wp_body_open</span>(); <span class="keyword">?&gt;</span> <span class="comment">&lt;!-- Hook for plugins --&gt;</span>

<span class="tag">&lt;header</span> class=<span class="string">"site-header"</span><span class="tag">&gt;</span>
    <span class="tag">&lt;div</span> class=<span class="string">"container"</span><span class="tag">&gt;</span>
        <span class="comment">&lt;!-- Logo --&gt;</span>
        <span class="tag">&lt;div</span> class=<span class="string">"site-logo"</span><span class="tag">&gt;</span>
            <span class="tag">&lt;a</span> href=<span class="string">"&lt;?php echo esc_url(home_url('/')); ?&gt;"</span><span class="tag">&gt;</span>
                <span class="keyword">&lt;?php</span> <span class="function">bloginfo</span>(<span class="string">'name'</span>); <span class="keyword">?&gt;</span>
            <span class="tag">&lt;/a&gt;</span>
        <span class="tag">&lt;/div&gt;</span>

        <span class="comment">&lt;!-- Navigation --&gt;</span>
        <span class="tag">&lt;nav</span> class=<span class="string">"main-navigation"</span><span class="tag">&gt;</span>
            <span class="keyword">&lt;?php</span>
                <span class="function">wp_nav_menu</span>(<span class="keyword">array</span>(
                    <span class="string">'theme_location'</span> =&gt; <span class="string">'primary'</span>,
                    <span class="string">'menu_class'</span> =&gt; <span class="string">'nav-menu'</span>,
                ));
            <span class="keyword">?&gt;</span>
        <span class="tag">&lt;/nav&gt;</span>
    <span class="tag">&lt;/div&gt;</span>
<span class="tag">&lt;/header&gt;</span></code></pre>
                </div>
            </div>
        </div>
    </section>

    <!-- Live Demo Section -->
    <section id="live-demo">
        <div class="container">
            <div class="section-header">
                <h2>🎮 Interactive Demo</h2>
                <p>See header.php components in action</p>
            </div>

            <div class="card">
                <div class="tabs">
                    <button class="tab-btn active" onclick="switchTab(event, 'basic')">Basic Header</button>
                    <button class="tab-btn" onclick="switchTab(event, 'advanced')">Advanced Header</button>
                    <button class="tab-btn" onclick="switchTab(event, 'hooks')">WordPress Hooks</button>
                </div>

                <div id="basic" class="tab-content active">
                    <h3>🎯 Basic Header Structure</h3>
                    <p>The minimal header.php every WordPress theme needs:</p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">📋 Copy</button>
                        <pre><code><span class="comment">&lt;!-- Minimal header.php --&gt;</span>
<span class="tag">&lt;!DOCTYPE html&gt;</span>
<span class="tag">&lt;html</span> <span class="keyword">&lt;?php</span> <span class="function">language_attributes</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="tag">&lt;head&gt;</span>
    <span class="tag">&lt;meta</span> charset=<span class="string">"&lt;?php bloginfo('charset'); ?&gt;"</span><span class="tag">&gt;</span>
    <span class="keyword">&lt;?php</span> <span class="function">wp_head</span>(); <span class="keyword">?&gt;</span>
<span class="tag">&lt;/head&gt;</span>
<span class="tag">&lt;body</span> <span class="keyword">&lt;?php</span> <span class="function">body_class</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="keyword">&lt;?php</span> <span class="function">wp_body_open</span>(); <span class="keyword">?&gt;</span></code></pre>
                    </div>
                </div>

                <div id="advanced" class="tab-content">
                    <h3>🚀 Advanced Header with SEO</h3>
                    <p>Production-ready header with modern best practices:</p>
                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">📋 Copy</button>
                        <pre><code><span class="tag">&lt;!DOCTYPE html&gt;</span>
<span class="tag">&lt;html</span> <span class="keyword">&lt;?php</span> <span class="function">language_attributes</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="tag">&lt;head&gt;</span>
    <span class="tag">&lt;meta</span> charset=<span class="string">"&lt;?php bloginfo('charset'); ?&gt;"</span><span class="tag">&gt;</span>
    <span class="tag">&lt;meta</span> name=<span class="string">"viewport"</span> content=<span class="string">"width=device-width, initial-scale=1"</span><span class="tag">&gt;</span>
    <span class="tag">&lt;link</span> rel=<span class="string">"profile"</span> href=<span class="string">"https://gmpg.org/xfn/11"</span><span class="tag">&gt;</span>
    
    <span class="comment">&lt;!-- Preconnect for performance --&gt;</span>
    <span class="tag">&lt;link</span> rel=<span class="string">"preconnect"</span> href=<span class="string">"https://fonts.googleapis.com"</span><span class="tag">&gt;</span>
    
    <span class="keyword">&lt;?php</span> <span class="function">wp_head</span>(); <span class="keyword">?&gt;</span>
<span class="tag">&lt;/head&gt;</span>

<span class="tag">&lt;body</span> <span class="keyword">&lt;?php</span> <span class="function">body_class</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="keyword">&lt;?php</span> <span class="function">wp_body_open</span>(); <span class="keyword">?&gt;</span>

<span class="tag">&lt;a</span> class=<span class="string">"skip-link"</span> href=<span class="string">"#content"</span><span class="tag">&gt;</span>Skip to content<span class="tag">&lt;/a&gt;</span>

<span class="tag">&lt;header</span> id=<span class="string">"masthead"</span> class=<span class="string">"site-header"</span><span class="tag">&gt;</span>
    <span class="comment">&lt;!-- Your header content --&gt;</span>
<span class="tag">&lt;/header&gt;</span></code></pre>
                    </div>
                </div>

                <div id="hooks" class="tab-content">
                    <h3>🔌 Essential WordPress Hooks</h3>
                    <p>Critical functions that make WordPress work:</p>
                    
                    <div class="success-box">
                        <strong>wp_head() - The Most Important Hook!</strong>
                        <p>This function is REQUIRED in every header.php. It allows WordPress and plugins to inject styles, scripts, meta tags, and more into the &lt;head&gt; section.</p>
                    </div>

                    <div class="code-block">
                        <button class="copy-btn" onclick="copyCode(this)">📋 Copy</button>
                        <pre><code><span class="comment">// What wp_head() does behind the scenes:</span>
<span class="keyword">&lt;?php</span> <span class="function">wp_head</span>(); <span class="keyword">?&gt;</span>

<span class="comment">// This hook allows plugins to add:</span>
<span class="comment">// - Stylesheets</span>
<span class="comment">// - JavaScript files</span>
<span class="comment">// - Meta tags (SEO, social media)</span>
<span class="comment">// - Analytics tracking codes</span>
<span class="comment">// - Custom fonts</span>
<span class="comment">// - And much more!</span></code></pre>
                    </div>

                    <div class="info-box">
                        <strong>wp_body_open() - Modern WordPress Hook</strong>
                        <p>Added in WordPress 5.2, this hook lets plugins inject code right after the opening &lt;body&gt; tag (useful for tracking pixels, accessibility tools, etc.)</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Code Breakdown Section -->
    <section id="code-breakdown">
        <div class="container">
            <div class="section-header">
                <h2>🔍 Code Breakdown</h2>
                <p>Understanding every line of header.php</p>
            </div>

            <div class="card">
                <h3>📚 Line-by-Line Explanation</h3>
                
                <div class="grid">
                    <div class="grid-item">
                        <h4><code>language_attributes()</code></h4>
                        <p>Outputs the language and text direction attributes for the &lt;html&gt; tag. Example: <code>lang="en-US" dir="ltr"</code></p>
                    </div>

                    <div class="grid-item">
                        <h4><code>bloginfo('charset')</code></h4>
                        <p>Displays the character encoding (usually UTF-8). Critical for displaying international characters correctly.</p>
                    </div>

                    <div class="grid-item">
                        <h4><code>wp_head()</code></h4>
                        <p>🔥 REQUIRED! Fires the wp_head action hook. Plugins and WordPress core use this to add styles, scripts, and meta tags.</p>
                    </div>

                    <div class="grid-item">
                        <h4><code>body_class()</code></h4>
                        <p>Adds contextual CSS classes to the &lt;body&gt; tag (page type, logged-in status, etc.). Super useful for styling!</p>
                    </div>

                    <div class="grid-item">
                        <h4><code>wp_body_open()</code></h4>
                        <p>Fires right after &lt;body&gt; opens. Plugins use this for tracking codes, skip links, and more.</p>
                    </div>

                    <div class="grid-item">
                        <h4><code>home_url('/')</code></h4>
                        <p>Returns your site's home URL. Always use this instead of hardcoding URLs!</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Common Mistakes Section -->
    <section id="common-mistakes">
        <div class="container">
            <div class="section-header">
                <h2>⚠️ Common Mistakes</h2>
                <p>Avoid these header.php pitfalls!</p>
            </div>

            <div class="card">
                <div class="warning-box">
                    <h3>❌ Mistake #1: Forgetting wp_head()</h3>
                    <p><strong>The Problem:</strong> Without <code>wp_head()</code>, plugins can't add their styles/scripts, WordPress admin bar won't work, and SEO plugins will fail.</p>
                    <div class="code-block">
                        <pre><code><span class="comment">// WRONG - Missing wp_head()</span>
<span class="tag">&lt;head&gt;</span>
    <span class="tag">&lt;meta</span> charset=<span class="string">"UTF-8"</span><span class="tag">&gt;</span>
    <span class="tag">&lt;title&gt;</span>My Site<span class="tag">&lt;/title&gt;</span>
<span class="tag">&lt;/head&gt;</span>

<span class="comment">// CORRECT - Always include wp_head()</span>
<span class="tag">&lt;head&gt;</span>
    <span class="tag">&lt;meta</span> charset=<span class="string">"&lt;?php bloginfo('charset'); ?&gt;"</span><span class="tag">&gt;</span>
    <span class="keyword">&lt;?php</span> <span class="function">wp_head</span>(); <span class="keyword">?&gt;</span>
<span class="tag">&lt;/head&gt;</span></code></pre>
                    </div>
                </div>

                <div class="warning-box">
                    <h3>❌ Mistake #2: Hardcoding URLs</h3>
                    <p><strong>The Problem:</strong> If your site URL changes, hardcoded links will break!</p>
                    <div class="code-block">
                        <pre><code><span class="comment">// WRONG - Hardcoded URL</span>
<span class="tag">&lt;a</span> href=<span class="string">"https://mysite.com"</span><span class="tag">&gt;</span>Home<span class="tag">&lt;/a&gt;</span>

<span class="comment">// CORRECT - Use WordPress functions</span>
<span class="tag">&lt;a</span> href=<span class="string">"&lt;?php echo esc_url(home_url('/')); ?&gt;"</span><span class="tag">&gt;</span>Home<span class="tag">&lt;/a&gt;</span></code></pre>
                    </div>
                </div>

                <div class="warning-box">
                    <h3>❌ Mistake #3: Missing body_class()</h3>
                    <p><strong>The Problem:</strong> You lose valuable contextual CSS classes that help with styling different page types.</p>
                    <div class="code-block">
                        <pre><code><span class="comment">// WRONG - No body_class()</span>
<span class="tag">&lt;body&gt;</span>

<span class="comment">// CORRECT - Always use body_class()</span>
<span class="tag">&lt;body</span> <span class="keyword">&lt;?php</span> <span class="function">body_class</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="comment">&lt;!-- Outputs: &lt;body class="home page-id-2 logged-in"&gt; --&gt;</span></code></pre>
                    </div>
                </div>

                <div class="warning-box">
                    <h3>❌ Mistake #4: Not Escaping Output</h3>
                    <p><strong>The Problem:</strong> Security vulnerability! Always escape data before outputting.</p>
                    <div class="code-block">
                        <pre><code><span class="comment">// WRONG - Not escaped</span>
<span class="tag">&lt;a</span> href=<span class="string">"&lt;?php echo home_url('/'); ?&gt;"</span><span class="tag">&gt;</span>

<span class="comment">// CORRECT - Use esc_url()</span>
<span class="tag">&lt;a</span> href=<span class="string">"&lt;?php echo esc_url(home_url('/')); ?&gt;"</span><span class="tag">&gt;</span></code></pre>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Pro Tips Section -->
    <section id="pro-tips">
        <div class="container">
            <div class="section-header">
                <h2>🌟 Pro Tips</h2>
                <p>Level up your header.php game!</p>
            </div>

            <div class="grid">
                <div class="card">
                    <h3>💡 Tip #1: Custom Headers</h3>
                    <p>Create multiple header variations using <code>get_header('name')</code></p>
                    <div class="code-block">
                        <pre><code><span class="comment">// In your template file:</span>
<span class="keyword">&lt;?php</span> <span class="function">get_header</span>(<span class="string">'home'</span>); <span class="keyword">?&gt;</span>
<span class="comment">// Loads: header-home.php</span>

<span class="keyword">&lt;?php</span> <span class="function">get_header</span>(<span class="string">'shop'</span>); <span class="keyword">?&gt;</span>
<span class="comment">// Loads: header-shop.php</span></code></pre>
                    </div>
                </div>

                <div class="card">
                    <h3>🚀 Tip #2: Conditional Headers</h3>
                    <p>Show different headers based on page type:</p>
                    <div class="code-block">
                        <pre><code><span class="keyword">&lt;?php</span> <span class="keyword">if</span> (<span class="function">is_front_page</span>()) : <span class="keyword">?&gt;</span>
    <span class="tag">&lt;header</span> class=<span class="string">"hero-header"</span><span class="tag">&gt;</span>
        <span class="comment">&lt;!-- Large hero header --&gt;</span>
    <span class="tag">&lt;/header&gt;</span>
<span class="keyword">&lt;?php</span> <span class="keyword">else</span> : <span class="keyword">?&gt;</span>
    <span class="tag">&lt;header</span> class=<span class="string">"simple-header"</span><span class="tag">&gt;</span>
        <span class="comment">&lt;!-- Compact header --&gt;</span>
    <span class="tag">&lt;/header&gt;</span>
<span class="keyword">&lt;?php</span> <span class="keyword">endif</span>; <span class="keyword">?&gt;</span></code></pre>
                    </div>
                </div>

                <div class="card">
                    <h3>🎨 Tip #3: Add Custom Classes</h3>
                    <p>Extend body_class() with your own classes:</p>
                    <div class="code-block">
                        <pre><code><span class="comment">// In functions.php:</span>
<span class="function">add_filter</span>(<span class="string">'body_class'</span>, <span class="keyword">function</span>(<span class="keyword">$classes</span>) {
    <span class="keyword">if</span> (<span class="function">is_page_template</span>(<span class="string">'page-custom.php'</span>)) {
        <span class="keyword">$classes</span>[] = <span class="string">'custom-template'</span>;
    }
    <span class="keyword">return</span> <span class="keyword">$classes</span>;
});</code></pre>
                    </div>
                </div>

                <div class="card">
                    <h3>⚡ Tip #4: Performance Optimization</h3>
                    <p>Add resource hints for faster loading:</p>
                    <div class="code-block">
                        <pre><code><span class="tag">&lt;head&gt;</span>
    <span class="comment">&lt;!-- Preconnect to external resources --&gt;</span>
    <span class="tag">&lt;link</span> rel=<span class="string">"preconnect"</span> href=<span class="string">"https://fonts.googleapis.com"</span><span class="tag">&gt;</span>
    <span class="tag">&lt;link</span> rel=<span class="string">"dns-prefetch"</span> href=<span class="string">"//cdn.example.com"</span><span class="tag">&gt;</span>
    <span class="keyword">&lt;?php</span> <span class="function">wp_head</span>(); <span class="keyword">?&gt;</span>
<span class="tag">&lt;/head&gt;</span></code></pre>
                    </div>
                </div>

                <div class="card">
                    <h3>♿ Tip #5: Accessibility</h3>
                    <p>Always include skip links for keyboard users:</p>
                    <div class="code-block">
                        <pre><code><span class="tag">&lt;body</span> <span class="keyword">&lt;?php</span> <span class="function">body_class</span>(); <span class="keyword">?&gt;</span><span class="tag">&gt;</span>
<span class="keyword">&lt;?php</span> <span class="function">wp_body_open</span>(); <span class="keyword">?&gt;</span>

<span class="tag">&lt;a</span> class=<span class="string">"skip-link screen-reader-text"</span> 
   href=<span class="string">"#primary"</span><span class="tag">&gt;</span>
    Skip to content
<span class="tag">&lt;/a&gt;</span></code></pre>
                    </div>
                </div>

                <div class="card">
                    <h3>🔒 Tip #6: Security Best Practices</h3>
                    <p>Always escape and validate output:</p>
                    <div class="code-block">
                        <pre><code><span class="comment">// Escape URLs</span>
<span class="function">esc_url</span>(<span class="function">home_url</span>(<span class="string">'/'</span>));

<span class="comment">// Escape HTML</span>
<span class="function">esc_html</span>(<span class="function">get_bloginfo</span>(<span class="string">'name'</span>));

<span class="comment">// Escape attributes</span>
<span class="function">esc_attr</span>(<span class="keyword">$custom_class</span>);</code></pre>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Quiz Section -->
    <section id="quiz">
        <div class="container">
            <div class="section-header">
                <h2>🎯 Test Your Knowledge!</h2>
                <p>Let's see what you've learned about header.php</p>
            </div>

            <div class="quiz-question">
                <h3>Question 1: What is the most critical function that MUST be included in header.php?</h3>
                <div class="quiz-options">
                    <div class="quiz-option" onclick="checkAnswer(this, false, 1)">
                        A) get_header()
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, true, 1)">
                        B) wp_head()
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, false, 1)">
                        C) the_header()
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, false, 1)">
                        D) bloginfo('header')
                    </div>
                </div>
                <div class="quiz-feedback" id="feedback1"></div>
            </div>

            <div class="quiz-question">
                <h3>Question 2: Where should header.php be located in a WordPress theme?</h3>
                <div class="quiz-options">
                    <div class="quiz-option" onclick="checkAnswer(this, false, 2)">
                        A) /wp-content/plugins/
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, true, 2)">
                        B) /wp-content/themes/your-theme/
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, false, 2)">
                        C) /wp-includes/
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, false, 2)">
                        D) /wp-admin/
                    </div>
                </div>
                <div class="quiz-feedback" id="feedback2"></div>
            </div>

            <div class="quiz-question">
                <h3>Question 3: What does body_class() do?</h3>
                <div class="quiz-options">
                    <div class="quiz-option" onclick="checkAnswer(this, false, 3)">
                        A) Creates a new body element
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, true, 3)">
                        B) Adds contextual CSS classes to the body tag
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, false, 3)">
                        C) Styles the body element
                    </div>
                    <div class="quiz-option" onclick="checkAnswer(this, false, 3)">
                        D) Closes the body tag
                    </div>
                </div>
                <div class="quiz-feedback" id="feedback3"></div>
            </div>

            <div id="quiz-complete" style="display: none; text-align: center; margin-top: 40px;">
                <h2 style="font-size: 3rem;">🎉 Congratulations!</h2>
                <p style="font-size: 1.5rem; margin-top: 20px;">You've mastered header.php basics!</p>
                <div class="badge">WordPress Header Expert</div>
                <div class="badge">Theme Developer</div>
                <div class="badge">PHP Ninja</div>
            </div>
        </div>
    </section>

    <!-- Summary Section -->
    <section id="summary">
        <div class="container">
            <div class="section-header">
                <h2>📚 Quick Reference</h2>
                <p>Your header.php cheat sheet</p>
            </div>

            <div class="summary-card">
                <h3>🎯 Essential header.php Checklist</h3>
                
                <div class="summary-grid">
                    <div class="summary-item">
                        <strong>✅ DOCTYPE Declaration</strong>
                        <p>&lt;!DOCTYPE html&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ Language Attributes</strong>
                        <p>&lt;html &lt;?php language_attributes(); ?&gt;&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ Character Encoding</strong>
                        <p>&lt;meta charset="&lt;?php bloginfo('charset'); ?&gt;"&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ Viewport Meta</strong>
                        <p>&lt;meta name="viewport" content="width=device-width"&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ wp_head() Hook</strong>
                        <p>&lt;?php wp_head(); ?&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ Body Classes</strong>
                        <p>&lt;body &lt;?php body_class(); ?&gt;&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ wp_body_open()</strong>
                        <p>&lt;?php wp_body_open(); ?&gt;</p>
                    </div>

                    <div class="summary-item">
                        <strong>✅ Skip Link</strong>
                        <p>&lt;a class="skip-link" href="#content"&gt;</p>
                    </div>
                </div>

                <div class="success-box" style="margin-top: 30px;">
                    <h4>🔑 Key Takeaways:</h4>
                    <ul style="margin-left: 20px; margin-top: 10px;">
                        <li>header.php controls the top section of all pages</li>
                        <li>wp_head() is REQUIRED - never forget it!</li>
                        <li>Always use WordPress functions instead of hardcoding</li>
                        <li>Escape all output for security</li>
                        <li>Use body_class() for flexible styling</li>
                        <li>Create custom headers with get_header('name')</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer>
        <div class="container">
            <h3 style="margin-bottom: 20px;">🎓 You've Completed the Tutorial!</h3>
            <p>Now you're ready to create amazing WordPress theme headers!</p>
            <p style="margin-top: 20px; color: var(--text-muted); font-size: 0.9rem;">
                Generated by <strong>AI Prompt Dictionary</strong> 🤖<br>
                Making learning interactive and fun, one tutorial at a time!
            </p>
            <div style="margin-top: 30px;">
                <span class="badge">Interactive Learning</span>
                <span class="badge">WordPress Expert</span>
                <span class="badge">Theme Development</span>
            </div>
        </div>
    </footer>

    <script>
        // Progress Bar
        window.addEventListener('scroll', () => {
            const windowHeight = window.innerHeight;
            const documentHeight = document.documentElement.scrollHeight - windowHeight;
            const scrolled = window.scrollY;
            const progress = (scrolled / documentHeight) * 100;
            document.getElementById('progressBar').style.width = progress + '%';
        });

        // Intersection Observer for sections
        const sections = document.querySelectorAll('section');
        const observerOptions = {
            threshold: 0.1,
            rootMargin: '0px 0px -100px 0px'
        };

        const observer = new IntersectionObserver((entries) => {
            entries.forEach(entry => {
                if (entry.isIntersecting) {
                    entry.target.classList.add('visible');
                }
            });
        }, observerOptions);

        sections.forEach(section => {
            observer.observe(section);
        });

        // Tab Switching
        function switchTab(event, tabName) {
            const tabContents = document.querySelectorAll('.tab-content');
            const tabBtns = document.querySelectorAll('.tab-btn');
            
            tabContents.forEach(content => content.classList.remove('active'));
            tabBtns.forEach(btn => btn.classList.remove('active'));
            
            document.getElementById(tabName).classList.add('active');
            event.target.classList.add('active');
        }

        // Copy Code Function
        function copyCode(button) {
            const codeBlock = button.nextElementSibling;
            const code = codeBlock.textContent;
            
            navigator.clipboard.writeText(code).then(() => {
                button.textContent = '✓ Copied!';
                button.style.background = 'var(--accent-green)';
                
                setTimeout(() => {
                    button.textContent = '📋 Copy';
                    button.style.background = 'var(--accent-purple)';
                }, 2000);
            });
        }

        // Quiz Logic
        let correctAnswers = 0;
        let answeredQuestions = new Set();

        function checkAnswer(element, isCorrect, questionNum) {
            // Prevent multiple answers
            if (answeredQuestions.has(questionNum)) return;
            
            answeredQuestions.add(questionNum);
            const feedback = document.getElementById('feedback' + questionNum);
            const options = element.parentElement.querySelectorAll('.quiz-option');
            
            // Disable all options
            options.forEach(opt => opt.style.pointerEvents = 'none');
            
            if (isCorrect) {
                element.classList.add('correct');
                feedback.className = 'quiz-feedback correct show';
                feedback.innerHTML = '🎉 Correct! Excellent work!';
                correctAnswers++;
                createConfetti();
            } else {
                element.classList.add('incorrect');
                feedback.className = 'quiz-feedback incorrect show';
                feedback.innerHTML = '❌ Not quite. Review the tutorial and try again!';
            }

            // Check if all questions answered
            if (answeredQuestions.size === 3 && correctAnswers === 3) {
                setTimeout(() => {
                    document.getElementById('quiz-complete').style.display = 'block';
                    createMegaConfetti();
                }, 1000);
            }
        }

        // Confetti Effect
        function createConfetti() {
            const colors = ['#a855f7', '#3b82f6', '#10b981', '#ec4899'];
            for (let i = 0; i < 30; i++) {
                const confetti = document.createElement('div');
                confetti.className = 'confetti';
                confetti.style.left = Math.random() * 100 + '%';
                confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
                confetti.style.animationDelay = Math.random() * 0.5 + 's';
                document.body.appendChild(confetti);
                
                setTimeout(() => confetti.remove(), 3000);
            }
        }

        function createMegaConfetti() {
            const colors = ['#a855f7', '#3b82f6', '#10b981', '#ec4899', '#f59e0b'];
            for (let i = 0; i < 100; i++) {
                const confetti = document.createElement('div');
                confetti.className = 'confetti';
                confetti.style.left = Math.random() * 100 + '%';
                confetti.style.background = colors[Math.floor(Math.random() * colors.length)];
                confetti.style.animationDelay = (Math.random() * 2) + 's';
                confetti.style.width = (Math.random() * 10 + 5) + 'px';
                confetti.style.height = confetti.style.width;
                document.body.appendChild(confetti);
                
                setTimeout(() => confetti.remove(), 5000);
            }
        }

        // Smooth scroll for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                const target = document.querySelector(this.getAttribute('href'));
                if (target) {
                    target.scrollIntoView({ behavior: 'smooth', block: 'start' });
                }
            });
        });
    </script>
</body>
</html>
Live Preview