{"id":876,"date":"2011-01-04T15:38:00","date_gmt":"2011-01-04T15:38:00","guid":{"rendered":"http:\/\/cssreset.com\/"},"modified":"2022-07-28T12:48:58","modified_gmt":"2022-07-28T12:48:58","slug":"what-is-a-css-reset","status":"publish","type":"page","link":"https:\/\/cssdeck.com\/blog\/what-is-a-css-reset\/","title":{"rendered":"What Is A CSS Reset?"},"content":{"rendered":"<p>A <strong>CSS Reset<\/strong> (or &#8220;Reset CSS&#8221;) is a short, often compressed (minified) set of CSS rules that <em>resets<\/em> the styling of all HTML elements to a consistent baseline.<\/p>\n<p>In case you didn&#8217;t know, every browser has its own default &#8216;user agent&#8217; stylesheet, that it uses to make unstyled websites appear more legible. For example, most browsers by default make links blue and visited links purple, give tables a certain amount of border and padding, apply variable font-sizes to H1, H2, H3 etc. and a certain amount of padding to almost everything. Ever wondered why Submit buttons look different in every browser?<\/p>\n<p>Obviously this creates a certain amount of headaches for CSS authors, who can&#8217;t work out how to make their websites look the same in every browser. (NB: article coming soon about why this is a false notion!)<\/p>\n<p>Using a <a title=\"CSS Reset\" href=\"https:\/\/cssdeck.com\/blog\/\">CSS Reset<\/a>, CSS authors can force every browser to have all its styles reset to null, thus avoiding cross-browser differences as much as possible.<\/p>\n<h2>Basic Example: CSS Reset vs. No CSS Reset<\/h2>\n<p>Here&#8217;s the <a title=\"First website ever created\" href=\"http:\/\/www.w3.org\/History\/19921103-hypertext\/hypertext\/WWW\/TheProject.html\" rel=\"nofollow\">first website ever created<\/a>, with and without a CSS Reset:<\/p>\n<div style=\"clear: both;\">\n<p><img decoding=\"async\" loading=\"lazy\" width=\"330\" height=\"450\" class=\"size-full wp-image-926 alignleft\" style=\"width: 280px; height: auto;\" title=\"Without CSS Reset\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2011\/01\/without-css-reset.gif\" alt=\"Without CSS Reset\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2011\/01\/without-css-reset.gif 330w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2011\/01\/without-css-reset-220x300.gif 220w\" sizes=\"(max-width: 330px) 100vw, 330px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"330\" height=\"450\" class=\"size-full wp-image-927 alignright\" style=\"width: 280px; height: auto;\" title=\"With CSS Reset\" src=\"https:\/\/cssdeck.com\/blog\/\/wp-content\/uploads\/2011\/01\/with-css-reset.gif\" alt=\"With CSS Reset\" srcset=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2011\/01\/with-css-reset.gif 330w, https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2011\/01\/with-css-reset-220x300.gif 220w\" sizes=\"(max-width: 330px) 100vw, 330px\" \/><\/p>\n<\/div>\n<p style=\"clear: both;\">This is a very basic example, that doesn&#8217;t include any lists, images, or tables &#8211; but it should help give you an idea of what the CSS Reset is doing.<\/p>\n<h2>Why Use A CSS Reset?<\/h2>\n<p>You might wonder what this is all for &#8211; well, it&#8217;s simple. From the consistent base that you&#8217;ve set up via your reset, you can then go on to <em>re-style<\/em> your document, safe in the knowledge that the browsers&#8217; differences in their default rendering of HTML can&#8217;t touch you!<\/p>\n<h3>CSS Reset Issues<\/h3>\n<p>Some people claim that this is unnecessary &#8211; that there&#8217;s no sense resetting an element&#8217;s style, only to <em>un-reset<\/em> it afterwards. If you did a close up on one element, with a CSS Reset and then further styling, the issue becomes clear:<\/p>\n<pre class=\"prettyprint linenums\">\/* CSS Reset *\/\n#element { margin:0; padding:0; font-size:100%; line-height:1; }\n\n...\n\/* #element rules: *\/\n#element { margin:5px 0 10px; font-size:13px; line-height:1.5; }<\/pre>\n<p>In many ways, they&#8217;re right &#8211; it duplicates effort and processing time, when a single declaration would have sufficed &#8211; many developers and designers feel that this violates the &#8216;DRY&#8217; (Don&#8217;t Repeat Yourself) principle.<\/p>\n<p>However, there are multiple benefits of this technique that outweigh any drawbacks, not least the more logical development progression that it afford: paste in your CSS Reset, paste in your base styles (if needed), then define everything else from there. It&#8217;s also nice to know that you&#8217;ve got your bases covered.<\/p>\n<p>Another issue is to do with the <em>Cascading<\/em> part of &#8216;Cascading Style Sheets&#8217;. If your CSS Reset isn&#8217;t carefully written, you might find that your CSS rules are being themselves overwritten by the code that was supposed to be their baseline! This is often a problem when using the <a title=\"Universal Selector CSS Reset\" href=\"https:\/\/cssdeck.com\/blog\/\/scripts\/universal-selector-css-reset\/\">Universal Selector Reset<\/a>, but won&#8217;t generally be an issue if working with well-written code such as the <a title=\"HTML5 Doctor CSS Reset\" href=\"https:\/\/cssdeck.com\/blog\/\/scripts\/html5-doctor-css-reset-stylesheet\/\">HTML5 Doctor CSS Reset<\/a>.<\/p>\n<p>Hopefully this article has helped answer the whole <em>What is a CSS Reset<\/em> question with a little clarity&#8230; if you&#8217;re still left scratching your head, then\u00a0<a href=\"https:\/\/bootesnull.com\/hire-developers\/\" target=\"_blank\" rel=\"noopener\" data-saferedirecturl=\"https:\/\/www.google.com\/url?q=https:\/\/bootesnull.com\/hire-developers\/&amp;source=gmail&amp;ust=1659076412868000&amp;usg=AOvVaw1q-Wdt01804-prS59Sh-di\">hire software developers<\/a>\u00a0or\u00a0check out the companion article, <strong><a title=\"Which CSS Reset Should I Use?\" href=\"https:\/\/cssdeck.com\/blog\/\/which-css-reset-should-i-use\/\">Which CSS Reset Should I Use?<\/a><\/strong><\/p>\n<p>You can also check the perfect <a href=\"https:\/\/1.envato.market\/kj1BYM\">Shopify Mysterio<\/a> &#8211; a multipurpose fashion and beauty store theme that contains HTML, CSS, JSON, and JavaScript.<\/p>\n<p>Please shoot me a message if there&#8217;s anything you think needs to be added to this article and I&#8217;ll be happy to add it with credit and a link back!<\/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>A CSS Reset (or &#8220;Reset CSS&#8221;) is a short, often compressed (minified) set of CSS rules that resets the styling of all HTML elements to a consistent baseline.<\/p>\n<p>In case you didn&#8217;t know, every browser has its own default &#8216;user agent&#8217; [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/what-is-a-css-reset\/\" title=\"Click to read 'What Is A CSS Reset?'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/pages\/876"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"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=876"}],"version-history":[{"count":8,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/pages\/876\/revisions"}],"predecessor-version":[{"id":3498,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/pages\/876\/revisions\/3498"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}