Create a simple Wikipedia clone with HTML & CSS.
- User
Create a simple Wikipedia clone with HTML & CSS.
Assistant
Okay, let's create a simple Wikipedia clone using just HTML and CSS. We'll focus on the basic layout: a header, a left sidebar for navigation, the main content area, and a footer.
For content, we'll create a mock article about "HTML".
1.
index.html(The HTML Structure)<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML - WikiClone</title> <link rel="stylesheet" href="style.css"> <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📚</text></svg>"> </head> <body> <header class="main-header"> <div class="logo"> <a href="#">WikiClone</a> </div> <form class="search-box"> <input type="search" placeholder="Search WikiClone"> <button type="submit">Search</button> </form> </header> <div class="container"> <nav class="sidebar"> <div class="sidebar-section"> <h3>Navigation</h3> <ul> <li><a href="#">Main page</a></li> <li><a href="#">Contents</a></li> <li><a href="#">Featured content</a></li> <li><a href="#">Current events</a></li> <li><a href="#">Random article</a></li> </ul> </div> <div class="sidebar-section"> <h3>Interaction</h3> <ul> <li><a href="#">Help</a></li> <li><a href="#">About WikiClone</a></li> <li><a href="#">Community portal</a></li> <li><a href="#">Recent changes</a></li> </ul> </div> <div class="sidebar-section"> <h3>Tools</h3> <ul> <li><a href="#">What links here</a></li> <li><a href="#">Related changes</a></li> <li><a href="#">Upload file</a></li> <li><a href="#">Special pages</a></li> </ul> </div> </nav> <main class="main-content"> <div class="article-header"> <h1>HTML</h1> <ul class="tabs"> <li class="active"><a href="#">Read</a></li> <li><a href="#">Edit</a></li> <li><a href="#">View history</a></li> </ul> </div> <div class="article-body"> <div class="toc"> <h2>Contents</h2> <ul> <li><a href="#intro">1 Introduction</a></li> <li><a href="#history">2 History</a> <ul> <li><a href="#early">2.1 Early developments</a></li> <li><a href="#html5">2.2 HTML5 and beyond</a></li> </ul> </li> <li><a href="#elements">3 Elements and attributes</a></li> <li><a href="#structure">4 Document structure</a></li> <li><a href="#semantic">5 Semantic HTML</a></li> </ul> </div> <h2 id="intro">1 Introduction</h2> <p> <b>HyperText Markup Language (HTML)</b> is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript. </p> <p> Web browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document. </p> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/HTML5_logo_and_wordmark.svg/120px-HTML5_logo_and_wordmark.svg.png" alt="HTML5 Logo" class="article-image"> <p> HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects, such as interactive forms, may be embedded into the rendered page. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes, and other items. </p> <h2 id="history">2 History</h2> <h3 id="early">2.1 Early developments</h3> <p> In 1989, Tim Berners-Lee invented the World Wide Web. At the time, he was a software engineer at CERN, a European particle physics laboratory. He proposed a global hypertext system, which later evolved into HTML. The first publicly available description of HTML was a document called "HTML Tags", first mentioned on the Internet by Berners-Lee in late 1991. </p> <h3 id="html5">2.2 HTML5 and beyond</h3> <p> HTML5 is the fifth and current major version of HTML. It was finalized in October 2014 by the W3C. Its aims were to improve the language with support for the latest multimedia, while keeping it easily readable by humans and consistently understood by computers and devices. </p> <p> HTML5 introduced many new semantic tags like <code><article></code>, <code><section></code>, <code><nav></code>, <code><header></code>, <code><footer></code>, and <code><aside></code>, enhancing the structure of web pages. </p> <h2 id="elements">3 Elements and attributes</h2> <p> HTML documents are composed of HTML elements. Each element is marked up by a pair of tags, a "start tag" and an "end tag". For example, <code><p></code> and <code></p></code> are the start and end tags that define a paragraph. Some elements, such as <code><img></code> and <code><br></code>, are empty elements, meaning they do not have an end tag. </p> <p> Elements can have attributes, which are properties that define additional characteristics or modify the behavior of the element. For example, the <code>href</code> attribute in an <code><a></code> (anchor) tag specifies the URL of the linked page. </p> <h2 id="structure">4 Document structure</h2> <p> A basic HTML document structure includes: </p> <ul> <li><code><!DOCTYPE html></code>: Declaration defining the document type.</li> <li><code><html></code>: The root element of an HTML page.</li> <li><code><head></code>: Contains meta-information about the HTML page.</li> <li><code><body></code>: Contains the visible page content.</li> </ul> <h2 id="semantic">5 Semantic HTML</h2> <p> Semantic HTML refers to the use of HTML markup to reinforce the meaning, or semantics, of the information in web pages rather than merely to define its presentational appearance. For example, using <code><strong></code> for important text instead of just <code><b></code>. This improves accessibility and SEO. </p> </div> <div class="categories"> <p>Categories: <a href="#">Programming languages</a> | <a href="#">Web development</a> | <a href="#">Markup languages</a></p> </div> </main> </div> <footer class="main-footer"> <p>© 2023 WikiClone (This is a simplified demo. Not affiliated with Wikipedia.)</p> <p><a href="#">Privacy policy</a> | <a href="#">About WikiClone</a> | <a href="#">Disclaimers</a></p> </footer> </body> </html>
2.
style.css(The CSS Styling)/* Basic Reset & Variables */ :root { --wiki-light-gray: #f8f8f8; --wiki-medium-gray: #eaecf0; --wiki-dark-gray: #a2a9b1; --wiki-blue: #3366cc; --wiki-dark-blue: #2a5298; --wiki-border-color: #a2a9b1; --text-color: #202122; } body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; margin: 0; background-color: var(--wiki-medium-gray); color: var(--text-color); line-height: 1.6; } a { color: var(--wiki-blue); text-decoration: none; } a:hover { text-decoration: underline; } /* Header */ .main-header { background-color: #fff; padding: 10px 20px; border-bottom: 1px solid var(--wiki-border-color); display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 2px rgba(0,0,0,0.05); } .main-header .logo a { font-size: 1.8em; font-weight: bold; color: var(--wiki-dark-blue); text-decoration: none; } .search-box { display: flex; border: 1px solid var(--wiki-border-color); border-radius: 2px; overflow: hidden; } .search-box input[type="search"] { border: none; padding: 8px 10px; font-size: 0.9em; outline: none; width: 250px; } .search-box button { background-color: var(--wiki-light-gray); border: none; padding: 8px 12px; cursor: pointer; font-size: 0.9em; font-weight: bold; color: var(--text-color); border-left: 1px solid var(--wiki-border-color); } .search-box button:hover { background-color: var(--wiki-dark-gray); } /* Main Container - Flexbox for layout */ .container { display: flex; min-height: calc(100vh - 100px); /* Adjust based on header/footer height */ max-width: 1200px; /* Max width for content */ margin: 20px auto; /* Center the container */ background-color: #fff; /* Background for entire content area */ border: 1px solid var(--wiki-border-color); box-shadow: 0 2px 5px rgba(0,0,0,0.1); } /* Sidebar */ .sidebar { width: 200px; background-color: #f6f6f6; padding: 20px 0; border-right: 1px solid var(--wiki-border-color); flex-shrink: 0; /* Prevent sidebar from shrinking */ } .sidebar-section { padding: 0 15px; margin-bottom: 20px; } .sidebar-section h3 { font-size: 1em; font-weight: bold; color: #54595d; border-bottom: 1px solid var(--wiki-border-color); padding-bottom: 5px; margin-bottom: 10px; text-transform: uppercase; } .sidebar-section ul { list-style: none; padding: 0; margin: 0; } .sidebar-section li { margin-bottom: 5px; } .sidebar-section a { display: block; padding: 3px 0; color: var(--wiki-blue); text-decoration: none; font-size: 0.9em; } .sidebar-section a:hover { color: var(--wiki-dark-blue); text-decoration: underline; } /* Main Content Area */ .main-content { flex-grow: 1; /* Allows main content to take up remaining space */ padding: 20px; background-color: #fff; } .article-header h1 { font-size: 2em; margin-top: 0; margin-bottom: 10px; padding-bottom: 5px; border-bottom: 1px solid var(--wiki-border-color); color: #000; } /* Tabs */ .tabs { list-style: none; padding: 0; margin: 0 0 20px 0; display: flex; border-bottom: 1px solid var(--wiki-border-color); } .tabs li { margin-right: 5px; margin-bottom: -1px; /* Overlap border */ } .tabs li a { display: block; padding: 8px 15px; background-color: var(--wiki-light-gray); border: 1px solid var(--wiki-border-color); border-bottom: none; border-top-left-radius: 4px; border-top-right-radius: 4px; color: var(--wiki-blue); text-decoration: none; font-size: 0.9em; } .tabs li a:hover { background-color: var(--wiki-medium-gray); text-decoration: none; } .tabs li.active a { background-color: #fff; border-bottom: 1px solid transparent; /* Remove bottom border for active tab */ font-weight: bold; color: var(--text-color); cursor: default; } .tabs li.active a:hover { background-color: #fff; /* Keep white on hover for active tab */ } /* Article Body */ .article-body h2 { font-size: 1.5em; margin-top: 25px; padding-bottom: 3px; border-bottom: 1px solid var(--wiki-border-color); } .article-body h3 { font-size: 1.2em; margin-top: 20px; } .article-body p { margin-bottom: 1em; } .article-body ul { margin-left: 20px; margin-bottom: 1em; } .article-body li { margin-bottom: 0.5em; } .article-body code { background-color: var(--wiki-light-gray); border: 1px solid var(--wiki-border-color); padding: 2px 4px; border-radius: 3px; font-family: monospace; font-size: 0.9em; } .article-image { max-width: 150px; height: auto; float: right; /* Wikipedia style image */ margin: 0 0 10px 15px; /* Top, Right, Bottom, Left */ border: 1px solid var(--wiki-border-color); padding: 5px; background-color: #fff; box-shadow: 1px 1px 3px rgba(0,0,0,0.1); } /* Table of Contents */ .toc { float: right; width: 280px; border: 1px solid var(--wiki-border-color); padding: 10px 15px; margin: 5px 0 15px 15px; background-color: var(--wiki-light-gray); font-size: 0.9em; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); } .toc h2 { font-size: 1.1em; font-weight: bold; border-bottom: 1px solid var(--wiki-border-color); padding-bottom: 5px; margin-top: 0; margin-bottom: 10px; } .toc ul { list-style: none; padding: 0; margin: 0; } .toc ul ul { /* Nested TOC items */ margin-left: 15px; } .toc ul li { margin-bottom: 3px; } .toc ul li a { display: block; padding: 2px 0; color: var(--wiki-blue); } /* Categories */ .categories { border-top: 1px solid var(--wiki-border-color); padding-top: 10px; margin-top: 20px; font-size: 0.9em; } .categories p { margin: 0; } .categories a { margin-right: 5px; } /* Footer */ .main-footer { background-color: #f8f8f8; padding: 15px 20px; text-align: center; font-size: 0.8em; color: #54595d; border-top: 1px solid var(--wiki-border-color); margin-top: 20px; } .main-footer p { margin: 5px 0; } .main-footer a { color: #54595d; } .main-footer a:hover { text-decoration: underline; } /* Responsive adjustments (basic) */ @media (max-width: 768px) { .container { flex-direction: column; /* Stack sidebar and main content */ margin: 10px; box-shadow: none; border: none; } .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--wiki-border-color); padding-bottom: 10px; } .sidebar-section { padding: 0 10px; /* Adjust padding for smaller screens */ } .main-content { padding: 15px; } .main-header { flex-direction: column; align-items: flex-start; padding: 10px; } .main-header .logo { margin-bottom: 10px; } .search-box { width: 100%; } .search-box input[type="search"] { width: calc(100% - 70px); /* Adjust width for input */ } .article-image, .toc { float: none; /* Remove float for better stacking */ width: auto; margin: 15px 0; max-width: 100%; box-sizing: border-box; /* Include padding/border in width */ } }
How to Use:
- Save the first code block as
index.html. - Save the second code block as
style.cssin the same directory asindex.html. - Open
index.htmlin your web browser.
You'll see a page that closely mimics the layout and basic styling of a Wikipedia article!
Key CSS techniques used:
- Flexbox (
display: flex): Used for the main page layout (.container) to place the sidebar and main content side-by-side, and for the header elements. - Floats (
float: right): Used for the Table of Contents and the image to position them to the right of the text, similar to Wikipedia. - Box Model: Extensive use of
padding,margin, andborderto create spacing and visual separation. - Pseudo-classes (
:hover,.active): For interactive effects on links and to highlight the active tab. - CSS Variables (
:root): To define common colors and make them easy to change globally. - Basic Responsiveness (
@media): A simple media query is included to make the layout stack vertically on smaller screens (like phones).
- Save the first code block as
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.