Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

keywords (initial, revert, etc) in padding and margin shorthand properties

Here is a padding shorthand property:

selector {
  padding: 0 1em;
}

which is the same as

selector {
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 1em;
  padding-right: 1em;
}

I have tried to use the same shorthand as in the first example with keywords (initial, inherit, unset, revert) instead of numbers, but this doesn’t work. May be there is some workaround or I simply don’t know something very simple?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

selector {
  padding: revert 1em; /* doesn't work */
}

selector {
  padding: 'revert' 1em; /* and this too */
}

>Solution :

Use padding-inline to target only left and right side

padding-inline: 1em;
div {
  padding-inline: 1em;
  border:1px solid red;
}
<div>box</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading