HTML•Form Controls
HTML Form Controls: Checkboxes, Radio Buttons, and <select>
Learn how to group radio buttons with name attributes and construct dropdown menus with <option>.
Syntax
<select name="tier">
<option value="free">Free</option>
</select>
Parameters & Values
Key components and acceptable values for this structure:
| Parameter | Type | Description |
|---|---|---|
| name (radio group) | Attribute | Shares single selection mutually exclusively across radios. |
Ready-to-Run Code Example
Executable in CompilraRun this complete, working example directly without installing HTML locally:
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: sans-serif; padding: 20px; line-height: 1.6; }
.group { margin-bottom: 12px; }
select { padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1; }
</style>
</head>
<body>
<h2>Compiler Environment Configuration</h2>
<div class="group">
<label><strong>Select Language Engine:</strong></label><br />
<select id="engine">
<option value="python">Python 3.12</option>
<option value="cpp">C++ (GCC 14)</option>
<option value="rust">Rust 1.85</option>
</select>
</div>
<div class="group">
<label><input type="checkbox" checked /> Include Pre-Supplied Standard Input (stdin)</label>
</div>
</body>
</html>Expected Output:
[Rendered Dropdown Select with Languages and Checked Checkbox Option]
How It Works: Step-by-Step
- Lines 12-18: <select> dropdown populated with <option> items.
- Line 20: type="checkbox" with default checked state.
Key Concepts
- Radio buttons with identical name values are mutually exclusive.
- Checkboxes allow independent multi-value boolean selections.
Common Mistake: Giving radio buttons different name attributes
Radio buttons only group together when they share the exact same name attribute.
❌ Incorrect
<input type="radio" name="opt1" /> <input type="radio" name="opt2" /> // Both can be checked!
✅ Correct
<input type="radio" name="opt" value="1" /> <input type="radio" name="opt" value="2" />
Related HTML Tutorials & Compiler
HTML Form Validation: Client-Side Input Requirement Attributes and Constraint Tags
Enforce client-side input validation and conditional submission guards using HTML5 constraint attributes (required, pattern, minlength, min/max).
HTML Tabular Dataset Matrices: Structural Presentation Layouts with Table Semantics
Structure tabular dataset matrices using semantic table elements (<table>, <thead>, <tbody>, <tfoot>, <tr>, <th>, <td>) with column alignments and metrics formatting.
CSS Grid Layout: grid-template-columns and Responsive Grids
Master 2-dimensional layouts using CSS Grid and repeat(auto-fit, minmax(200px, 1fr)).
HTML Online Compiler
Open in Compilra IDE
Run and test HTML on Compilra
Execute this code snippet with pre-supplied standard input (stdin) in Compilra’s cloud compiler.