HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

CSS Tutorial

CSS Introduction

What is CSSCSS SyntaxHow to Add CSSCSS Comments

CSS Foundations

Cascade & InheritanceCSS SpecificityCSS UnitsBox SizingCSS VariablesCSS Math Functions

CSS Selectors

CSS Element SelectorCSS Class SelectorCSS ID SelectorCSS Universal SelectorCSS Group SelectorCSS CombinatorsCSS Attribute SelectorsCSS Pseudo ClassesCSS Pseudo Elements

CSS Colors and Backgrounds

CSS ColorsCSS HEX ColorsCSS RGB ColorsModern ColorsCSS Background ColorCSS Background ImageLayered Backgrounds

CSS Text & Fonts

CSS Text ColorCSS Text AlignmentCSS Text DecorationCSS Font FamilyCSS Font SizeWeb Fonts & TypographyText Wrapping

CSS Box Model

CSS MarginCSS PaddingCSS BorderCSS OutlineCSS Width and Height

CSS Layout

Normal FlowCSS DisplayCSS PositionAnchor PositioningCSS FloatCSS OverflowCSS Z-indexIntrinsic SizingAspect Ratio & Object FitMulti-column Layout

CSS Flexbox

Flex ContainerFlex DirectionJustify ContentAlign ItemsFlex WrapFlex Item Sizing

CSS Grid

CSS Grid ContainerCSS Grid ColumnsCSS Grid RowsCSS Grid GapCSS Grid Layout ExampleGrid PlacementGrid AreasCSS Subgrid

CSS Lists, Tables & Forms

CSS ListsCSS TablesCSS Form StylingCSS Input Fields

CSS Effects

CSS ShadowsCSS GradientsCSS FiltersCSS OpacityClipping & MaskingBlending & BackdropScroll Snap

CSS Animations & Transitions

CSS TransformCSS 2D TransformCSS 3D TransformCSS TransitionsEntry & Exit TransitionsCSS AnimationsScroll AnimationsView TransitionsMotion Paths

CSS Responsive Design

CSS Media QueriesResponsive LayoutMobile First DesignContainer QueriesPreference Media QueriesFeature Queries

Modern CSS Authoring

Cascade LayersNesting & ScopeLogical PropertiesGenerated Content

CSS Accessibility

Accessible CSSCSS ThemingModern Form StylingCSS User Interface

CSS Output & Performance

Print StylesCSS PerformanceCSS ArchitectureDebugging CSS

CSS Reference

CSS At-rulesCSS FunctionsCSS Tutorial PDF

CSS Projects

Responsive CSS Project
  1. Home
  2. /
  3. Tutorials
  4. /
  5. CSS Tutorial
  6. /
  7. CSS Input Fields

CSS Lists, Tables & Forms

CSS Input Fields

CSS Input Fields are styled using CSS to improve the appearance and usability of form input elements.

Input fields allow users to enter data such as:

  • Name
  • Email
  • Password
  • Phone Number
  • Search Queries

By applying CSS, you can customize input fields with colors, borders, spacing, focus effects, and responsive sizing. The supporting concepts are explained in CSS Form Styling and Modern Form Styling.

Syntax

CSS Input Fields Syntax

css

input {
    property: value;
}

CSS Input Fields Example

css

input {
    border: 1px solid #cccccc;
    padding: 10px;
}

This adds a border and padding to all input fields.

Attributes

PropertyDescriptionExample
widthSets input widthwidth: 100%;
paddingAdds inner spacingpadding: 10px;
borderAdds borderborder: 1px solid #ccc;
border-radiusCreates rounded cornersborder-radius: 5px;
outlineControls focus outlineoutline: none;

Example

CSS Input Fields Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS Input Fields Example</title>
    <style>
        input[type="text"],
        input[type="email"],
        input[type="password"] {
            width: 300px;
            padding: 12px;
            border: 1px solid #cccccc;
            border-radius: 5px;
            margin-bottom: 10px;
            font-size: 16px;
        }
        input:focus {
            border-color: #007acc;
            outline: none;
            box-shadow: 0 0 5px rgba(0, 122, 204, 0.3);
        }
    </style>
</head>
<body>
    <form>
        <input type="text" placeholder="Enter your name">
        <br>
        <input type="email" placeholder="Enter your email">
        <br>
        <input type="password" placeholder="Enter your password">
    </form>
</body>
</html>

Output

Browser Output

css

Three input fields will appear
Each field will have padding and rounded corners
When a field receives focus, its border color will change to blue
A subtle shadow effect will appear around the active field

Browser Support

Feature
Chrome
Edge
Firefox
Safari
caret-color57795311.1

Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.

Notes

  • Use :focus to style active input fields.
  • Avoid removing focus indicators completely, as they help accessibility.
  • width: 100%; is commonly used for responsive forms.
  • border-radius creates modern-looking inputs.
  • Consistent input styling improves user experience.

Common Input Types

Input TypePurpose
textSingle-line text input
emailEmail address input
passwordPassword input
numberNumeric input
searchSearch field
telTelephone number input

Conclusion

CSS Input Fields allow you to create visually appealing and user-friendly form controls. By styling borders, spacing, focus states, and dimensions, you can improve both the appearance and usability of forms on your website.

PreviousCSS Form StylingNextCSS Shadows