Is it customary to wrap each form field in it's own div?
Or just add a class to each imput so you can use different colors or styling if it is a required field vs. a not required field.
You don't have to enclose <input> tags in a <div>. You can set the CSS for the <input> tag directly, or enclose it in any appropriate container element and set the style for the container if that works best for you.
Do yourself a favor and spend some time with a book on CSS or an online tutorial. Don't try to pick things up as you go or you'll end up constantly frustrated and waste a lot of time and effort. Once you have the basics, the rest will fall into place for you pretty quickly.
Hi,
I guess div was not quite right, and I should have said container, I know you can use p and others. But if I did a form that has some fields required and others not required, I was trying to figure out if the best practice was to enclose the form fields in a container to style each field differently.
Or does it even really matter, and is it just personal preference.
yes, I have read tutorials and articles online, but the problem is they do not always tell you the best practices. they are normally just how one person does it, which might not be the best way. And I know with PHP even stuff that has recently been written is using depreicated functions and isn't really the best way to do stuff.
You're right that this isn't an instance where there's a true best practice. You start with valid HTML mark-up and then code for the desired appearance. This sometimes requires a container, or even multiple containers, to allow for differentiating instances within the CSS styling. Good luck!
Bookmarks