32
readers helped!

This helped me

How to Create a Text Input Using HTML

HTML forms are what you need for getting user input. But first, you need to make a text box! Here is a simple tutorial on how to make a text box if you're using Windows.

Method 1
Method 1 of 1:

Creating a Text Input Using HTML

  1. How.com.vn English: Step 1 Create an HTML page.
    To do that, open up Notepad or any other plain text editor. On Windows, you can access Notepad via the Start Menu, at: "Accessories", then "Notepad". Or, use the Windows key + R, then type notepad and press enter.
  2. How.com.vn English: Step 2 Put in the code.
    Write the normal tags (<html><head></head><body></body></html>), and it should look like:
    Advertisement
    • Between the two body tags, (<body> and </body>), type: <form name="test">.
      How.com.vn English: Step 3 Now that you have the base code, you're ready to make a form to hold the text box and then make the text box.
    • Next the actual input element, type: <input type="text" name="textie">.
      How.com.vn English: Step 3 Now that you have the base code, you're ready to make a form to hold the text box and then make the text box.
    • Finally, close the form tag, type: </form>.
      How.com.vn English: Step 3 Now that you have the base code, you're ready to make a form to hold the text box and then make the text box.
  3. How.com.vn English: Step 4 Save the page.
    Click "File", "Save As", and then save it as test.html. Or, save it as anything.html.
  4. How.com.vn English: Step 5 Open up the window and see your new text box!
    • Using JavaScript, now you could make the text box do something in conjunction with a button!
    • If you want to put some text before the input box to explain what it is, do so before the <input> tag.
    Advertisement


Community Q&A

Search
Add New Question
  • Question
    How do I resize this text box?
    How.com.vn English: Community Answer
    Community Answer
    You can resize the text box by using CSS. For a good CSS tutorial, you can go to FreeCodeCamp, Codecademy, or W3Schools. However, there are also some very helpful How.com.vn articles.
  • Question
    How do I make a text box mandatory?
    How.com.vn English: Vinod Kumar
    Vinod Kumar
    Community Answer
    You can write required="true" / required="required" instead of required.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit

      Advertisement

      Video

      Tips

      • You can also use other programs, such as Notepad++, PSPad, JEdit, etc. More complex (and expensive) programs such as Dreamweaver are good too.
      • As the video shows, you can set a maximum amount of characters to the box! Just add the maximum length attribute to the input tag. It would look like: maxlength="10".
      • You also want to include an id. Right after name="whatever", put id="whatever". It is recommended to use the same id as the name for ease of use.
      Advertisement

      Things You'll Need

      • Any text editor
      • Browser

      Expert Interview

      Thanks for reading our article! If you’d like to learn more about dealing with html, check out our in-depth interview with Jessica Andzouana.

      About this article

      How.com.vn English: Jessica Andzouana
      Co-authored by:
      Software Engineer
      This article was co-authored by Jessica Andzouana. Jessica Andzouana is a Software Engineer based in the San Francisco Bay Area. With over five years of professional experience in front-end development, digital art, and design, she is passionate about emerging technologies such as blockchain and AI. Her background as both a programmer and artist, paired with a highly design-conscious mindset, provides her a fresh perspective and unique skill set to produce creative solutions in her field. She works at Alcacruz as a Software Engineer, and received a dual BS/BA degree from Santa Clara in Computer Science and Studio Art. This article has been viewed 132,883 times.
      How helpful is this?
      Co-authors: 34
      Updated: August 28, 2023
      Views: 132,883
      Thanks to all authors for creating a page that has been read 132,883 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement