Native inputs and buttons
Definition and purpose
HTML controls supply keyboard behavior and accessible semantics before CSS is applied. Style the actual input and button instead of replacing them with non-interactive boxes. Native widgets may look different on different platforms.
Consistent font and width
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { font: inherit; width: 160px; box-sizing: border-box; padding: 8px; } </style> </head> <body> <label for="a">Name</label> <input id="a"> <button id="b" type="button">Save</button> </body></html>The input occupies 160 pixels including padding and border.
Syntax and mental model
Use font: inherit to match the surrounding type, explicit padding to provide room, and box-sizing: border-box to include borders in a declared width. appearance: none removes platform styling, not the native semantics, but can remove important visual cues; keep a visible boundary and focus indicator.
A visible button
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #b { appearance: none; background: navy; color: white; border: 2px solid navy; padding: 8px; } #b:focus-visible { outline: 3px solid black; } </style> </head> <body> <label for="a">Name</label> <input id="a"> <button id="b" type="button">Save</button> </body></html>The button retains its native activation behavior.
Common mistakes
A placeholder is not a label. A button inside a form defaults to submit unless its type is specified; use type="button" for non-submit actions.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Top layer and transformed ancestors, International component project. Next lesson: Form state pseudo-classes.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Native inputs and buttons — knowledge check
Five questions on native inputs and buttons.
What preserves native button behavior?
Which property includes padding in declared width?
What does appearance: none remove?
What labels an input persistently?
Which button type avoids default form submission?