Certainly! Here’s a simplified recreation of the ChatGPT website using HTML, CSS, and JavaScript. This is a static, front-end-only mockup—it won’t connect to OpenAI’s servers or provide real AI responses, but it will look and behave similarly to the ChatGPT interface.
1. HTML (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>ChatGPT Mockup</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<div class="chatgpt-container">
<header>
<h1>ChatGPT</h1>
</header>
<main id="chat-window">
<!-- Messages will appear here -->
</main>
<form id="chat-form" autocomplete="off">
<input type="text" id="user-input" placeholder="Send a message..." autocomplete="off" required />
<button type="submit">➤</button>
</form>
</div>
<script src="script.js"></script>
</body>
</html>
2. CSS (style.css)
body {
background: #343541;
color: #ececf1;
font-family: 'Inter', Arial, sans-serif;
margin: 0;
height: 100vh;
}
.chatgpt-container {
max-width: 600px;
margin: 40px auto;
background: #444654;
border-radius: 12px;
box-shadow: 0 4px 32px rgba(0,0,0,0.2);
display: flex;
flex-direction: column;
height: 80vh;
}
header {
padding: 24px;
border-bottom: 1px solid #3e3f4b;
text-align: center;
}
main#chat-window {
flex: 1;
padding: 24px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 18px;
}
.message {
display: flex;
align-items: flex-start;
gap: 12px;
}
.message.user .bubble {
background: #19c37d;
color: #fff;
align-self: flex-end;
}
.message.assistant .bubble {
background: #565869;
color: #ececf1;
align-self: flex-start;
}
.bubble {
padding: 12px 18px;
border-radius: 16px;
max-width: 70%;
font-size: 1rem;
line-height: 1.5;
}
form#chat-form {
display: flex;
padding: 16px;
border-top: 1px solid #3e3f4b;
background: #40414f;
}
#user-input {
flex: 1;
padding: 12px;
border-radius: 8px;
border: none;
font-size: 1rem;
background: #343541;
color: #ececf1;
outline: none;
}
#chat-form button {
background: #19c37d;
color: #fff;
border: none;
border-radius: 8px;
margin-left: 8px;
padding: 0 18px;
font-size: 1.2rem;
cursor: pointer;
transition: background 0.2s;
}
#chat-form button:hover {
background: #13a06f;
}
3. JavaScript (script.js)
const chatWindow = document.getElementById('chat-window');
const chatForm = document.getElementById('chat-form');
const userInput = document.getElementById('user-input');
// Simple fake responses for demonstration
const fakeResponses = [
"Hello! How can I help you today?",
"I'm an AI language model developed by OpenAI.",
"Could you please clarify your question?",
"That's interesting! Tell me more.",
"I'm here to assist you with any questions you have."
];
function addMessage(text, sender) {
const msgDiv = document.createElement('div');
msgDiv.className = `message ${sender}`;
const bubble = document.createElement('div');
bubble.className = 'bubble';
bubble.textContent = text;
msgDiv.appendChild(bubble);
chatWindow.appendChild(msgDiv);
chatWindow.scrollTop = chatWindow.scrollHeight;
}
chatForm.addEventListener('submit', function(e) {
e.preventDefault();
const text = userInput.value.trim();
if (!text) return;
addMessage(text, 'user');
userInput.value = '';
setTimeout(() => {
// Pick a random fake response
const response = fakeResponses[Math.floor(Math.random() * fakeResponses.length)];
addMessage(response, 'assistant');
}, 700);
});
// Initial assistant message
window.onload = () => {
addMessage("Hi! I'm ChatGPT. How can I assist you today?", 'assistant');
};
How to use
- Create three files:
index.html, style.css, and script.js in the same folder.
- Copy and paste the code above into the respective files.
- Open
index.html in your browser.
Note:
- This is a static mockup for educational/demo purposes.
- For a real ChatGPT experience, you’d need to connect to the OpenAI API and handle authentication, streaming, etc.
Let me know if you want a version that connects to the real OpenAI API!