{"id":29619,"date":"2019-04-09T18:19:40","date_gmt":"2019-04-09T10:19:40","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=29619"},"modified":"2023-04-06T19:20:28","modified_gmt":"2023-04-06T11:20:28","slug":"css-debug-code","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/","title":{"rendered":"Revolutionize Your CSS Layout With Our Debugger Tool"},"content":{"rendered":"<p>How many times have you struggled to <strong>find one specific problem<\/strong> messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS issues are a dime a dozen. And with <strong><a target=\"_blank\" href=\"https:\/\/gist.github.com\/addyosmani\/fd3999ea7fce242756b1\" rel=\"noopener\">this CSS layout debugger<\/a><\/strong>, the process just <strong>got a lot easier<\/strong>.<\/p>\n<p>This one line of code will <strong>traverse the DOM<\/strong> and <strong>outline each element<\/strong> with a different color. This way you can <strong>better visualize<\/strong> how your CSS is working (or not working) and <strong>quickly spot problem areas<\/strong>.<\/p>\n<figure><a target=\"_blank\" href=\"https:\/\/gist.github.com\/addyosmani\/fd3999ea7fce242756b1\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.jpg\" alt=\"dom debug\" width=\"800\" height=\"309\"><\/a><\/figure>\n<p>GitHub allows developers to <strong>save little bits of code<\/strong> called <a target=\"_blank\" href=\"https:\/\/help.github.com\/articles\/about-gists\/\" rel=\"noopener\">Gists<\/a>. These are all open source and free to <strong>save for your own use<\/strong>. That\u2019s why <a target=\"_blank\" href=\"https:\/\/gist.github.com\/addyosmani\/fd3999ea7fce242756b1\" rel=\"noopener\">this CSS debugger<\/a> is so useful. It combines the <strong>modern prowess of Chrome DevTools<\/strong> with the <strong>simplicity of <a href=\"https:\/\/www.hongkiat.com\/blog\/100-useful-bookmarklets-for-better-productivity-ultimate-list\/\">browser bookmarklets<\/a><\/strong>.<\/p>\n<p>To use this code, you should first <strong>copy whichever version you like the best<\/strong> from the <a target=\"_blank\" href=\"https:\/\/gist.github.com\/addyosmani\/fd3999ea7fce242756b1\" rel=\"noopener\">Gist page<\/a>. Then, you <strong>paste that code<\/strong> into your Terminal window and <strong>run it<\/strong>. You should end up with <strong>a result like this<\/strong>:<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/02-wacom-debug-sample.jpg\" alt=\"wacom debugging\" width=\"800\" height=\"517\"><\/figure>\n<p>Now, it is possible to <strong>save this code as a bookmarklet<\/strong> in your browser toolbar. But if you\u2019re a Chrome user you can <strong>save this JS code as <a target=\"_blank\" href=\"https:\/\/developer.chrome.com\/docs\/devtools\/\/snippets\" rel=\"noopener nofollow\">a code snippet<\/a><\/strong> which is much easier to run.<\/p>\n<p>This code snippet can be <strong>recalled over and over<\/strong> at the click of a button. You can <strong>parse every page<\/strong>, full of these colorful CSS outlines, for DOM elements of parents and children alike.<\/p>\n<p>However, you shouldn\u2019t feel limited only to Chrome. This snippet <strong>works for all major browsers<\/strong>, including Firefox, Safari, Opera, and Internet Explorer.<\/p>\n<p>And for anyone curious to learn how this works, you can check out the <strong><a target=\"_blank\" href=\"https:\/\/gist.github.com\/addyosmani\/fd3999ea7fce242756b1#file-annotated-js\" rel=\"noopener\">annotated version<\/a><\/strong> with comments for each line of code.<\/p>\n<p>This Gist is full of <strong>related user comments<\/strong> and <strong>updates from other developers<\/strong> helping to make it smaller and more efficient. But in its current state, this is one of the simplest ways to <strong>debug any DOM with a single line of code<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/03-firefox-nightly-build-sample.jpg\" alt=\"firefox nightly debug\" width=\"800\" height=\"452\"><\/figure>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/code-optimization-series-refactoring-css\/\">How to Refactor CSS \u2013 A Guide<\/a>\n\t\t\t\t<\/p>","protected":false},"excerpt":{"rendered":"<p>How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS issues are a dime a dozen. And with this CSS layout debugger, the process just got a lot easier. This one line of code will traverse the DOM and outline&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":[352],"tags":[511],"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.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>This CSS Layout Debugger Will Be Developer&#039;s Next Best Friend<\/title>\n<meta name=\"description\" content=\"How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS\" \/>\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\/css-debug-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Revolutionize Your CSS Layout With Our Debugger Tool\" \/>\n<meta property=\"og:description\" content=\"How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/\" \/>\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=\"2019-04-09T10:19:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-06T11:20:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/\"},\"author\":{\"name\":\"Jake Rocheleau\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/966b2daea15283b4145e71aa98a82c2a\"},\"headline\":\"Revolutionize Your CSS Layout With Our Debugger Tool\",\"datePublished\":\"2019-04-09T10:19:40+00:00\",\"dateModified\":\"2023-04-06T11:20:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/\"},\"wordCount\":335,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-debug-code\\\/01-debug-dom-elements.jpg\",\"keywords\":[\"Web Developers\"],\"articleSection\":[\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/\",\"name\":\"This CSS Layout Debugger Will Be Developer's Next Best Friend\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-debug-code\\\/01-debug-dom-elements.jpg\",\"datePublished\":\"2019-04-09T10:19:40+00:00\",\"dateModified\":\"2023-04-06T11:20:28+00:00\",\"description\":\"How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-debug-code\\\/01-debug-dom-elements.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/css-debug-code\\\/01-debug-dom-elements.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/css-debug-code\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Revolutionize Your CSS Layout With Our Debugger Tool\"}]},{\"@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":"This CSS Layout Debugger Will Be Developer's Next Best Friend","description":"How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS","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\/css-debug-code\/","og_locale":"en_US","og_type":"article","og_title":"Revolutionize Your CSS Layout With Our Debugger Tool","og_description":"How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS","og_url":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2019-04-09T10:19:40+00:00","article_modified_time":"2023-04-06T11:20:28+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/"},"author":{"name":"Jake Rocheleau","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/966b2daea15283b4145e71aa98a82c2a"},"headline":"Revolutionize Your CSS Layout With Our Debugger Tool","datePublished":"2019-04-09T10:19:40+00:00","dateModified":"2023-04-06T11:20:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/"},"wordCount":335,"commentCount":1,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.jpg","keywords":["Web Developers"],"articleSection":["Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/","url":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/","name":"This CSS Layout Debugger Will Be Developer's Next Best Friend","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.jpg","datePublished":"2019-04-09T10:19:40+00:00","dateModified":"2023-04-06T11:20:28+00:00","description":"How many times have you struggled to find one specific problem messing up your CSS layout? From missing closing tags to improperly nested siblings, CSS","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/css-debug-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/css-debug-code\/01-debug-dom-elements.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/css-debug-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Revolutionize Your CSS Layout With Our Debugger Tool"}]},{"@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-7HJ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/29619","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=29619"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/29619\/revisions"}],"predecessor-version":[{"id":66021,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/29619\/revisions\/66021"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=29619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=29619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=29619"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=29619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}