Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Some HTML form question

<div class="myclassname">
  <form action="index.html" method="post" class="myclassname">
    <input type="text" id="name" name="user_name" class="form-group">
  </form>
</div>

1) If I have a class name (myclassname), is better place in div or form?
2) Is it better leave blank (action="" method="" id="") let the engineer fill it?

1 Answer

Steven Parker
Steven Parker
229,608 Points

The choice of class placement should be based on the purpose of the class. Also, consider why the div is around the form. If you can accomplish your needs by adding a class directly to the form perhaps the div is not needed. I'd need to see the whole code (all HTML, CSS and JavaScript) to be more specific.

As a general rule, I would suggest only leaving attributes blank if you're certain they are needed but you just don't know what values they should have. But if you're working as part of a team, perhaps this decision should be made by team and/or supervisor before the work begins.