Content · Web Development · HTML

HTML required, disabled, and readonly: Understanding Differences

Required asks the browser to check that a suitable value is entered. Readonly stops editing but can still submit its value; disabled usually prevents focus, interaction, and submission of that control.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Required asks the browser to check that a suitable value is entered. Readonly stops editing but can still submit its value; disabled usually prevents focus, interaction, and submission of that control. We will keep the example small, so you can see how the fields work without building a whole application first.

What You Need to Know


Do not use disabled for information the server must receive unless there is another trustworthy source. Readonly applies only to certain controls and does not make submitted values trustworthy.

A form is like a question sheet. The label asks the question, the control holds the answer, and the name tells the receiving application what that answer is called.

Example: See It in Action


Add this example to the appropriate part of a practice HTML page. Read each line before you open the page in your browser.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<form action="/save" method="post">
    <label><input name="nickname" value="Alex" readonly> Nickname</label>
    <label><input name="reference" value="A-9" disabled> Reference</label>
    <button type="submit">Save</button>
</form>

Let’s Understand the Example


  • Input creates a form control. Its type decides whether people type text, choose a date, move a slider and more.
  • Label tells people what a control is for. For connects the label to the control with the matching id.
  • Disabled removes a control from normal interaction and from ordinary form submission.
  • Readonly lets a control keep its value and submit it, while preventing editing where the attribute applies.
  • Action names the destination where the browser sends a form submission. A real server handler must exist there.
  • Method controls how a form submits; GET makes values part of the URL, while POST sends them in the request body.

The browser can submit values with keys such as nickname, reference. A control without a name normally contributes no entry. Whether the submission produces a result depends on the action URL and the server behind it.

What Should You See?


You should see controls for Nickname, Reference. The example uses an input of type text and sends a POST request when submitted. If the action points to a missing server endpoint, the browser cannot complete the task.

Choose one field and predict its submitted name and value. Then change the value and check whether the browser accepts it. Do not assume that a working-looking form has a real server behind it.

Try It Yourself


  1. Identify which input values the example would actually submit.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Assuming a disabled field's visible value will be sent with the form.
  • Client-side HTML validation is a helpful first check, not a security boundary. A real receiving application must validate the values again.

Key Takeaways


  • Required asks the browser to check that a suitable value is entered.
  • Input creates a form control. Its type decides whether people type text, choose a date, move a slider and more.
  • Do not use disabled for information the server must receive unless there is another trustworthy source. Readonly applies only to certain controls and does not make submitted values trustworthy.
Share this resourceSend this page to someone who may find it useful.