Single declaration

Question

When should we use single declaration properties like padding and margin with values for every side?

Answer

The decision of how to structure the padding or margin of an element will always be based on the needed result of a page, if you need to have different measurements on each side, a single declaration is easier and faster to write, the same goes for elements that have the same measurements on opposite sides, but if your element will only need the distance on one side, it makes better sense to use the property for that specific side, for example:
padding-bottom: 20px;.

7 Likes

enjoying the lesson so far… I like this forum

28 Likes

Thanks for an answer.

2 Likes

Positive vibrations <3

3 Likes

Great response from you, thanks.

2 Likes

Hi everyone.

In the lesson it is mentioned that “If the left and right sides of the content can be equal, the padding shorthand property allows for 3 values to be specified. The first value sets the padding-top value , the second value sets the padding-left and padding-right values, and the third value sets the padding-bottom value.” But what if the top and bottom have equal values but the left and right sides have different ones, is there a way to write a single-line code with 3 values in this case? Thanks for your help.

2 Likes

hiya :wave: :smiling_face:
Great question
I suppose for that goal, one can use the four value padding shorthand property. I hope we can get more responses to this query though :smiling_face:
Happy coding!

1 Like