{"id":1498,"date":"2012-07-10T00:22:50","date_gmt":"2012-07-10T00:22:50","guid":{"rendered":"http:\/\/cssreset.com\/?p=1498"},"modified":"2012-07-10T00:22:50","modified_gmt":"2012-07-10T00:22:50","slug":"css-shorthand-the-lowdown","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/css-shorthand-the-lowdown\/","title":{"rendered":"CSS Shorthand &#8211; The Lowdown."},"content":{"rendered":"<p>There are many CSS properties that support attribute shorthand to save time, space and may even make it easier for you to read and understand, too. Chris Coyier from <a title=\"CSS-Tricks.com\" href=\"http:\/\/CSSTricks.com\" target=\"_blank\">CSS-Tricks.com<\/a> takes us through some examples.<!--more--><\/p>\n<p>One of the more common properties that allow for shorthand to be used, is margin: and it&#8217;s the first one that Chris looks at. He explains how the shorthand is written and read, and shows how it works along the way.<\/p>\n<p>There are four main ways to use shorthand with a property like <code>margin:<\/code>. First, you can list all four values for top, right, bottom and left. If your right and left values are the same you can shorten to just three values; top, right\/left and bottom. If both your right\/left and top\/bottom values are the same it can be shortened even more to be just top\/bottom and right\/left. And lastly, if all values are equal, then you need only input one which will then be applied to each of the four margins on your page.<\/p>\n<p>So this code:<\/p>\n<pre class=\"prettyprint linenums\">#page-wrap {\r\n    width: 500px;\r\n    margin-top: 10px;\r\n    margin-left: auto;\r\n    margin-right: auto;\r\n    margin-bottom: 10px:\r\n}<\/pre>\n<p>Can be shortened to this:<\/p>\n<pre class=\"prettyprint linenums\">#page-wrap {\r\n    width: 500px;\r\n    margin: 10px auto;\r\n}<\/pre>\n<p>The same is true with other properties, like <code>padding:<\/code> for instance. The two examples below equate to being the same exact thing.<\/p>\n<pre class=\"prettyprint linenums\">p {\r\n    padding-top: 10px;\r\n    padding-left: 50px;\r\n    padding-right: 0px;\r\n    padding-bottom: 20px;\r\n}<\/pre>\n<pre class=\"prettyprint linenums\">p {\r\n    padding: 10px 0px 20px 50px;\r\n}<\/pre>\n<p>You can easily see why CSS shorthand exists and why it is a good idea to use it wherever you can. <\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>There are many CSS properties that support attribute shorthand to save time, space and may even make it easier for you to read and understand, too. Chris Coyier from CSS-Tricks.com takes us through some examples.<\/p>\n<p>Share and Enjoy !0Shares0<\/p>\n<p>0<\/p>\n<p> [&#8230;]<\/p>\n<p><a class=\"more-link video\" href=\"https:\/\/cssdeck.com\/blog\/css-shorthand-the-lowdown\/\" title=\"Click to watch 'CSS Shorthand &#8211; The Lowdown.'\">Watch Video<\/a><\/p>\n","protected":false},"author":18,"featured_media":1499,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,13],"tags":[79,75,73,102,119,121,123,122],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1498"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=1498"}],"version-history":[{"count":3,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1498\/revisions"}],"predecessor-version":[{"id":1524,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/1498\/revisions\/1524"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/1499"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=1498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=1498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=1498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}