CHAPTER 36 · HTML
Specialised form controls: time, ranges, colours and files
Choose controls by the answer you need. Learn what their values mean, and separate selecting a file from uploading it.
Download example files (ZIP)Start with the question, then choose a control
Time, month, week and local date-time
Ranges: an approximate preference
Colour selection does not recolour the page
File selection: each part explained
What a real upload needs
Other controls you may meet
Follow the idea
- 1Time or month: choose a calendar or clock value
- 2Range: an approximate bounded preference
- 3Colour: choose a colour value
- 4File: select; upload needs a receiving service
A picker is an entry tool, not a booking or storage service.
Complete program: planning-controls.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Try Planning Controls</title>
</head>
<body>
<h1>Plan an imaginary study session</h1>
<p>Use fictional preferences. Keep form-result.html from Chapter 31 beside this file.</p>
<form action="form-result.html" method="get">
<p>
<label for="session-time">Starting time (local clock)</label>
<input type="time" id="session-time" name="start" value="16:30" />
</p>
<p>
<label for="study-month">Study month</label>
<input type="month" id="study-month" name="month" value="2027-02" />
</p>
<p>
<label for="study-week">Study week</label>
<input type="week" id="study-week" name="week" value="2027-W06" />
</p>
<p>
<label for="meeting">Local meeting date and time (no time zone)</label>
<input type="datetime-local" id="meeting" name="meeting" value="2027-02-09T16:30" />
</p>
<p>
<label for="pace">Practice pace: 1 slow, 5 fast</label>
<input type="range" id="pace" name="pace" min="1" max="5" step="1" value="3" />
</p>
<p>
<label for="ink">Notebook colour</label>
<input type="color" id="ink" name="ink" value="#2458a6" />
</p>
<button type="submit">Inspect planning values</button>
</form>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here. Form submission is disabled in this preview. Save the example and its result page locally to test submission. Use fictional practice values.
Complete program: file-selection.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Select a Local Practice File</title>
</head>
<body>
<h1>Try a file chooser without uploading</h1>
<p>This page only lets you select files. It has no form submission or upload service.</p>
<p id="file-help">
Use a harmless practice PDF or text file. The chooser hint is not a safety check.
</p>
<label for="notes-file">Practice notes (PDF or text; more than one allowed)</label>
<input
type="file"
id="notes-file"
name="notes"
accept=".pdf,.txt"
multiple
aria-describedby="file-help"
/>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.
Problem and solution
Common mistakes and useful tips
Do not call datetime-local a worldwide meeting time. Do not expect a colour picker to apply a theme. Do not use GET to upload file contents. Explain range endpoints and test arrow keys. Use harmless fictional practice files.
Practice questions
Which control suits a month and year? Does datetime-local include a time zone? How many stops are in the example slider? Does accept guarantee a safe PDF? What does multiple do on a file input? Save both examples. Change the pace with arrow keys and select a harmless text file. What did not happen?
Check your practice answers
Type=month; a value can be 2027-02. No. Agree or collect the zone separately for a remote meeting. Five: 1, 2, 3, 4 and 5. No. It guides selection; the receiver must check the actual file. It permits selecting more than one file where supported. No live range number, theme change, booking or upload is created by these examples.
Interview questions
Is JavaScript required for a normal file upload?
Why does datetime-local need care?
When is range useful?
How do accept and file validation differ?
Quick revision
Match the input to the answer. Explain formats, limits and browser differences. Selection does not mean upload. A real service must check received data.