Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
216,057 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.