Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro-preview-03-25· GoogleHugging Face LMArena Human Preference 140K

write the html/css, javascript all in a single file for a website that looks like…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-5-sonnet-20241022’s answer.
  1. User

    write the html/css, javascript all in a single file for a website that looks like YouTube. make the website close to the target, remember its core components.

  2. Gemini Assistant

    Okay, here is a single HTML file containing HTML, CSS, and JavaScript to create a basic visual resemblance of the YouTube desktop layout.

    Key Components Included:

    1. Header: Logo, Search Bar, User Icons (static).
    2. Sidebar: Collapsible navigation menu (Home, Shorts, Subscriptions, etc.).
    3. Main Content Area: A grid of video placeholders (Thumbnail, Title, Channel, Views/Time).
    4. Basic Interactivity: Sidebar toggle functionality.

    Limitations:

    • This is purely visual. No actual video playback, search, login, or data loading.
    • Uses placeholder images and text.
    • Icons are from Font Awesome (requires internet connection for icons to load).
    • Responsiveness is basic (video grid adjusts, sidebar collapses). A real site needs much more complex media queries.
    • Styling is approximate, not pixel-perfect.
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>MyTube - YouTube Clone</title>
        <!-- Google Fonts (Roboto) -->
        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
        <!-- Font Awesome Icons -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    
        <style>
            /* --- Global Resets & Base Styles --- */
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
    
            body {
                font-family: 'Roboto', sans-serif;
                background-color: #f9f9f9;
                display: flex;
                flex-direction: column;
                height: 100vh; /* Ensure body takes full viewport height */
                overflow: hidden; /* Prevent body scroll when main content scrolls */
            }
    
            a {
                text-decoration: none;
                color: inherit;
            }
    
            button {
                background: none;
                border: none;
                cursor: pointer;
                padding: 0;
            }
    
            /* --- Header --- */
            .header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 10px 20px;
                background-color: #ffffff;
                border-bottom: 1px solid #ddd;
                height: 56px; /* Standard YouTube header height */
                position: sticky; /* Keep header fixed */
                top: 0;
                z-index: 1000;
            }
    
            .header-left, .header-center, .header-right {
                display: flex;
                align-items: center;
            }
    
            .header-left .menu-icon {
                font-size: 20px;
                margin-right: 20px;
                cursor: pointer;
                color: #606060;
            }
    
            .header-left .logo img {
                height: 20px; /* Approximate YouTube logo height */
                vertical-align: middle; /* Align image nicely */
            }
             /* Simple Text Logo fallback */
            .header-left .logo span {
                font-size: 22px;
                font-weight: bold;
                color: #ff0000; /* YouTube Red */
                margin-left: 5px;
            }
    
    
            .header-center {
                flex: 1; /* Takes up available space */
                max-width: 650px; /* Limit search bar width */
                margin: 0 40px; /* Spacing around search */
                display: flex;
            }
    
            .header-center .search-bar {
                display: flex;
                width: 100%;
                border: 1px solid #ccc;
                border-radius: 40px; /* Pill shape */
                overflow: hidden; /* Keep button inside */
            }
    
            .header-center .search-bar input {
                flex: 1;
                padding: 8px 15px;
                border: none;
                font-size: 16px;
                outline: none;
                border-radius: 40px 0 0 40px; /* Match container */
            }
    
            .header-center .search-bar button {
                padding: 0 20px;
                border-left: 1px solid #ccc;
                background-color: #f8f8f8;
                cursor: pointer;
                display: flex;
                align-items: center;
                justify-content: center;
                border-radius: 0 40px 40px 0; /* Match container */
                transition: background-color 0.2s ease;
            }
             .header-center .search-bar button:hover {
                background-color: #f0f0f0;
             }
    
            .header-center .search-bar button i {
                font-size: 18px;
                color: #606060;
            }
    
            .header-right i {
                font-size: 20px;
                margin-left: 25px;
                color: #606060;
                cursor: pointer;
            }
    
            .header-right .profile-icon img {
                height: 32px;
                width: 32px;
                border-radius: 50%;
                margin-left: 25px;
                cursor: pointer;
            }
    
            /* --- Main Container (Sidebar + Content) --- */
            .main-container {
                display: flex;
                flex: 1; /* Takes remaining vertical space */
                overflow: hidden; /* Prevent container itself from scrolling */
                background-color: #f9f9f9;
            }
    
            /* --- Sidebar --- */
            .sidebar {
                width: 240px;
                background-color: #ffffff;
                padding-top: 10px;
                height: calc(100vh - 56px); /* Full height minus header */
                overflow-y: auto; /* Scrollable if content exceeds height */
                transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
                border-right: 1px solid #ddd;
            }
    
            .sidebar.collapsed {
                width: 72px; /* Width when collapsed */
                overflow: hidden; /* Hide text when collapsed */
            }
    
            .sidebar.collapsed .sidebar-link span {
                display: none; /* Hide text */
            }
             .sidebar.collapsed .sidebar-link {
                justify-content: center;
                padding: 15px 0;
             }
            .sidebar.collapsed .sidebar-link i {
                margin-right: 0;
                font-size: 20px; /* Slightly larger icons */
            }
    
            .sidebar-link {
                display: flex;
                align-items: center;
                padding: 10px 20px;
                cursor: pointer;
                transition: background-color 0.2s ease;
                font-size: 14px;
                color: #030303;
            }
    
            .sidebar-link:hover, .sidebar-link.active {
                background-color: #eeeeee;
            }
    
            .sidebar-link i {
                font-size: 18px;
                margin-right: 24px; /* Space between icon and text */
                width: 24px; /* Fixed width for alignment */
                text-align: center;
                color: #606060;
            }
    
            .sidebar hr {
                border: 0;
                border-top: 1px solid #e5e5e5;
                margin: 10px 0;
            }
    
             .sidebar h3 {
                font-size: 14px;
                color: #606060;
                padding: 10px 20px;
                text-transform: uppercase;
             }
             .sidebar.collapsed h3 {
                display: none;
             }
    
            /* --- Main Content Area --- */
            .main-content {
                flex: 1; /* Takes remaining horizontal space */
                padding: 20px;
                overflow-y: auto; /* Allows scrolling of video grid */
                height: calc(100vh - 56px); /* Full height minus header */
            }
    
            /* --- Video Grid --- */
            .video-grid {
                display: grid;
                /* Responsive grid: Auto-fill columns, min width 250px, max 1fr */
                grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
                gap: 20px 15px; /* Row gap, Column gap */
            }
    
            .video-card {
                background-color: transparent; /* Inherit from main */
                cursor: pointer;
            }
    
            .video-card .thumbnail img {
                width: 100%;
                aspect-ratio: 16 / 9; /* Maintain video aspect ratio */
                object-fit: cover; /* Cover the area without distortion */
                border-radius: 8px; /* Slightly rounded corners */
                background-color: #e0e0e0; /* Placeholder background */
                display: block; /* Remove extra space below img */
            }
    
            .video-details {
                display: flex;
                margin-top: 10px;
            }
    
            .video-details .channel-avatar img {
                width: 36px;
                height: 36px;
                border-radius: 50%;
                margin-right: 12px;
                background-color: #cccccc; /* Placeholder */
            }
    
            .video-info h4 {
                font-size: 14px;
                font-weight: 500;
                color: #0f0f0f;
                margin-bottom: 4px;
                /* Clamp title to 2 lines */
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                overflow: hidden;
                text-overflow: ellipsis;
            }
    
            .video-info p {
                font-size: 12px;
                color: #606060;
                line-height: 1.4;
            }
        </style>
    </head>
    <body>
    
        <!-- Header Section -->
        <header class="header">
            <div class="header-left">
                <i class="fas fa-bars menu-icon" id="menu-toggle"></i>
                <a href="#" class="logo">
                    <!-- You can replace this with an actual SVG or image logo -->
                    <img src="https://upload.wikimedia.org/wikipedia/commons/b/b8/YouTube_Logo_2017.svg" alt="YouTube Logo">
                    <!-- Fallback Text Logo -->
                    <!-- <span>MyTube</span> -->
                </a>
            </div>
            <div class="header-center">
                <div class="search-bar">
                    <input type="text" placeholder="Search">
                    <button type="submit">
                        <i class="fas fa-search"></i>
                    </button>
                </div>
                 <!-- Microphone Icon (optional) -->
                 <!-- <button class="mic-icon"><i class="fas fa-microphone"></i></button> -->
            </div>
            <div class="header-right">
                <i class="fas fa-video"></i> <!-- Create -->
                <i class="fas fa-bell"></i> <!-- Notifications -->
                 <!-- User Profile Picture -->
                <div class="profile-icon">
                     <img src="https://placehold.co/32x32/cccccc/808080?text=U" alt="User Profile">
                </div>
            </div>
        </header>
    
        <!-- Main Container (Sidebar + Content) -->
        <div class="main-container">
    
            <!-- Sidebar Section -->
            <aside class="sidebar" id="sidebar">
                <a href="#" class="sidebar-link active">
                    <i class="fas fa-home"></i>
                    <span>Home</span>
                </a>
                <a href="#" class="sidebar-link">
                    <i class="fas fa-bolt"></i>
                    <span>Shorts</span>
                </a>
                <a href="#" class="sidebar-link">
                    <i class="fas fa-photo-video"></i>
                    <span>Subscriptions</span>
                </a>
                <hr>
                <a href="#" class="sidebar-link">
                    <i class="fas fa-play-circle"></i>
                    <span>Library</span>
                </a>
                <a href="#" class="sidebar-link">
                    <i class="fas fa-history"></i>
                    <span>History</span>
                </a>
                 <a href="#" class="sidebar-link">
                    <i class="fas fa-caret-square-right"></i> <!-- Using this as placeholder -->
                    <span>Your Videos</span>
                </a>
                 <a href="#" class="sidebar-link">
                    <i class="fas fa-clock"></i>
                    <span>Watch Later</span>
                </a>
                 <a href="#" class="sidebar-link">
                    <i class="fas fa-thumbs-up"></i>
                    <span>Liked Videos</span>
                </a>
                <hr>
                 <h3>Subscriptions</h3>
                 <!-- Add subscription links here if needed -->
                 <a href="#" class="sidebar-link">
                    <i class="fas fa-user-circle"></i> <!-- Placeholder Icon -->
                    <span>Cool Channel</span>
                 </a>
                 <a href="#" class="sidebar-link">
                     <i class="fas fa-user-circle"></i>
                     <span>Another Channel</span>
                 </a>
                 <!-- Add more links as needed -->
            </aside>
    
            <!-- Main Content Section -->
            <main class="main-content" id="main-content">
                <div class="video-grid">
                    <!-- Repeat this video card structure for more videos -->
                    <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/E8A87C/474747?text=Video+Thumbnail+1" alt="Video Thumbnail 1">
                            </div>
                            <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/7FDBFF/333333?text=C1" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Amazing Nature Documentary - Must Watch Today</h4>
                                    <p>Nature Explorers</p>
                                    <p>1.2M views • 3 weeks ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                    <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/C38D9E/474747?text=Video+Thumbnail+2" alt="Video Thumbnail 2">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/FFDC00/333333?text=T2" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Tech Review: The Latest Gadget You Need</h4>
                                    <p>Tech Guru</p>
                                    <p>500K views • 1 day ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                     <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/41B3A3/474747?text=Video+Thumbnail+3" alt="Video Thumbnail 3">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/2ECC40/333333?text=G3" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Ultimate Gaming Montage Compilation 2023</h4>
                                    <p>GamerPro</p>
                                    <p>8M views • 5 months ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                     <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/FF851B/474747?text=Video+Thumbnail+4" alt="Video Thumbnail 4">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/FF4136/333333?text=M4" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Easy 10 Minute Makeup Tutorial for Beginners</h4>
                                    <p>Makeup Maven</p>
                                    <p>95K views • 2 days ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                     <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/A1D6E2/474747?text=Video+Thumbnail+5" alt="Video Thumbnail 5">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/B10DC9/333333?text=F5" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Funny Cat Videos That Will Make You Laugh</h4>
                                    <p>Cute Pets TV</p>
                                    <p>10M views • 1 year ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                     <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/F0E68C/474747?text=Video+Thumbnail+6" alt="Video Thumbnail 6">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/0074D9/333333?text=S6" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Learn JavaScript in 1 Hour - Crash Course</h4>
                                    <p>Code Masters</p>
                                    <p>2.5M views • 6 months ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                     <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/98FB98/474747?text=Video+Thumbnail+7" alt="Video Thumbnail 7">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/AAAAAA/333333?text=T7" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Travel Vlog: Exploring the Mountains of Peru</h4>
                                    <p>Wanderlust Adventures</p>
                                    <p>300K views • 4 weeks ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
    
                     <article class="video-card">
                        <a href="#">
                            <div class="thumbnail">
                                <img src="https://placehold.co/400x225/ADD8E6/474747?text=Video+Thumbnail+8" alt="Video Thumbnail 8">
                            </div>
                             <div class="video-details">
                                <div class="channel-avatar">
                                    <img src="https://placehold.co/36x36/F012BE/333333?text=C8" alt="Channel Avatar">
                                </div>
                                <div class="video-info">
                                    <h4>Delicious Chocolate Cake Recipe - Easy Baking</h4>
                                    <p>Chef's Kitchen</p>
                                    <p>750K views • 2 months ago</p>
                                </div>
                            </div>
                        </a>
                    </article>
                     <!-- Add more video cards here -->
    
                </div> <!-- End Video Grid -->
            </main>
    
        </div> <!-- End Main Container -->
    
        <script>
            // --- JavaScript for Sidebar Toggle ---
            const menuToggle = document.getElementById('menu-toggle');
            const sidebar = document.getElementById('sidebar');
            const mainContent = document.getElementById('main-content'); // Optional: to adjust padding/margin
    
            menuToggle.addEventListener('click', () => {
                sidebar.classList.toggle('collapsed');
    
                // Optional: Adjust main content margin if needed when sidebar collapses/expands
                // if (sidebar.classList.contains('collapsed')) {
                //     mainContent.style.marginLeft = '72px'; // Width of collapsed sidebar
                // } else {
                //     mainContent.style.marginLeft = '240px'; // Width of expanded sidebar
                // }
                // Note: Adjusting margin might cause layout shifts.
                // Alternatively, rely on the flex layout automatically adjusting.
            });
    
            // --- Placeholder for Video Clicks ---
            const videoCards = document.querySelectorAll('.video-card a');
    
            videoCards.forEach(card => {
                card.addEventListener('click', (event) => {
                    event.preventDefault(); // Prevent default link behavior
                    const title = card.querySelector('.video-info h4').textContent;
                    alert(`Clicked on video: "${title}" \n(Functionality not implemented)`);
                });
            });
    
             // --- Placeholder for other icon clicks ---
             const headerIcons = document.querySelectorAll('.header-right i, .header-right .profile-icon');
             headerIcons.forEach(icon => {
                icon.addEventListener('click', () => {
                    const iconClass = icon.classList.length > 0 ? icon.classList[1] : 'profile'; // Get a representative class
                    alert(`Clicked on header icon: ${iconClass} (Functionality not implemented)`);
                })
             })
    
             const searchButton = document.querySelector('.search-bar button');
             searchButton.addEventListener('click', (e) => {
                e.preventDefault();
                const searchTerm = document.querySelector('.search-bar input').value;
                if(searchTerm.trim()) {
                    alert(`Searching for: "${searchTerm}" (Functionality not implemented)`);
                } else {
                     alert(`Please enter a search term.`);
                }
             })
    
        </script>
    
    </body>
    </html>
    

    How to Use:

    1. Save the entire code block above as an HTML file (e.g., mytube.html).
    2. Open the file in your web browser.

    You should see a static page that mimics the basic layout of YouTube, with a functioning sidebar toggle. Remember that internet access is needed for the Font Awesome icons and the Google Font to load correctly.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.