gpt-4.1-2025-04-14· OpenAI
LMArena Human Preference 140K
Create a web UI
- User
Create a web UI
- Assistant
Absolutely! Here’s a simple example of a web UI using HTML, CSS, and a bit of JavaScript. This will create a basic, modern-looking user interface with a header, a form, and a list to display submitted items.
Example: Simple Task List Web UI
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>Task List UI</title> <link rel="stylesheet" href="styles.css" /> </head> <body> <div class="container"> <header> <h1>Task List</h1> </header> <form id="taskForm"> <input type="text" id="taskInput" placeholder="Enter a new task..." required /> <button type="submit">Add Task</button> </form> <ul id="taskList"></ul> </div> <script src="script.js"></script> </body> </html>2. CSS (styles.css)
body { background: #f4f6f8; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; } .container { max-width: 400px; margin: 40px auto; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); padding: 24px; } header h1 { margin: 0 0 16px 0; font-size: 2em; color: #333; text-align: center; } form { display: flex; gap: 8px; margin-bottom: 16px; } input[type="text"] { flex: 1; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 1em; } button { padding: 8px 16px; background: #007bff; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 1em; transition: background 0.2s; } button:hover { background: #0056b3; } ul#taskList { list-style: none; padding: 0; margin: 0; } ul#taskList li { background: #f9fafb; border: 1px solid #eee; border-radius: 4px; padding: 10px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; } ul#taskList li button { background: #dc3545; padding: 4px 8px; font-size: 0.9em; } ul#taskList li button:hover { background: #a71d2a; }3. JavaScript (script.js)
const taskForm = document.getElementById('taskForm'); const taskInput = document.getElementById('taskInput'); const taskList = document.getElementById('taskList'); taskForm.addEventListener('submit', function(e) { e.preventDefault(); const taskText = taskInput.value.trim(); if (taskText !== '') { addTask(taskText); taskInput.value = ''; } }); function addTask(text) { const li = document.createElement('li'); li.textContent = text; const removeBtn = document.createElement('button'); removeBtn.textContent = 'Remove'; removeBtn.onclick = function() { taskList.removeChild(li); }; li.appendChild(removeBtn); taskList.appendChild(li); }
How to use:
- Save each code block into its respective file (
index.html,styles.css,script.js). - Open
index.htmlin your browser.
Let me know if you want a different style, more features, or a different framework (like React or Vue)!
- Save each code block into its respective file (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.