π· 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