W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Add margin-x and margin-y properties (same for padding and border-*)

From: Marat Tanalin | tanalin.com <mtanalin@yandex.ru>
Date: Mon, 16 Jan 2012 02:20:45 +0400
To: www-style@w3.org
Message-Id: <398341326666045@web92.yandex.ru>
Hello. It would be nice to have ability to specify vertical and horizontal margins, paddings, and border-* subproperties once, without need for duplicating same value in separate subproperties like margin-top/margin-bottom.

Vertical margins are margin-top and margin-bottom. Horizontal margins are margin-left and margin-right.

For example, vertical margins (paddings, border-width, border-style) are _very often_ specified equal. Currently we are forced to inevitably specify same value twice:

šššš.example {
ššššššššmargin-top: ššš1em;
ššššššššmargin-bottom: 1em;

It makes sense to introduce more elegant syntax:

šššš.example {margin-y: 1em; }

One could argue why not just specify it as {margin: 1em 0}? Answer is that it's inappropriate if we need to _override_ vertical (or horizontal) margins _already specified_ as 'margin' property for more general class. For example:

šššš.general šššššš{margin: šš1em 20px; }
šššš.general.lorem {margin-y: 2em; }
šššš.general.ipsum {margin-y: 3em; }

Currently we are forced to duplicate either vertical margin (value for more specific class):

šššš.general.lorem {margin-top: 2em; margin-bottom: 2em; }
šššš.general.ipsum {margin-top: 3em; margin-bottom: 3em; }

or horizontal one (repeating value already specified for more general class):

šššš.general.lorem {margin: 2em 20px; }
šššš.general.ipsum {margin: 3em 20px; }

This is non-DRY and makes CSS-code littered / less readable and eventually making maintenance harder.

Introducing margin-y and margin-x properties would make things simpler and smarter.

(Same applies to at least padding and border-* properties like border-width as well as any other properties where vertical/horizontal values make sense.)

Received on Sunday, 15 January 2012 22:21:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 11 February 2015 12:35:02 UTC