Typefully

5 Best Practices For Better HTML Forms

Avatar

Share

Β β€’Β 

3 years ago

Β β€’Β 

View on X

πŸ”· 5 Best Practices For Better HTML Forms A Thread🧡 πŸ‘‡
πŸ“Œ Forms are an essential part of any UI. πŸ“Œ It can be intimidating to work with HTML forms. πŸ“Œ They don't only use a few specialised HTML elements; they also blur the barrier between static material and user involvement.
πŸ“Œ Forms can be complex and even irritating for users; they frequently interrupt a user's main focus and direction on a page: they want to buy that gift or try out your new web app, not give you their mailing address or create yet another password.
πŸ“Œ These pointers will make form development and design easier for you as a developer or designer, as well as for your users.
1️⃣ Label fieldset with Legends β†’ It's hard to justify using a fieldset without giving it a name. β†’ We may improve the code above by titling our fieldset with the legend element.
β†’ The legend will arrange itself over the border of the fieldset element, which has a border by default.
2️⃣ Use the label Element β†’ While there's nothing wrong with using a span to mark the inputs, the label tag is a natural fit for them.
3️⃣ Name Your Inputs β†’ Each input element must have a name if you wish to transfer form data to a script; if you're using PHP, these names will become the keys of a superglobal array, commonly $_POST or $_GET.
4️⃣ Give Labels the for Attribute β†’ The for attribute allows you to associate a label with an input. β†’ The id of the input you wish to tie it to should be the same as the value of for.
5️⃣ Use optgroup to Categorize Options β†’ The optgroup is a little-known element that will indent and title choices. β†’ It is important to note that the label attribute is essential.
Thanks for reading this thread ❀️ If you like it , make sure you: πŸ”· Like the tweet πŸ”· Retweet the first tweet ⚑ For more content , follow: @MrunayU
Avatar

Mrunay Uttarwar

@MrunayU

🌐 Front End Dev πŸ’» Transitioning into Web3 πŸš€ Content Creator πŸ“ Always learning and sharing my journey πŸ’» Let's connect and geek out!