Codelab Editor
Free Online HTML Editor
Run
Learn JSON
<!DOCTYPE html> <html> <head> <style> body { padding: 10px; background: #fafafa; } .user-card { display: none; max-width: 300px; padding: 16px; border: 1px solid #ccc; border-radius: 12px; background-color: #f1f1f1; font-family: sans-serif; margin-top: 20px; } .user-card h3 { margin: 0 0 10px; font-size: 20px; } button { margin-right: 10px; padding: 8px 16px; border: none; background-color: #007acc; color: white; border-radius: 6px; cursor: pointer; } button:hover { background-color: #005f99; } </style> </head> <body> <h2>Display User Name</h2> <p>Click a button to show a user's name from a simple JSON array.</p> <button onclick="showUser(0)">First User</button> <button onclick="showUser(1)">Second User</button> <div class="user-card" id="userCard"> <h3 id="username"></h3> </div> <script> function showUser(index) { const userData = '["Bob", "Alice", "John"]'; const users = JSON.parse(userData); if (index >= 0 && index < users.length) { document.getElementById('username').textContent = users[index]; document.getElementById('userCard').style.display = 'block'; } } </script> </body> </html>
Editor Commands
Ctrl
F
Find
Ctrl
G
Find Next
Ctrl
⇧
G
Find Previous
Ctrl
⇧
F
Find & Replace
Ctrl
]
Indent Code Right
Ctrl
[
Indent Code Left
⇧
Tab
Auto Indent Code
Ctrl
/
Line Comment
Ctrl
Alt
/
Block Comment
TutsInsider Actions
Alt
S
Run Code
Ctrl
C
Copy Editor Code
Ctrl
A
Select All Editor Code
Ctrl
S
Save/Download
Ctrl
Alt
X
Rotate
Ctrl
Alt
T
Switch Theme
Ctrl
⇧
C
Open Console
Esc
Close Console