Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3666746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:55:03+00:00 2026-05-19T01:55:03+00:00

I have a feeling that this is a subjective question, but perhaps there’s something

  • 0

I have a feeling that this is a subjective question, but perhaps there’s something somewhere on the interwebs that has attempted to standardize this already and I’m just not aware of it (but someone else who will post here is).

Just a note: Please disregard any errors or omitted element attributes as I’m looking for suggestions solely regarding the authoring of the .css file itself. Both methods work. However, I personally prefer .css B as it seems more correct, but maintenance can be a pain if you’re working with nested divs whos parents change class names.

Let’s say I have a simple form on a page contained inside a div container. The form has two three fields: two input text boxes and one textarea (from, subject and message).

Which would be the more “semantically correct” CSS to accompany the following form:

<div id="contact">
<form action="/index.php/forms/contact" method="POST">
    <label for="txt_replyto">From:</label><input type="text" id="txt_replyto"></input>
    <label for="txt_replyto">Subject:</label><input type="text" id="txt_subject"></input>
    <label for="txt_replyto">Message:</label><textarea id="txt_msg"></textarea>
</form>

(.css A)

<style>
div#contact    { width: 350px; }
div#contact form   { width: 100%; }
div#contact label { float: left; width: 20%; text-align: right; }
div#contact input   { margin-left: 1%; width: 79%; float: left; }
div#contact textarea { margin-left: 1%; width: 79%; float: left; }
</style>

or

(.css B)

<style>
div#contact      { width: 350px; }
div#contact form     { width: 100%; }
div#contact form label  { float: left; width: 20%; text-align: right; }
div#contact form input    { margin-left: 1%; width: 79%; float: left; }
div#contact form textarea  { margin-left: 1%; width: 79%; float: left; }
</style>

Are there any pre-defined standards for this sort of thing (Google’ing it didn’t yield much), or is it solely personal preference?

Edit: Thar. Updated based on Jack’s reminder 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:55:04+00:00Added an answer on May 19, 2026 at 1:55 am

    I don’t know if there is any type of “pre-defined standard” for this sort of thing. However, in all of my CSS I always follow the mindset that less is more. And that is what I would recommend: write the least amount of good, clean, acceptable code to get your result.

    Both of your options are easily readable, easily followed when/if changes need to be made, and are semantically correct. I suppose at that point it then comes down to personal preference. If you feel that your second option is more correct in your eyes, go with it.

    Side note: You are saving 22 bytes in this example to do the same thing using option A. It may not seem like much, but it can add up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a feeling that this is stupid question, but I'll ask anyway... I
I have a feeling that I already know the answer to this one, but
I have a feeling that there must be client-server synchronization patterns out there. But
I realize that what counts as premature optimization has a subjective component, but this
This is my first post and I have the feeling that this is something
I have a feeling this is a repost but I can't seem to find
I have a feeling that this query is pretty easy to construct, I just
Although I have a feeling that this isn't technically possible, it's worth asking anyways.
I've been pondering this today, and I have a nagging feeling that this is
I have the feeling that is easy to find samples, tutorials and simple examples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.