{"id":11227,"date":"2012-02-28T21:01:28","date_gmt":"2012-02-28T13:01:28","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=11227"},"modified":"2023-08-08T00:06:40","modified_gmt":"2023-08-07T16:06:40","slug":"keep-css3-markup-slim","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/","title":{"rendered":"Keeping Your CSS3 Code Markup Slim"},"content":{"rendered":"<p>Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the <a href=\"https:\/\/www.hongkiat.com\/blog\/ultimate-guide-to-web-optimization-tips-best-practices\/\">fastest possible load time<\/a> \u2013 which makes it your responsibility to keep file sizes down. There are plenty of shorthand tricks with CSS and especially under the new <a href=\"https:\/\/www.hongkiat.com\/blog\/beginners-guide-to-css3\/\">CSS3 model<\/a>.<\/p>\n<p>I have put together a few of these ideas in the guide below. We should also touch upon other areas such as minifying your CSS code. There are in-browser tools available to aid developers in the styling process but you would want to combine shortcodes with this file-size reduction to ultimately streamline the rendering process of your website.<\/p>\n<h2>Basic Tips on Formatting<\/h2>\n<p>Before we jump into the actual CSS syntax I want to go over the topic of <em><a href=\"https:\/\/www.hongkiat.com\/blog\/css-back-to-basics-terminology-explained\/\">how<\/a><\/em> <a href=\"https:\/\/www.hongkiat.com\/blog\/css-back-to-basics-terminology-explained\/\">to write your CSS<\/a>. If you\u2019re any bit familiar with web design, you\u2019ve likely seen a stylesheet before, probably more than once. The first part of each command is called the <strong>selector<\/strong>. This targets the type of element which will receive the styles added inside the curly braces, also known as <strong>properties<\/strong>.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg\" alt=\"CSS3 Property and Value pairing\"><\/figure>\n<h3>Inline Level<\/h3>\n<p>With inline styles each property is written one after the other with only spaces to separate them. This method is best applied onto selectors where you only need a couple of properties. It will save you space on the page and scrolling through your stylesheet will be much quicker. In case you\u2019ve never encountered inline CSS before, I\u2019ve added a small example below targeting HTML anchor links.<\/p>\n<pre>a {\r\n  color: #648cc8;\r\n  font-weight: bold;\r\n}\r\n\r\na:hover {\r\n  color: #739cda;\r\n  text-decoration: none;\r\n}\r\n\r\na.alt {\r\n  color: #bd4949 !important;\r\n}<\/pre>\n<h3>Block Level<\/h3>\n<p>On the other hand block-style properties are entered in one line per key\/value pair and are often indented for quicker edits when scanning the code. About 99% of the cleaner stylesheets I run into use this formatting, and it has become an industry standard to many designers. If your selector is using more than 6 or 7 properties this is the best formatting to apply.<\/p>\n<p>When you take into consideration the many new CSS3 properties, you also realize just how quickly your stylesheets fill up. And many of these properties support browser-specific copies which require almost duplicate code entries(such as border radius). You can check out my example of a block property set below targeting a sample wrapper div.<\/p>\n<pre>.wrap {\r\n  display: block;\r\n  padding: 6px 10px;\r\n  background: #FFF;\r\n  border-radius: 4px;\r\n  -moz-border-radius: 4px;\r\n  -webkit-border-radius: 4px;\r\n  -o-border-radius: 4px;\r\n}\r\n<\/pre>\n<p>Neither way of writing CSS is specifically better than the other. Ultimately it is your choice as a developer which style you prefer, and even this will according to the project you work on. It\u2019s even common to find CSS where designers have mixed both together! I personally feel that \u201cworks in progress\u201d tend to be easier with block-styles since I\u2019m constantly examining the stylesheet to make edits or additions. But for traffic-heavy domains <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.minifycss.com\/css-compressor\/\">minifying your CSS<\/a> file is the absolute best way to go.<\/p>\n<h2>Keeping Them Slim<\/h2>\n<p>By utilizing the many short codes available in CSS3 you can save a lot of development time. Editing HTML elements will become a lot easier as you understand this time-saving lingo. Additionally your code will appear more clean-cut and easier to look at.<\/p>\n<p>The only downside is that not all browsers fully support these properties. There are workarounds for many of the existing issues such as in Internet Explorer and Netscape. Thankfully the Web is always progressing forward and as CSS3 grows in popularity, we will undoubtedly experience a growth in browser compatibility too.<\/p>\n<h3>RGBa Color Transparency\/Opacity<\/h3>\n<p>The new RGBavalue isn\u2019t exactly a CSS3 <strong>property<\/strong>, but <strong>alpha transparency is specific to CSS3 only<\/strong>. Instead of the common \u201cRed Green Blue\u201d values you pass in for color you may now <strong>include a fourth option of color transparency<\/strong>. Because of this, web developers are done with transparent PNGs almost entirely.<\/p>\n<p>The basic syntax requires a value from 0-255 in the first three(3) slots and 0\u20131.0 in the alpha position. The color range is specific for how much of each hue (RGB) is visible with 0 being nothing and 255 full.<\/p>\n<pre> div { background: rgba(255, 255, 255, 0.3); }<\/pre>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>Another property <code>opacity<\/code> can be used in some circumstances. However this will affect the whole HTML element and inner content, not just the background as you saw in my example.<\/p>\n<p>Unfortunately Internet Explorer does not support the RGBa color value as of yet. You should generally include a fallback property with full opacity for these less-standard browsers. You set this up with the same values but excluding the 4th(opacity). It would look something like <code>rgba(255, 255, 255)<\/code><\/p>\n<p>Additionally Internet Explorer can be handled a bit more gracefully through conditionals. You can actually check if the browser is running IE and display a proprietary Microsoft CSS filter on command. I\u2019ve demonstrated this in my example below (note this would appear somewhere in your HTML file):<\/p>\n<pre>\r\n&lt;!--[if IE]&gt;\r\n&lt;style type=\"text\/css\"&gt;\r\n.bg {\r\n  background: transparent;\r\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff, endColorstr=#ffffff);\r\n}\r\n&lt;\/style&gt;\r\n&lt;![endif]--&gt;\r\n<\/pre>\n<h3>CSS3 Border Radius<\/h3>\n<p>I have read a few confusing forum threads about creating rounded borders with CSS3 \u2013 not so much on the side of how it\u2019s done, but with finicky browser support, web developers are scrambling for the easiest code to drop in and function as expected.<\/p>\n<pre>border-radius: top-left top-right bottom-right bottom-left;\r\n<\/pre>\n<p>The <code>border-radius<\/code> property shares similar syntax to creating a standard border, except in this case we\u2019re targeting the box corners. This property will actually accept 1 \u2013 4 values and they each target a different setup of corners.<\/p>\n<ul>\n<li><strong>1 value<\/strong>: All four corners are rounded to the same value<\/li>\n<li><strong>2 values<\/strong>: The first value applies to <code>top-left<\/code> and <code>bottom-right<\/code> while the second value hits <code>top-right<\/code> and <code>bottom-left<\/code><\/li>\n<li><strong>3 values<\/strong>: First applies to the <code>top-left<\/code> corner, the second is both <code>bottom-left<\/code> & <code>top-right<\/code> while the 3rd and final value is applied to <code>bottom-right<\/code><\/li>\n<li><strong>4 values<\/strong>: All 4 values target corners in the following order: top-left, top-right, bottom-right, bottom-left<\/li>\n<\/ul>\n<pre>\r\n\r\n div { border-radius: 4px 4px 8px 4px; }\r\n div { border-radius: 4px 4px 8px; }<\/pre>\n<p>So in the code above we\u2019re using <code>border-radius<\/code> to apply a 4px rounded effect on everything except the <code>bottom-right<\/code> border which gets an 8px smoothed curve. If you noticed it, both of these codes will actually apply the same style effect.<\/p>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>Now the main problem is that <code>border-radius<\/code> is only supported within a few browsers. Internet Explorer 9 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/stackoverflow.com\/\/questions\/635851\/support-for-border-radius-in-ie\">recently added great support<\/a> and Opera will render this as well. However even Opera has created its own property with <code>-o-border-radius<\/code> targeting their specific browser engine. Additionally <code>-moz-border-radius<\/code> is supported by Firefox\/Gecko software and <code>-webkit-border-radius<\/code> for Google Chrome\/Safari.<\/p>\n<p>The code below is an example of my bare-bone template for creating rounded corners with the largest global browser support.<\/p>\n<pre>div {\r\n  border-radius: 4px 4px 8px 4px;\r\n  -webkit-border-radius: 4px 4px 8px 4px;\r\n  -moz-border-radius: 4px 4px 8px 4px;\r\n  -o-border-radius: 4px 4px 8px 4px;\r\n}\r\n<\/pre>\n<h3>Fancy a Drop Shadow?<\/h3>\n<p>The other really awesome facet of CSS3 is the support for <strong>box<\/strong> and <strong>text shadows<\/strong>. This has been such a problem for developers in the past since background images were the only realistic option. This syntax actually follows a shorthand role that is much easier than the other properties we\u2019ve covered. It is difficult to remember the proper order of key values at first \u2013 but the more practice you put in, the easier it\u2019ll become.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css3-drop-shadow.jpg\" alt=\"css3 markup\" width=\"500\" height=\"263\"><\/figure>\n<p>Unfortunately Internet Explorer is once again the odd one out. Every other major browser including Firefox, Google Chrome, Safari and Opera fully support the <code>text-shadow<\/code> property. Developers have tried to <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.workingwith.me.uk\/articles\/css\/cross-browser-drop-shadows\">build their own IE support<\/a> in but is still very limiting. The basic syntax is written as follows:<\/p>\n<pre>\/* Text Shadow Syntax *\/\r\ntext-shadow: x-offset y-offset blur-radius color;\r\n\r\n\/* Example *\/\r\ndiv {\r\n  text-shadow: 2px 2px 1px #111;\r\n}\r\n<\/pre>\n<p>The X and Y offset tell the browser how far over right and low the shadow should appear. You can use negative values to position the shadow above and over left, respectively. But this comes off looking very awkward so I recommend positive integers. Also the blur-radius value can be used to smooth out the rigid edges, if the text shadow appears unnatural.<\/p>\n<p>This syntax is just looking into the basic notation when creating a single drop shadow effect. Highly advanced designers have studied to even create multiple shadows simultaneously! I reference <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.useragentman.com\/blog\/2011\/04\/14\/css3-text-shadow-can-it-be-done-in-ie-without-javascript\/\">this awesome blog post<\/a> from back in April 2011 which goes into great detail on imposing text shadows. If you\u2019ve got time, skim through the content just to get an idea of the more advanced features, and be sure to bookmark it as a future reference!<\/p>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>The biggest detractor we run into is Internet Explorer. Time and time again Microsoft has pushed out their own browser rendering engine which has performed sub-par at best. Now even with CSS3 taking the reigns at text shadows, IE is still behind. There is a <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/alt-web.com\/DEMOS\/CSS-Shadows.shtml\">great demo website<\/a> where you can find code examples and traditional CSS conditional comments.<\/p>\n<pre>&lt;!--[if lte IE 9]&gt;\r\n&lt;style type=\"text\/css\"&gt;\r\np {\r\n  font-size: 1.2em;\r\n  filter: shadow(color=#222222,direction=135,strength=3);\r\n  -ms-filter: \"progid:DXImageTransform.Microsoft.Shadow(color=#222222,direction=135,strength=3)\";\r\n}\r\n&lt;\/style&gt;\r\n&lt;![endif]--&gt;\r\n<\/pre>\n<p>Basically you\u2019re looking to check if the browser your user is running matches any version of Internet Explorer 9 or below. Then using MS filters we can apply a shadow into any text element (above, we\u2019re using a paragraph).<\/p>\n<h3>Easing Transitions<\/h3>\n<p>CSS3 <code>transition<\/code> is the hottest property on the design market since granny\u2019s flapjacks! Web designers have been making such a fuss about pure CSS transitions, even though support is mainly limited to Webkit browsers. You can of course utilize secondary properties for Mozilla and Opera and such. But the shorthand notation is really captivating, especially if you are against JavaScript animations for whatever reason.<\/p>\n<p>Firstly let\u2019s take a look at the original transition property. This will require 4 values which you could also break down into properties themselves. They correspond with the transition <code>property<\/code>(what is the effect), <code>duration<\/code>(how long to draw it out), <code>timing-function<\/code>(changes in speed over the animation), and <code>delay<\/code>(number of seconds to wait before animating).<\/p>\n<pre>\/** syntax **\/\r\n transition: property duration timing-function delay;\r\n \r\n\r\n img {\r\n transition-property: opacity;\r\n transition-duration: 2s;\r\n transition-timing-function: ease-in;\r\n transition-delay: 0.5s;\r\n }<\/pre>\n<p>You should intuitively understand the purpose for most of these properties except possibly the timing function. Although confusing at first, this property simply animates your transition differently so the effect will start slower, end slower, or something similar.<\/p>\n<p>W3 Schools has a <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.w3schools.com\/cssref\/css3_pr_transition-timing-function.asp\">timing function doc<\/a> online which lists all the possible values you can try out. I constantly find myself Googling for these guides, yet they make such handy bookmarks.<\/p>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>Now let\u2019s bring full browser support into play. By default the transition property is <strong>only<\/strong> supported by newer versions of Safari. Yet many users still require the <code>-webkit<\/code> prefix which also applies to Google Chrome and similar rendering engines. Below is a \u201cfinalized\u201d code block template I recommend saving and using if you need transition support from the majority of web browsers.<\/p>\n<pre>img {\r\n  transition: opacity 2s ease-in 1s; \/* standard syntax *\/\r\n  -webkit-transition: opacity 2s ease-in 1s; \/* chrome, safari, flock *\/\r\n  -moz-transition: opacity 2s ease-in 1s; \/* mozilla+gecko *\/\r\n  -o-transition: opacity 2s ease-in 1s; \/* opera *\/\r\n}\r\n<\/pre>\n<h3>Text-stroke Effects<\/h3>\n<p>This property isn\u2019t huge and you won\u2019t find many web designers using it today. But you can use <code>text-stroke<\/code> to build some really neat effects with your fonts. Webkit browsers such as Safari and Chrome are the only true supporters of this property so far. Opera and Firefox have difficulty rendering text objects with these same outlines.<\/p>\n<pre>p {\r\n  -webkit-text-stroke: width color;\r\n}\r\n\r\n\/* Example *\/\r\np {\r\n  -webkit-text-stroke: 1px #222;\r\n}\r\n<\/pre>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>If you feel the need for text stroke effects, you should always include a backup color. Mozilla and Opera can get by, however Internet Explorer users have no other options. Sadly this is one of the newer CSS3 properties which just hasn\u2019t garnered enough support from the web browser developers\u2019 community. You should spend some time playing around with <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.westciv.com\/tools\/textStroke\/index.html\">this great web tool<\/a> specifically created for building these CSS3 text outlines.<\/p>\n<h3>Box-sizing<\/h3>\n<p>The box-sizing property gives you more control over the total width\/height of any block element. By default the width\/height+border+margin+padding make up the total size of a box. However using border-box on your content pushes all your padding and margins <strong>inward<\/strong> to keep the width exactly the same. There are only two values for this property, with <code>content-box<\/code> being the default.<\/p>\n<pre>div { width: 550px; padding: 9px; box-sizing: border-box;   width will stay at 550px _old\/ }<\/pre>\n<p>As you can imagine this will come in handy at some point during your CSS career. Padding and margins can be a real pain and when you add in borders you tend to lose track of pixels.<\/p>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>Opera and IE 8 support this new property by default. IE7 and below are stuck with the content box setup unless your visitors are using quirks mode. The only additions you should know about specifically target webkit and Mozilla-powered browser engines.<\/p>\n<pre>div {\r\n  -webkit-box-sizing: border-box; \/* Safari\/Chrome *\/\r\n  -moz-box-sizing: border-box;    \/* Firefox *\/\r\n  box-sizing: border-box;         \/* Opera\/IE8+ *\/\r\n}\r\n<\/pre>\n<h3>Pure CSS3 Columns<\/h3>\n<p>Columns are a bit tricky with CSS3 but can be accomplished with minimal code. The 2 properties you want to focus on are <code>column-count<\/code> and <code>column-gap<\/code>. The count references the total number of columns you wish to apply while the gap creates a margin between each one.<\/p>\n<pre>div#cols {\r\n  column-count: 3;\r\n  column-gap: 10px;\r\n}\r\n<\/pre>\n<p>In my example we can see the ID #cols being used as a container. Inside we split the div into 3 columns with a 10px gap between each one. Further you could set <code>column-width<\/code> which is used to set the total width of each column instead of listing a solid number.<\/p>\n<p><strong>Cross-browser compatibility<\/strong><\/p>\n<p>Anything before IE8 will simply not be able to make use of this property. But as we\u2019ve seen in every example, Mozilla and Webkit offer their own solutions for multiple browsers. If you need a template check out my small example code below:<\/p>\n<pre>div#sidebar {\r\n  width: 210px;\r\n  -moz-column-count: 3;\r\n  -moz-column-gap: 7px;\r\n  -webkit-column-count: 3;\r\n  -webkit-column-gap: 7px;\r\n  column-count: 3;\r\n  column-gap: 7px;\r\n}\r\n<\/pre>\n<h3>Custom @font-face<\/h3>\n<p>You must have heard about the excitement regarding CSS3 custom fonts. Well using the @font-face property we can import external font styles and use these just like any other family. The syntax is somewhat convoluted and you\u2019ll have to spend some time getting it right. The block for <code>@font-face<\/code> is used to define a family name, afterwards you can use this in your <code>font-family<\/code> properties wherever!<\/p>\n<pre>@font-face {\r\n  font-family: 'MyNewFont';\r\n  src: url('New_Font.ttf'),\r\n       url('New_Font.eot'); \/* Internet Explorer only *\/\r\n}\r\n<\/pre>\n<p>So you see above I\u2019m not targeting any specific font type, but the syntax is what should stand out. Notice that Internet Explorer only supports <em>.eot<\/em> font types, while <em>.ttf<\/em> and <em>.otf<\/em> are popular options for the other browsers. Also of importance, you should understand that you can pass in font URLs from direct links, ie. <em>url(\u2018https:\/\/www.hongkiat.com\/css3\/fonts\/myfont.ttf\u2019);<\/em><\/p>\n<p>There is no real cross-browser issue with this setup since all rendering engines can parse these font file types. Just remember that for IE support you must include an eot version as well as your original. I feel that <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.w3schools.com\/cssref\/css3_pr_font-face_rule.asp\">W3 Schools article<\/a> has a catalog of the most important information you should check out.<\/p>\n<h2>Converting to Miniature CSS<\/h2>\n<p>This topic is debated frequently as it serves a different purpose for each project. On the one hand, web developers spend a lot of time writing their stylesheets. There is no way to encrypt this type of plaintext data and hide it from snooping eyes. If you are trying to keep others from blatantly stealing your code the best you can do is clutter up the styles and remove all line breaks\/spaces.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/minify-css.jpg\" width=\"500\" height=\"175\" alt=\"minify css\"><\/figure>\n<p>This process can be labeled as <strong>miniaturizing<\/strong> your code. Generally developers will write the CSS in standard format and then remove all whitespace before uploading to the web server. Then you have a local copy to edit quickly while also providing a smaller version on the live project. This method can obviously be useful to reduce page loads along with keeping code hijackers at bay.<\/p>\n<p>The link I posted above leading to <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/www.minifycss.com\/\">Minify CSS<\/a> has some terrific reading material on the subject. The site also provides a browser-based tool for removing such whitespace and key returns from your code. <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/csscompressor.com\/\">CSS Compressor<\/a> is another option sporting a simple interface which runs directly within your web browser. I have also heard good things about <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.cleancss.com\/\">Clean CSS<\/a>, though I have never used the app myself.<\/p>\n<h2>Related Links<\/h2>\n<p>To keep you pushing forward I\u2019ve provided six handy links from around the Web. These include not only shorthand notation but helpful guides and tutorials to access when practicing this new shorthand CSS code.<\/p>\n<ul>\n<li> <a href=\"https:\/\/www.hongkiat.com\/blog\/beginners-guide-to-css3\/\">Beginner\u2019s Guide to CSS3<\/a> <\/li>\n<li> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/Shorthand_properties\">CSS Shorthand Guide<\/a> <\/li>\n<li> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.webfx.com\/blog\/web-design\/using-css3-appropriately\/\">Are You Using CSS3 Appropriately?<\/a> <\/li>\n<li> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.quirksmode.org\/css\/contents.html\">CSS contents and browser compatibility chart<\/a> <\/li>\n<li> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/perishablepress.com\/css3-progressive-enhancement-smart-design\/\">CSS3 + Progressive Enhancement = Smart Design<\/a> <\/li>\n<li> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/meiert.com\/en\/indices\/css-properties\/\">Complete CSS\/CSS3 Properties Index<\/a> <\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>It takes a lot of dedication and practice writing CSS code to build a concrete schedule which you can follow for each project. Most web designers are happy to pick up new projects and ideas, so you will surely find the time to practice these helpful coding tips. Try copying down a small reference sheet for your own convenience in case you can\u2019t find any cheat-sheets, or even worse you lose Internet connection!<\/p>\n<p>Do you know of any other handy CSS3 properties or shortcuts? We would love to hear your thoughts and ideas in the discussion comments. Web developers are pushing for more standardization within the W3C and clearly the transition has been getting easier. CSS3 provides fantastic benefits and if you can master shorthand coding this will keep your file sizes low and deter copycats from stealing your code.<\/p>","protected":false},"excerpt":{"rendered":"<p>Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time \u2013 which makes it your responsibility to keep file sizes down. There are plenty of shorthand tricks with CSS and especially under the new CSS3 model. I have put together&hellip;<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392,352],"tags":[507,506,2016],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Keep Your CSS3 Code Markup Slim<\/title>\n<meta name=\"description\" content=\"Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time - which\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Keeping Your CSS3 Code Markup Slim\" \/>\n<meta property=\"og:description\" content=\"Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time - which\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2012-02-28T13:01:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-07T16:06:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg\" \/>\n<meta name=\"author\" content=\"Jake Rocheleau\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jake Rocheleau\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"Keeping Your CSS3 Code Markup Slim\",\"datePublished\":\"2012-02-28T13:01:28+00:00\",\"dateModified\":\"2023-08-07T16:06:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/\"},\"wordCount\":2683,\"commentCount\":48,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-code-slim\\\/css-property-value-pair.jpg\",\"keywords\":[\"CSS\",\"HTML\",\"HTML5 \\\/ CSS3 Tutorials\"],\"articleSection\":[\"Coding\",\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/\",\"name\":\"How to Keep Your CSS3 Code Markup Slim\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-code-slim\\\/css-property-value-pair.jpg\",\"datePublished\":\"2012-02-28T13:01:28+00:00\",\"dateModified\":\"2023-08-07T16:06:40+00:00\",\"description\":\"Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time - which\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-code-slim\\\/css-property-value-pair.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css3-code-slim\\\/css-property-value-pair.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/keep-css3-markup-slim\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Keeping Your CSS3 Code Markup Slim\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\",\"name\":\"Jake Rocheleau\",\"description\":\"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/jake\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Keep Your CSS3 Code Markup Slim","description":"Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time - which","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/","og_locale":"en_US","og_type":"article","og_title":"Keeping Your CSS3 Code Markup Slim","og_description":"Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time - which","og_url":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2012-02-28T13:01:28+00:00","article_modified_time":"2023-08-07T16:06:40+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg","type":"","width":"","height":""}],"author":"Jake Rocheleau","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Jake Rocheleau","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"Keeping Your CSS3 Code Markup Slim","datePublished":"2012-02-28T13:01:28+00:00","dateModified":"2023-08-07T16:06:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/"},"wordCount":2683,"commentCount":48,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg","keywords":["CSS","HTML","HTML5 \/ CSS3 Tutorials"],"articleSection":["Coding","Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/","url":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/","name":"How to Keep Your CSS3 Code Markup Slim","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg","datePublished":"2012-02-28T13:01:28+00:00","dateModified":"2023-08-07T16:06:40+00:00","description":"Web developers can save a lot of time using more sophisticated CSS3 syntax. Users who visit your page are expecting the fastest possible load time - which","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/css3-code-slim\/css-property-value-pair.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/keep-css3-markup-slim\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Keeping Your CSS3 Code Markup Slim"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a","name":"Jake Rocheleau","description":"Jake is a writer and designer with over 10 years experience working on the web. He writes about user experience design and cool resources for designers","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/jake\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-2V5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/11227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=11227"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/11227\/revisions"}],"predecessor-version":[{"id":68605,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/11227\/revisions\/68605"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=11227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=11227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=11227"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=11227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}