HTML Form Elements

So, you’ve got a <form> tag sitting on your page, maybe with an action and method to give it some direction. That’s a solid start, but it’s like having an empty toolbox. The real fun begins when you start tossing in form elements — the bits that let people type stuff, choose options, or hit buttons. I remember the first time I got a form to actually do something. It was like my webpage turned into a living thing, chatting back at me. Not gonna lie, it’s a rush, and it’s way easier than it looks. Let’s unpack a few of these goodies together!

First, there’s the <input> tag. It’s the Swiss Army knife of forms. Change its type, and it does different tricks.

Here’s a classic:

<input type="text" name="username">

That’s a plain text box for typing a name or whatever. Give it a name so you can grab that info later. I’ve used this tons, like asking for someone’s favorite movie.

Then there’s:

<input type="email" name="email">

It’s smarter, checking if the input looks like an email. Messed up once by forgetting name, and my form sent nothing. Rookie move!

Next, <button>. It’s your action star:

<button type="submit">Send It</button>

Stick that in your <form>, and it submits whatever’s typed. I swapped input type="submit" for <button> once because you can style it more.

Try this combo:

<form action="/send">
<input type="text" name="message">
<button type="submit">Go</button>
</form>

Type something, click “Go”, and it’s off (well, to “/send” anyway).

Then there’s <select> for dropdowns. I love these:

<select name="color">
<option value="red">Red</option>
<option value="blue">Blue</option>
</select>

Users pick one, and it’s slick. I made a “Pick your mood” dropdown once, just for kicks. Oh, and <textarea> for bigger text:

<textarea name="story">Write here...</textarea>

Perfect for longer rants. I forgot to close it once, and my page got wonky. Always close your tags, trust me.

These are just the start, but they’re the heart of it. Next time you’re coding, mix a few into a <form> and play. It’s like giving your page a voice to ask, “Hey, what’s up?”

How-To Guides for HTML

No How-To Guide is available right now.

Keep Learning & Level Up!

Enhance your HTML skills with our in-depth tutorials and interactive quizzes.

Explore HTML Quiz