{"id":67307,"date":"2023-06-07T21:01:08","date_gmt":"2023-06-07T13:01:08","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=67307"},"modified":"2023-06-15T20:40:45","modified_gmt":"2023-06-15T12:40:45","slug":"common-css-mistakes","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/","title":{"rendered":"10 Common CSS Mistakes Developers Often Make"},"content":{"rendered":"<p>CSS is a powerful tool that brings our websites to life. It\u2019s the magic behind the beautiful, interactive, and responsive designs that captivate users. However, like any tool, it\u2019s not immune to misuse or misunderstanding. Even the most seasoned developers can fall into common CSS pitfalls that can turn a dream website into a nightmare of bugs and inconsistencies.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg\" alt=\"CSS coding\" width=\"1600\" height=\"900\"><\/figure>\n<p>In this blog post, we\u2019ll shine a light on the ten common CSS mistakes developers make; whether you\u2019re a beginner just dipping your toes into the CSS pool, or an experienced developer looking to brush up on best practices, this post is for you.<\/p>\n<p>By understanding and avoiding these common CSS mistakes, you can write cleaner, more efficient code, ensure your websites look and function as intended across all browsers and devices, and ultimately provide a better user experience.<\/p>\n<h2 id=\"1\">1. Not Using a Reset CSS<\/h2>\n<p>Different browsers have different default styles for elements. For example, the default margin and padding for the <code>&lt;body&gt;<\/code> element might be different in Chrome and Firefox. This can lead to inconsistencies in how your website looks across different browsers.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have a simple HTML file:<\/p>\n<pre>\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Test Page&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;h1&gt;Hello, world!&lt;\/h1&gt;\r\n&lt;\/body&gt;<\/pre>\n<p>And you have some CSS:<\/p>\n<pre>\r\nbody {\r\n    margin: 0;\r\n    padding: 0;\r\n}\r\n\r\nh1 {\r\n    margin: 0;\r\n    padding: 0;\r\n}<\/pre>\n<p>Even with this CSS, the <code>&lt;h1&gt;<\/code> might still have some margin in some browsers, because they have a default style for <code>&lt;h1&gt;<\/code> that includes a margin.<\/p>\n<h3>Fix:<\/h3>\n<p>To fix this issue, you can use a reset CSS. A reset CSS is a set of styles that you apply at the beginning of your CSS file to reset the default styles of elements. Here\u2019s a simple reset CSS:<\/p>\n<pre>\r\n* {\r\n    margin: 0;\r\n    padding: 0;\r\n    box-sizing: border-box;\r\n}<\/pre>\n<p>This CSS resets the <code>margin<\/code> and <code>padding<\/code> of all elements to <code>0<\/code>, and sets their <code>box-sizing<\/code> to <code>border-box<\/code>. This can help eliminate inconsistencies between browsers.<\/p>\n<p>However, this is a very simple reset and might not cover all elements and styles. There are more comprehensive reset CSS files available, like the Meyer\u2019s reset, which you can find online and use in your projects.<\/p>\n<p>Using a reset CSS can make your website look very plain, because it removes all default styles. After applying a reset, you\u2019ll need to style all elements yourself. But this gives you complete control over the look of your website.<\/p>\n<h2 id=\"2\">2. Not Using Shorthand Properties<\/h2>\n<p>CSS has shorthand properties that allow you to set multiple related styles at once. If you\u2019re not using them, your CSS can become unnecessarily long and harder to maintain.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have the following CSS:<\/p>\n<pre>\r\n.box {\r\n    margin-top: 10px;\r\n    margin-right: 20px;\r\n    margin-bottom: 10px;\r\n    margin-left: 20px;\r\n}<\/pre>\n<p>This CSS applies margin to all four sides of elements with the class \u201c<code>box<\/code>\u201c. But it\u2019s quite verbose.<\/p>\n<h3>Fix:<\/h3>\n<p>You can use the shorthand <code>margin<\/code> property to set all four margins at once:<\/p>\n<pre>\r\n.box {\r\n    margin: 10px 20px;\r\n}<\/pre>\n<p>This does the same thing as the previous CSS. The first value is the top and bottom margin, and the second value is the right and left margin.<\/p>\n<p>Here\u2019s another example with the <code>background<\/code> property. Instead of this:<\/p>\n<pre>\r\n.box {\r\n    background-color: #000;\r\n    background-image: url('image.jpg');\r\n    background-repeat: no-repeat;\r\n    background-position: center;\r\n}<\/pre>\n<p>You can write this:<\/p>\n<pre>\r\n.box {\r\n    background: #000 url('image.jpg') no-repeat center;\r\n}<\/pre>\n<p>Shorthand properties can make your CSS much shorter and easier to read and maintain. They can also help ensure consistency in your styles.<\/p>\n<p>However, be aware that when you use a shorthand property, any unspecified sub-properties are set to their initial values. For example, if you use the <code>background<\/code> shorthand property and don\u2019t specify a background size, the background size is set to its default value of \u201c<code>auto<\/code>\u201c.<\/p>\n<h2 id=\"3\">3. Using Inline Styles<\/h2>\n<p>Inline styles are CSS declarations that are applied directly within your HTML elements. While they might seem convenient for quick styling, they can lead to several issues:<\/p>\n<p><strong>Maintenance Difficulty<\/strong>: If you have a large HTML file with many elements using inline styles, it can become very difficult to maintain and update your styles.<\/p>\n<p><strong>Specificity Issues<\/strong>: Inline styles have a very high specificity. This means that they will override any styles declared in your external or internal CSS, making it difficult to override them when needed.<\/p>\n<p><strong>Reusability<\/strong>: Inline styles are not reusable. If you want to apply the same styles to multiple elements, you would have to repeat the inline styles for each element.<\/p>\n<h3>Example:<\/h3>\n<p>Here\u2019s an example of an inline style:<\/p>\n<pre>\r\n&lt;h1 style=\"color: blue; font-size: 2em;\"&gt;Hello, world!&lt;\/h1&gt;\r\n<\/pre>\n<h3>Fix:<\/h3>\n<p>Instead of using inline styles, it\u2019s better to use external or internal CSS. Here\u2019s how you can do the same thing with internal CSS:<\/p>\n<pre>\r\n&lt;head&gt;\r\n    &lt;style&gt;\r\n        .blue-heading {\r\n            color: blue;\r\n            font-size: 2em;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;h1 class=\"blue-heading\"&gt;Hello, world!&lt;\/h1&gt;\r\n&lt;\/body&gt;\r\n<\/pre>\n<p>And here\u2019s how you can do it with external CSS. First, create a CSS file (let\u2019s call it \u201cstyles.css\u201d):<\/p>\n<pre>\r\n.blue-heading {\r\n    color: blue;\r\n    font-size: 2em;\r\n}<\/pre>\n<p>Then, link it in your HTML file:<\/p>\n<pre>\r\n&lt;head&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"styles.css\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;h1 class=\"blue-heading\"&gt;Hello, world!&lt;\/h1&gt;\r\n&lt;\/body&gt;\r\n<\/pre>\n<p>Using external or internal CSS makes your styles easier to maintain and update, allows you to reuse styles, and avoids specificity issues. It\u2019s a best practice to avoid using inline styles whenever possible.<\/p>\n<h2 id=\"4\">4. Not Using Vendor Prefixes<\/h2>\n<p>Vendor prefixes are a way for browser makers to add new CSS features before they become part of the official CSS specifications. Not using them can lead to some CSS properties not being recognized by some browsers, causing inconsistencies in your design.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you want to use the <code>box-shadow<\/code> property, which is a relatively new addition to CSS:<\/p>\n<pre>\r\n.box {\r\n    box-shadow: 10px 10px 5px #888888;\r\n}<\/pre>\n<p>This CSS will work in most modern browsers, but older versions of some browsers might not recognize the <code>box-shadow<\/code> property.<\/p>\n<h3>Fix:<\/h3>\n<p>To ensure that your CSS works in as many browsers as possible, you can use vendor prefixes. Here\u2019s how you can add a <code>box shadow<\/code> with vendor prefixes:<\/p>\n<pre>\r\n.box {\r\n    -webkit-box-shadow: 10px 10px 5px #888888; \/* Safari and Chrome *\/\r\n    -moz-box-shadow: 10px 10px 5px #888888; \/* Firefox *\/\r\n    box-shadow: 10px 10px 5px #888888; \/* non-prefixed, works in most modern browsers *\/\r\n}<\/pre>\n<p>This CSS will apply a box shadow in Safari, Chrome, Firefox, and most other modern browsers.<\/p>\n<p>However, keep in mind that vendor prefixes should be used as a last resort. The use of vendor prefixes can lead to bloated and hard-to-maintain code. It\u2019s better to write standard CSS and let tools like Autoprefixer add the vendor prefixes for you.<\/p>\n<p>Also, note that as CSS evolves and browsers update, the need for vendor prefixes decreases. Many properties that once required vendor prefixes now are universally supported without them. Always check the current browser compatibility for a CSS feature before deciding to use vendor prefixes.<\/p>\n<h2 id=\"5\">5. Using Too Specific Selectors<\/h2>\n<p>In CSS, specificity determines which CSS rule is applied by the browsers. If your selectors are too specific, it can make your CSS hard to override and maintain. It can also lead to unnecessary complexity in your CSS.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have the following CSS:<\/p>\n<pre>\r\nbody div#container ul.nav li a {\r\n    color: blue;\r\n}<\/pre>\n<p>This selector is very specific. It selects an <code>&lt;a&gt;<\/code> element that is a descendant of an <code>&lt;li&gt;<\/code> element, which is a descendant of a <code>&lt;ul&gt;<\/code> with a class of \u201cnav\u201d, which is a descendant of a <code>&lt;div&gt;<\/code> with an ID of \u201ccontainer\u201d, which is a descendant of the <code>&lt;body&gt;<\/code>.<\/p>\n<h3>Fix:<\/h3>\n<p>It\u2019s better to use classes and keep your selectors as simple as possible. Here\u2019s how you can simplify the previous selector:<\/p>\n<pre>\r\n.nav a {\r\n    color: blue;\r\n}<\/pre>\n<p>This selector does the same thing as the previous one, but it\u2019s much simpler. It selects any <code>&lt;a&gt;<\/code> element that is a descendant of an element with a class of \u201cnav\u201d.<\/p>\n<p>Simplifying your selectors makes your CSS easier to read and maintain. It also reduces the likelihood of specificity conflicts, where more specific selectors override less specific ones.<\/p>\n<p>However, be aware that simplifying your selectors can also increase the likelihood of naming conflicts, where two elements have the same class name but should have different styles. To avoid this, you can use methodologies like BEM (Block, Element, Modifier) to name your classes in a way that reduces the likelihood of conflicts.<\/p>\n<h2 id=\"6\">6. Not Organizing Your CSS<\/h2>\n<p>If your CSS is not organized, it can be hard to find and change styles. This can lead to difficulties in maintaining your code, especially when working with large stylesheets or in a team environment.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have a CSS file with hundreds of lines of code, and the styles are all mixed up:<\/p>\n<pre>\r\nh1 {\r\n    color: blue;\r\n}\r\n\r\n.footer {\r\n    background: black;\r\n}\r\n\r\nh2 {\r\n    color: green;\r\n}\r\n\r\n.header {\r\n    background: white;\r\n}<\/pre>\n<p>In this example, the styles for different sections of the website are scattered throughout the CSS file. This can make it hard to find the styles for a specific section when you need to update them.<\/p>\n<h3>Fix:<\/h3>\n<p>A good practice is to organize your CSS in a logical way. Here\u2019s how you can organize the previous CSS:<\/p>\n<pre>\r\n\/* Header *\/\r\n.header {\r\n    background: white;\r\n}\r\n\r\nh1 {\r\n    color: blue;\r\n}\r\n\r\nh2 {\r\n    color: green;\r\n}\r\n\r\n\/* Footer *\/\r\n.footer {\r\n    background: black;\r\n}<\/pre>\n<p>In this example, the styles are grouped by the section of the website they apply to. This makes it easier to find and update the styles for a specific section.<\/p>\n<p>There are many ways to organize your CSS, and the best method depends on the specifics of your project. Some developers prefer to organize their CSS by component, others prefer to organize it by page, and others prefer to organize it by type of style (typography, layout, color, etc.).<\/p>\n<p>In addition to organizing your CSS within each file, it\u2019s also a good idea to organize your CSS files themselves. For large projects, it can be helpful to split your CSS into multiple files (for example, one for typography, one for layout, one for colors, etc.) and then import them all into a main stylesheet using <code>@import<\/code> statements. This can make your CSS easier to manage and maintain.<\/p>\n<h2 id=\"7\">7. Not Using CSS Variables<\/h2>\n<p>CSS variables, also known as custom properties, allow you to store specific values for reuse throughout your CSS. If you\u2019re not using them, you might find yourself repeating the same values over and over, which can make your CSS harder to maintain and update.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have a specific shade of blue that you use frequently in your CSS:<\/p>\n<pre>\r\n.header {\r\n    background-color: #007BFF;\r\n}\r\n\r\n.button {\r\n    background-color: #007BFF;\r\n}\r\n\r\n.link {\r\n    color: #007BFF;\r\n}<\/pre>\n<p>In this example, the same color value is repeated three times. If you decide to change this color, you would have to find and update every instance of it in your CSS.<\/p>\n<h3>Fix:<\/h3>\n<p>You can use a CSS variable to store this color value:<\/p>\n<pre>\r\n:root {\r\n    --main-color: #007BFF;\r\n}\r\n\r\n.header {\r\n    background-color: var(--main-color);\r\n}\r\n\r\n.button {\r\n    background-color: var(--main-color);\r\n}\r\n\r\n.link {\r\n    color: var(--main-color);\r\n}<\/pre>\n<p>In this example, the color value is stored in a variable called <code>--main-color<\/code>, and this variable is used wherever the color is needed. If you decide to change this color, you only need to update the variable, and the change will be applied everywhere the variable is used.<\/p>\n<p>CSS variables can make your CSS easier to maintain and update. They can also help ensure consistency in your styles. However, be aware that CSS variables are not supported in some older browsers, so if you need to support this browser, you might need to provide a fallback or use a preprocessor like Sass or Less, which have their own systems for variables.<\/p>\n<h2 id=\"8\">8. Not Considering Accessibility<\/h2>\n<p>Accessibility in web design means making your website usable for all people, regardless of their abilities or disabilities. This includes people with visual, auditory, cognitive, and motor impairments. If you\u2019re not considering accessibility in your CSS, you might be excluding a significant portion of your audience.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have a website with light gray text on a white background:<\/p>\n<pre>\r\nbody {\r\n    color: #999;\r\n    background-color: #fff;\r\n}<\/pre>\n<p>This might look stylish, but it\u2019s hard to read for people with low vision or color vision deficiencies.<\/p>\n<p>Fix:<\/p>\n<p>To make your website more accessible, you can use high contrast colors for your text and background:<\/p>\n<pre>\r\nbody {\r\n    color: #333;\r\n    background-color: #fff;\r\n}<\/pre>\n<p>This is much easier to read, even for people with vision impairments.<\/p>\n<p>In addition to color contrast, there are many other aspects of accessibility to consider in your CSS. Here are a few examples:<\/p>\n<ul>\n<li>Use relative units like em and rem for font sizes, so users can adjust the text size if needed.<\/li>\n<li>Avoid using CSS to hide content that should be accessible to screen readers. For example, use <code>visibility: hidden<\/code> or <code>opacity: 0<\/code> instead of <code>display: none<\/code>.<\/li>\n<li>Use media queries to make your design responsive, so it\u2019s usable on all screen sizes.<\/li>\n<li>Use ARIA roles and properties when necessary to provide additional information to assistive technologies.<\/li>\n<\/ul>\n<p>Remember, accessibility is not just a nice-to-have feature, it\u2019s a requirement for good web design. Making your website accessible can improve its usability for all users, not just those with disabilities.<\/p>\n<h2 id=\"9\">9. Not Testing on Multiple Browsers<\/h2>\n<p>Your website can look and behave differently on different browsers due to differences in how they interpret and render CSS. If you\u2019re not testing your website on all major browsers, you might be unaware of these differences, leading to a poor user experience for some of your visitors.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you\u2019ve used the CSS <code>grid<\/code> layout in your website design:<\/p>\n<pre>\r\n.container {\r\n    display: grid;\r\n    grid-template-columns: repeat(3, 1fr);\r\n}<\/pre>\n<p>While CSS Grid is supported in all modern browsers, it may not be fully supported or may behave differently in older versions of some browsers.<\/p>\n<h3>Fix:<\/h3>\n<p>To ensure your website looks and works correctly on all major browsers, you should test it on each one. This includes Chrome, Firefox, Safari, and Edge. There are also tools available that can help you with cross-browser testing, such as <a href=\"https:\/\/www.browserstack.com\/\">BrowserStack<\/a> and <a href=\"https:\/\/smartbear.com\/product\/bitbar\/\">BitBar<\/a>.<\/p>\n<p>If you find that a certain CSS feature is not supported or behaves differently in a certain browser, you can use feature queries (<code>@supports<\/code> rule) to provide a fallback:<\/p>\n<pre>\r\n.container {\r\n    display: flex;\r\n}\r\n\r\n@supports (display: grid) {\r\n    .container {\r\n        display: grid;\r\n        grid-template-columns: repeat(3, 1fr);\r\n    }\r\n}<\/pre>\n<p>In this example, the container will use the <code>flex<\/code> layout by default. If the browser supports CSS Grid (as determined by the <code>@supports<\/code> rule), it will use the <code>grid<\/code> layout instead.<\/p>\n<p>The goal of cross-browser testing is not to make your website look exactly the same on all browsers, but to ensure a consistent and usable experience for all users.<\/p>\n<h2 id=\"10\">10. Not Using Responsive Design<\/h2>\n<p>With the variety of devices and screen sizes today, it\u2019s important to make your website responsive. This means that the layout and design of your website should adapt to the screen size of the device it\u2019s being viewed on. If you\u2019re not using responsive design, your website might be hard to use on some devices, particularly mobile devices.<\/p>\n<h3>Example:<\/h3>\n<p>Let\u2019s say you have a website with a fixed width:<\/p>\n<pre>\r\n.container {\r\n    width: 1200px;\r\n}<\/pre>\n<p>This website will look fine on screens that are 1200px wide or larger, but on smaller screens, it will cause horizontal scrolling, which is generally considered a poor user experience.<\/p>\n<h3>Fix:<\/h3>\n<p>To make your website responsive, you can use media queries to apply different styles for different screen sizes. Here\u2019s how you can make the previous example responsive:<\/p>\n<pre>\r\n.container {\r\n    width: 100%;\r\n    max-width: 1200px;\r\n    margin: 0 auto;\r\n}<\/pre>\n<p>In this example, the container will take up 100% of the screen width on smaller screens, and it will be centered with a maximum width of 1200px on larger screens.<\/p>\n<p>You can also use media queries to apply completely different styles for different screen sizes. For example:<\/p>\n<pre>\r\n.container {\r\n    width: 100%;\r\n}\r\n\r\n@media (min-width: 768px) {\r\n    .container {\r\n        width: 750px;\r\n        margin: 0 auto;\r\n    }\r\n}\r\n\r\n@media (min-width: 1200px) {\r\n    .container {\r\n        width: 1170px;\r\n        margin: 0 auto;\r\n    }\r\n}<\/pre>\n<p>In this example, the container will be full width on screens smaller than 768px, 750px wide on screens between 768px and 1199px, and 1170px wide on screens that are 1200px or larger.<\/p>\n<p>Using responsive design can make your website more user-friendly and accessible to a wider audience. It\u2019s a crucial aspect of modern web design.<\/p>","protected":false},"excerpt":{"rendered":"<p>How to avoid these common pitfalls to write cleaner, more efficient CSS code.<\/p>\n","protected":false},"author":113,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[507,4501],"topic":[],"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>10 Common CSS Mistakes Developers Often Make - Hongkiat<\/title>\n<meta name=\"description\" content=\"How to avoid these common pitfalls to write cleaner, more efficient CSS code.\" \/>\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\/common-css-mistakes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"10 Common CSS Mistakes Developers Often Make\" \/>\n<meta property=\"og:description\" content=\"How to avoid these common pitfalls to write cleaner, more efficient CSS code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/\" \/>\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=\"2023-06-07T13:01:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-15T12:40:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg\" \/>\n<meta name=\"author\" content=\"Thoriq Firdaus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@tfirdaus\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thoriq Firdaus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/\"},\"author\":{\"name\":\"Thoriq Firdaus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\"},\"headline\":\"10 Common CSS Mistakes Developers Often Make\",\"datePublished\":\"2023-06-07T13:01:08+00:00\",\"dateModified\":\"2023-06-15T12:40:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/\"},\"wordCount\":2354,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/common-css-mistakes\\\/web-developer-coding-css.jpg\",\"keywords\":[\"CSS\",\"CSS Tutorials\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/\",\"name\":\"10 Common CSS Mistakes Developers Often Make - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/common-css-mistakes\\\/web-developer-coding-css.jpg\",\"datePublished\":\"2023-06-07T13:01:08+00:00\",\"dateModified\":\"2023-06-15T12:40:45+00:00\",\"description\":\"How to avoid these common pitfalls to write cleaner, more efficient CSS code.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/common-css-mistakes\\\/web-developer-coding-css.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/common-css-mistakes\\\/web-developer-coding-css.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/common-css-mistakes\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"10 Common CSS Mistakes Developers Often Make\"}]},{\"@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\\\/e7948c7a175d211496331e4b6ce55807\",\"name\":\"Thoriq Firdaus\",\"description\":\"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.\",\"sameAs\":[\"https:\\\/\\\/thoriq.com\",\"https:\\\/\\\/x.com\\\/tfirdaus\"],\"jobTitle\":\"Web Developer\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/thoriq\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"10 Common CSS Mistakes Developers Often Make - Hongkiat","description":"How to avoid these common pitfalls to write cleaner, more efficient CSS code.","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\/common-css-mistakes\/","og_locale":"en_US","og_type":"article","og_title":"10 Common CSS Mistakes Developers Often Make","og_description":"How to avoid these common pitfalls to write cleaner, more efficient CSS code.","og_url":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2023-06-07T13:01:08+00:00","article_modified_time":"2023-06-15T12:40:45+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg","type":"","width":"","height":""}],"author":"Thoriq Firdaus","twitter_card":"summary_large_image","twitter_creator":"@tfirdaus","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Thoriq Firdaus","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/"},"author":{"name":"Thoriq Firdaus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807"},"headline":"10 Common CSS Mistakes Developers Often Make","datePublished":"2023-06-07T13:01:08+00:00","dateModified":"2023-06-15T12:40:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/"},"wordCount":2354,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg","keywords":["CSS","CSS Tutorials"],"articleSection":["Coding"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/","url":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/","name":"10 Common CSS Mistakes Developers Often Make - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg","datePublished":"2023-06-07T13:01:08+00:00","dateModified":"2023-06-15T12:40:45+00:00","description":"How to avoid these common pitfalls to write cleaner, more efficient CSS code.","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/common-css-mistakes\/web-developer-coding-css.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/common-css-mistakes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"10 Common CSS Mistakes Developers Often Make"}]},{"@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\/e7948c7a175d211496331e4b6ce55807","name":"Thoriq Firdaus","description":"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.","sameAs":["https:\/\/thoriq.com","https:\/\/x.com\/tfirdaus"],"jobTitle":"Web Developer","url":"https:\/\/www.hongkiat.com\/blog\/author\/thoriq\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-hvB","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/67307","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\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=67307"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/67307\/revisions"}],"predecessor-version":[{"id":67497,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/67307\/revisions\/67497"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=67307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=67307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=67307"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=67307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}