Courses/HTML & CSS/Advanced Input Types

    Advanced Input Types & Custom Controls

    Lesson 19 โ€ข Advanced Track

    What You'll Learn

    All HTML5 input types: range, color, date, time, search
    Style range sliders with CSS (track and thumb)
    Custom checkboxes and radio buttons
    The datalist element for autocomplete suggestions
    Style the color picker input
    Build custom toggle switches with CSS only

    ๐Ÿ’ก Think of It Like This

    HTML5 input types are like specialised tools. A text input is a Swiss Army knife โ€” works for everything but nothing perfectly. A type="date" input is a calendar. A type="color" is a paint palette. Using the right input type gives users the best native controls for each data type.

    Input TypeWhat It ShowsMobile Keyboard
    rangeSlider controlN/A
    colorColor picker popupN/A
    dateCalendar date pickerDate wheel
    timeTime selectorTime wheel
    datetime-localDate + time combinedDate + time
    searchSearchable text with clear buttonSearch keyboard
    telPhone number inputNumeric pad
    urlURL input with validation.com keyboard

    HTML5 Input Types Gallery

    Try every HTML5 input type in one interactive demo.

    All HTML5 Input Types

    Interactive gallery of every modern input type

    Try it Yourself ยป
    Code Preview
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>HTML5 Input Types</title>
      <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { background: #0f172a; font-family: system-ui, sans-serif; color: #e5e7eb; padding: 30px; }
    
        .grid {
          display: grid;
          grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
          gap: 15px;
        }
    
        .input-card {
          background: #1e293b;
          padding: 15px;
          border-radius: 8px;
        }
    
        lab
    ...

    Custom Toggle Switch & Styled Checkbox

    Build beautiful custom controls using only CSS โ€” no JavaScript needed.

    Custom CSS Controls

    Toggle switches and styled checkboxes with pure CSS

    Try it Yourself ยป
    Code Preview
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Custom Controls</title>
      <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { background: #0f172a; font-family: system-ui, sans-serif; color: #e5e7eb; padding: 30px; }
    
        h2 { color: #3b82f6; margin: 25px 0 15px; }
    
        /* === TOGGLE SWITCH === */
        .toggle-label {
          display: flex;
          align-items: center;
          gap: 12px;
          cursor: pointer;
          margin: 10px 0;
          font-size: 15px;
    ...

    โš ๏ธ Common Mistakes

    • Using type="text" for everything โ€” Use the right input type (email, tel, url, number) so mobile users get the right keyboard and browsers validate automatically.
    • Hiding native inputs without preserving accessibility โ€” Use display: none on the input but keep it inside a <label> so clicking the custom control still toggles the real input.
    • Forgetting :focus-visible on custom controls โ€” Keyboard users need visible focus indicators on custom checkboxes and toggles.
    • Not providing a datalist fallback โ€” The datalist element degrades gracefully to a normal text input in unsupported browsers.

    ๐ŸŽ‰ Lesson Complete

    You can now use and style every HTML5 input type:

    • โœ… Use specialised input types (range, color, date, search) for better UX
    • โœ… Build custom toggle switches, checkboxes, and radios with pure CSS
    • โœ… Use <datalist> for autocomplete suggestions
    • โœ… Always keep custom controls accessible with labels and focus indicators

    Sign up for free to track which lessons you've completed and get learning reminders.

    Previous

    Cookie & Privacy Settings

    We use cookies to improve your experience, analyze traffic, and show personalized ads. You can manage your preferences below.

    By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising. You can customize your preferences or reject non-essential cookies.

    Privacy Policy โ€ข Terms of Service