-2
\$\begingroup\$

I have the following CSS:

.class {
    margin: 1%;
    margin-left: 0;
}

I wonder whether another way would be better?

Option a)

.class {
    margin: 1% 1% 1% 0;
}

Option b)

.class {
    margin-top: 1%;
    margin-bottom: 1%;
    margin-right: 1%;
}

Option ...

Any other recommended ways?

\$\endgroup\$
  • \$\begingroup\$ You're really supposed to include the entirety of your code in your question, not just a section. Mention in the text of your question, the section you want evaluated. \$\endgroup\$ – Snowbody Apr 9 '15 at 13:05
  • 1
    \$\begingroup\$ Option B is different, but we cannot say which is better without more context. \$\endgroup\$ – 200_success Apr 9 '15 at 13:21
  • \$\begingroup\$ entirety of your code I have 258 lines .less - that are totally irrelevant. The only relevant part is how to structure the CSS above. \$\endgroup\$ – Mars Robertson Apr 9 '15 at 13:29
  • 1
    \$\begingroup\$ what are you trying to accomplish with this bit of code? what HTML does it affect for such purpose? is this the only class on the elements that you are styling? your question is too broad. \$\endgroup\$ – Malachi Apr 9 '15 at 14:08
1
\$\begingroup\$

What you already have leads to the least code-duplication. It's clear what the "default" margin is and then you provide a specific margin for margin-left.

I would definitely stick with this:

.class {
    margin: 1%;
    margin-left: 0;
}

Note that "option b" might not do the exact same thing, as it lacks margin-left: 0; which means that the margin-left can be applied from elsewhere.

| improve this answer | |
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.