<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
	<channel>
		<title>Things to NOT Avoid When Writing CSS | Infinum</title>
		<atom:link href="https://infinum.com/blog/things-to-not-avoid-when-writing-css/feed/" rel="self" type="application/rss+xml" />
		<link>https://infinum.com/blog/things-to-not-avoid-when-writing-css/</link>
		<description>Building digital products</description>
		<lastBuildDate>Fri, 03 Apr 2026 12:58:20 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>

					<item>
				<image>
					<url>7997https://infinum.com/uploads/2017/02/things-to-not-avoid-when-writing-css-0.gif</url>
				</image>
				<title>Things to NOT Avoid When Writing CSS</title>
				<link>https://infinum.com/blog/things-to-not-avoid-when-writing-css/</link>
				<pubDate>Thu, 05 Nov 2015 06:39:00 +0000</pubDate>
				<dc:creator>Mihael Šafarić</dc:creator>
				<guid isPermaLink="false">https://infinum.com/the-capsized-eight/things-to-not-avoid-when-writing-css/</guid>
				<description>
					<![CDATA[<p>A blog post about things to avoid when writing CSS caught our attention a few days ago. We beg to differ on some of the points raised.</p>
<p>The post <a href="https://infinum.com/blog/things-to-not-avoid-when-writing-css/">Things to NOT Avoid When Writing CSS</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</description>
				<content:encoded>
					<![CDATA[<div
	class="wrapper"
	data-id="es-178"
	 data-animation-target='inner-items'>
		
			<div class="wrapper__inner">
			<div class="block-blog-content js-block-blog-content">
	
<div class="block-blog-content-sidebar" data-id="es-92">
	</div>

<div class="block-blog-content-main">
	
<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-95"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-93">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-94'
	>
	A blog post titled <a href="https://medium.com/@Heydon/things-to-avoid-when-writing-css-1a222c43c28f#.mr0486xku">Things To Avoid When Writing CSS</a> caught our attention a few days ago. We appreciate the author’s point of view, but we just couldn’t bring ourselves to agree on all the points raised.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-98"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-96">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-97'
	>
	We thought it would be useful if we shared our experience and views on how to write efficient and maintainable CSS.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-101"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-99">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-100'
	>
	Multiple CSS files</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-104"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-102">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-103'
	>
	A CSS file is an ordered set of rules, so when writing CSS, a developer should always pay attention to the order of the rules.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-107"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-105">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-106'
	>
	Even a small project can rely on a CSS file that can grow quite large. As the project grows, the CSS file becomes bigger and bigger. Eventually, keeping track of all those rules becomes hard, and even a small change becomes fertile ground for your baldness.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-110"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-108">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-109'
	>
	While writing HTML or JavaScript, you organize it in multiple files. You should follow the same principle while writing CSS. It’s easier to find related information as it is grouped in separate files. Also, when a versioning system is used, more people are able to work on the project with less merge conflicts.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-113"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-111">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-112'
	>
	As for the specificity argument, if a rule depends on another rule, both of them need to be in the same file. In that way, it’s easy for you to manage that dependency.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-116"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-114">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-115'
	>
	You should always be aware that your files will generate one big CSS file and that, in some cases, the order of CSS files is crucial.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-119"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-117">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-118'
	>
	As a rule of thumb, we try to keep our SASS files under 200 lines of code with optimal length of around 100 lines per file. Also, complicated blocks that have over 50 lines of code should go into separate files.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-122"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-120">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-121'
	>
	From our experience, the modularization of CSS pays off even in cases when a single developer works on the project. Furthermore, the benefits of modularization increase with more developers working together.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-125"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-123">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-124'
	>
	<strong>Summary:</strong> Split your CSS code into different files and then use one main file to manage the loading order. Be wary of specificity as you would be if it was all in one file. Keep individual files under 200 LOC.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-128"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-126">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-127'
	>
	Nesting (with SASS)</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-131"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-129">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-130'
	>
	Nesting improves code readability and eliminates duplication. Most problems with nesting come from not understanding what the generated CSS will look like.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-134"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-132">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-133'
	>
	That being said, there’s no good excuse for not using it. Someone who writes SASS code with obnoxiously deep nesting would probably also write lousy non-nested CSS. For them, nesting is just another tool to shoot themselves in the foot.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-137"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-135">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-136'
	>
	We use <a href="http://getbem.com/introduction/">BEM methodology</a> and keep our nesting no more than three levels deep. There are some exceptions where we use four levels of nesting. This keeps our generated CSS code relatively flat.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-140"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-138">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-139'
	>
	<strong>Summary:</strong> Nesting in SASS is NOT inherently a bad thing and you should use it. However, in general, it should be no more than three levels deep.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-143"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-141">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-142'
	>
	Pixel units</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-146"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-144">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-145'
	>
	Using measurement units other than pixels is great, but you just can’t use them for some designs. There is a reason why it’s called <strong>pixel perfect</strong>. A designer has a vision of what the design should look like. By using pixel measurements, a developer has full control over the sizes, which is sometimes necessary.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-149"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-147">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-148'
	>
	This doesn’t mean that you shouldn’t use relative measurement units (em, rem, %, etc.). They are useful and powerful for elements that change depending on the screen size.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-152"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-150">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-151'
	>
	<strong>Summary:</strong> Using relative units of measurement is great, but they aren’t applicable to every metric in your CSS.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-155"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-153">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-154'
	>
	Device breakpoints</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-158"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-156">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-157'
	>
	This is actually the part of the article we agree on the most. There are many different devices with different screen sizes and, of course, you won’t have breakpoints for every single one of them.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-161"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-159">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-160'
	>
	<strong>Summary:</strong> Determine the number of breakpoints based on the design. A few breakpoints are usually enough.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-164"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-162">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-163'
	>
	Conclusion</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-167"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-165">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-166'
	>
	CSS is <strong>not a programming language</strong> (rather a stylesheet language), but there are a lot of <strong>good programming practices</strong> from other languages we can learn from and apply them to CSS.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-170"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-168">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-169'
	>
	Also, there are plenty of tools today that help us write cleaner CSS with less “I want to kill myself” moments. By using these modern techniques/rules/guides/tools, our CSS becomes cleaner, maintainable and easier to work with.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-173"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-171">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-172'
	>
	The key is <strong>understanding</strong> what is going on with your code, how the language works behind the scenes, and what <strong>your code will generate</strong>. After that, situations like Peter’s will be less frequent.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-176"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-media">
	<div	class="media block-media__media media__border--none media__align--center-center"
	data-id="es-174"
	 data-media-type='image'>

	<figure class="image block-media__image-figure image--size-stretch" data-id="es-175">
	<picture class="image__picture block-media__image-picture">
												<img
					src="https://infinum.com/uploads/2017/02/things-to-not-avoid-when-writing-css-1.gif"
					class="image__img block-media__image-img"
					alt=""
										height="345"
															width="460"
										loading="lazy"
					 />
					</picture>

			<figcaption class="image__figcaption block-media__image-figcaption">
			Peter is having a great time		</figcaption>
	</figure></div></div>	</div>
</div>
</div>		</div>
	</div><p>The post <a href="https://infinum.com/blog/things-to-not-avoid-when-writing-css/">Things to NOT Avoid When Writing CSS</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</content:encoded>
			</item>
		
	</channel>
</rss>