Complete CSS Guide for beginners and not so beginners
Published: 2020-06-23 09:07:18

---
title: Complete CSS Guide for beginners and not so beginners
published: true
description: A complete guide of CSS workflow, selectors, pseudo-selectors and CSS operation
tags: beginners, career, css, tutorial
cover_image: https://binima.com/wp-content/uploads/2018/05/css.jpg
---not

<meta name="monetization" content="$ilp.uphold.com/7QaxJkDwRZED">


<h1>Understanding CSS</h1>

<h2>What is CSS?</h2>
<p>CSS stands for Cascading Style Sheets.</p>
<p>CSS describes how HTML elements are to be displayed using rules.</p>

<h2>CSS Syntax</h2>
<p>A CSS rule consists of a selector and one or more declaration blocks:</p>

<img src="https://www.w3schools.com/whatis/img_selector.gif" width="100%" height="auto">


<h2>How to add CSS styles to your project?</h2>
<p>There's three ways CSS can be inserted into an HTML document:</p>
<ul>
<li>As external source (another file on your project or a CDN link, for example): <code>&lt;link rel="stylesheet" href="myStyles.css"></code></li>

<li>Internal Stylesheet (On the header or top body of your HTML file using style html tag): <pre>&lt;style> 
   // my css code 
&lt;/style>
</pre></li>

<li>Inline. I.E. on the same html tag using style attribute:

<code>&lt;p style="font-weight: bold;"></code></li>
</ul>

<h3>Recommendation:</h3>
<p>Add CSS files as external stylesheets but stored locally on your project. This reduces calls to external servers while performing well, specially on HTTP/2 environment. If you have a bad server/hosting provider, on a remote country (from your target users scope) and/or using HTTP/1 some benchmarking tools may suggest you to use a CDN, in which case could be better to keep the CSS files on your project and use a cache service such as cloudflare.</p>


<h2> Basic selectors </h2>
the dot <code>.</code> selects a class name and hashtag <code>#</code> selects an id. For example, on the following html:
<pre>
&lt;div id="main-content" class="container>
</pre>

The selector <code> #main-content </code> will point to the html id attribute, <code> .container </code> will search html tags with container as the value of their class attribute and <code> #container </code> or <code> .main-content </code> will not match anything as there's no main-content class or container id on the document.

<p>This will be expanded below. I'll add the full list and explanation of each selector below, after all basics.</p>



<h2>Cascading Order</h2>
<p>If different styles are specified for HTML elements, the styles will cascade into new styles with the following priority:</p>
<ol>
<li>Priority 1: Inline styles using style attribute.</li>
<li>Priority 2: Internal and external style sheets.</li>
<li>Priority 3: Browser default</li>
<li>If different styles are defined on the same priority level, the last one has the highest priority.*
</li>
</ol>
<small>This does not mean that the last you type with same priority will be applied, if it's chunked into different stylesheets, then the order you link them to your html also is not the loading order. 
"The last one with highest priority" means specifically the last one rendered by the browser.</small>

OK this is the basis, but there's much more to know about <strong>CSS priorities</strong>:
<p>The most important thing, that is strong enough to override base priorities listed above is the <strong>SPECIFICITY</strong>. You can create a selector more specific or less specific, let's see some examples:</p>

On a given html like this:
<pre>
&lt;div id="main-content" class="container">
  &lt;div class="header">
     &lt;p> TITLE &lt;/p>
  &lt;/div>
  &lt;div class="section1">
    &lt;p> TEXT CONTENT &lt;/p>
  &lt;/div>
&lt;/div>
</pre>

The following CSS rules will apply to the same element:
<pre>
#main-content.container { background: green; }
#main-content { background: red; }
.container { background: blue; }
</pre>

So which background color will our <code>&lt;div id="main-content class="container"></code> take?

It will be blue because is the last one? <strong>NO</strong>, it will be green because it's more specific.
We are selecting elements with id="main-content" which have class="container" too, not only each separately.

OK and... what if I want it yellow but can't edit this CSS rules because I'm on a big project and this could break something else?

<strong>Be more specific!</strong>
<pre>
div#main-content.container { background: yellow; }
</pre>

Now we are selecting specifically a <code>&lt;div></code> HTML tag which has an id attribute with main-content as value, and which also has a class html attribute with container as value.

<strong> Ok but there's no more to take for being more specific. What about if I'm in this situation and I need it to be white? </strong>

<pre>
div#main-content.container { background: white !important; }
</pre>

<h2><code>!important</code></h2>
this is a big double edged Katana from a big japanese war robot, take care with !importants, please.

Using important statement will make your rule hard or impossible to override. This means that if you are on a company with the hands on a project and you use it, you may be blocking a mate for overriding your styles on a design change. Moreover you may be blocking yourself from the future for being able to override it, so please, take care for not having to hate the "me" from the past.

You can add priority selecting items that are inside other items from html tag to the tag you need. 
<h3>Child Selectors</h3>
Or Nesting Selectors are <code> </code> a whitespace, that matches with all childs (described) of a (described) element (<code> div#main p.bold</code> will match all <code>&lt;p class="bold"></code> that are directly or indirectly inside the <code>&lt;div id="main"></code>) and <code>></code> which matches direct childs (<code> div#main>p.bold</code> will match any <code>&lt;p class="bold"></code> that is a direct child of the <code>&lt;div id="main"></code>).

For example:

<pre>
 html>body>div#main-content p { font-weight: bold; }
</pre>
This will select <strong>all</strong> &lt;p> tags that are inside (no matter the level) a &lt;div id="main-content"> which is directly inside the body html tag, which are directly inside the html tag (in fact, body will be always a direct child of html).

So <strong>ALL &lt;p> tags in this following snippet will be selected </strong> (and it's font will be bolded):

<pre>
&lt;html>
  &lt;head>
    &lt;title> My Example &lt;/title>
  &lt;/head>
  &lt;body>
    &lt;div id="main-content">
      &lt;p> lorem ipsum &lt;/p>
      &lt;div class="content-block">
        &lt;p> dolor sit amet &lt;/p>
      &lt;/div>
    &lt;/div>
  &lt;/body>
&lt;/html>
</pre>

<h2>CSS Combinators List:</h2>
<ul>
 <li>descendant selector (space)</li>
 <li>child selector (>)</li>
 <li>adjacent sibling selector (+)</li>
 <li>general sibling selector (~)</li>
 <li>wildcard selector (*)</li>
</ul>

<h2>Tag selectors</h2>

Tags selectors are easy to understand, simply type the same tag you want to match. For example, for matching all p tags (no matter their location inside the structure):

<pre>
 p { font-family: 'Ubuntu', sans-serif; }
</pre>

<h2> Attribute selectors: </h2>

You can match attribute and attribute-value pair too.
This CSS:
<pre>
  [data-action="expand"] { background: goldenrod; }
  [href="https://google.es"] { font-weight: bold; color: white; }
</pre>
will match the following html:
<pre>
 &lt;div data-action="expand">
    &lt;a href="https://google.es"> Go to google &lt;/a>
 &lt;/div>
</pre>

<h2> Pseudo-selectors </h2>
pseudo is a prefix that means "pretended and not real", so why they're called pseudo-selectors?

CSS introduces the concepts of pseudo-elements and pseudo-classes to permit formatting based on information that lies <strong>outside the document tree</strong> (DOM).
<ul>
<li><strong>Pseudo-elements</strong> create abstractions about the document tree beyond those specified by the document language. For instance, document languages do not offer mechanisms to access the first letter or first line of an element's content. CSS pseudo-elements allow style sheet designers to refer to this otherwise inaccessible information. Pseudo-elements may also provide style sheet designers a way to assign style to content that does not exist in the source document (e.g., the <code>:before</code> and <code>:after</code> pseudo-elements give access to generated content).</li>

<li>Pseudo-classes classify elements on characteristics other than their name, attributes or content; in principle characteristics that cannot be deduced from the document tree. Pseudo-classes may be dynamic, in the sense that an element may acquire or lose a pseudo-class while a user interacts with the document. The exceptions are <code>:first-child</code> (and another child and type pseudo selectors), which can be deduced from the document tree, and <code>:lang()</code>, which can be deduced from the document tree in some cases.</li>
</ul>

So basically, a pseudo-class is something you can attach a style to, but you never print it out in the HTML by your own. Also, a pseudo-class can be acquired and lost depending on user interaction with the UI.

<h2>Pseudo Classes List:</h2>
<small><a href="https://www.w3schools.com/css/css_pseudo_classes.asp" target="_blank"> Source </a></small>
<table>
<tr>
<td><strong>Selector</strong></td><td><strong>Example</strong></td><td><strong>Example description</strong></td></tr>
<tr><td>
:active</td><td>a:active</td><td>Selects the active link</td></tr>
<tr><td>:checked</td><td>input:checked</td><td>Selects every checked &lt;input> element</td></tr><tr>
<td>:disabled</td><td>input:disabled</td><td>Selects every disabled &lt;input> element</td></tr><tr>
<td>:empty</td><td>p:empty</td><td>Selects every &lt;p> element that has no children</td></tr><tr>
<td>:enabled</td><td>input:enabled</td><td>Selects every enabled &lt;input> element</td></tr><tr>
<td>:first-child</td><td>p:first-child</td>	<td>Selects every &lt;p> elements that is the first child of its parent</td></tr><tr>
<td>:first-of-type</td><td>p:first-of-type</td><td>Selects every &lt;p> element that is the first &lt;p> element of its parent</td></tr><tr>
<td>:focus<td>input:focus</td><td>Selects the &lt;input> element that has focus</td></tr><tr>
<td>:hover</td><td>a:hover</td><td>Selects links on mouse over</td></tr><tr>
<td>:in-range</td><td>input:in-range</td><td>Selects &lt;input> elements with a value within a specified range</td></tr><tr>
<td>:invalid</td><td>input:invalid</td><td>Selects all &lt;input> elements with an invalid value</td></tr><tr>
<td>:lang(language)</td><td>p:lang(it)</td><td>	Selects every &lt;p> element with a lang attribute value starting with "it"</td></tr><tr>
<td>:last-child</td><td>p:last-child</td>	<td>Selects every &lt;p> elements that is the last child of its parent</td></tr><tr>
<td>:last-of-type</td><td>p:last-of-type</td><td>	Selects every &lt;p> element that is the last &lt;p> element of its parent</td></tr><tr>
<td>:link</td><td>a:link</td><td>Selects all unvisited links</td></tr><tr>
<td>:not(selector)</td><td>:not(p)</td><td>Selects every element that is not a &lt;p> element</td></tr><tr>
<td>:nth-child(n)</td><td>p:nth-child(2)</td><td>Selects every &lt;p> element that is the second child of its parent</td></tr><tr>
<td>:nth-last-child(n)</td><td>p:nth-last-child(2)</td><td>Selects every &lt;p> element that is the second child of its parent, counting from the last child</td></tr><tr>
<td>:nth-last-of-type(n)</td><td>p:nth-last-of-type(2)</td><td>Selects every &lt;p> element that is the second &lt;p> element of its parent, counting from the last child</td></tr><tr>
<td>:nth-of-type(n)</td><td>p:nth-of-type(2)</td><td>Selects every &lt;p> element that is the second &lt;p> element of its parent</td></tr><tr>
<td>:only-of-type</td><td>p:only-of-type</td><td>Selects every &lt;p> element that is the only &lt;p> element of its parent</td></tr><tr>
<td>:only-child</td><td>p:only-child</td><td>Selects every &lt;p> element that is the only child of its parent</td></tr><tr>
<td>:optional</td><td>input:optional</td><td>Selects &lt;input> elements with no "required" attribute</td></tr><tr>
<td>:out-of-range</td><td>input:out-of-range</td><td>Selects &lt;input> elements with a value outside a specified range</td></tr><tr>
<td>:read-only</td><td>input:read-only</td><td>Selects &lt;input> elements with a "readonly" attribute specified</td></tr><tr>
<td>:read-write</td><td>input:read-write</td>	<td>Selects &lt;input> elements with no "readonly" attribute</td></tr><tr>
<td>:required</td><td>input:required</td><td>Selects &lt;input> elements with a "required" attribute specified</td></tr><tr>
<td>:root</td><td>root</td><td>Selects the document's root element</td></tr><tr>
<td>:target</td><td>#news:target</td><td>Selects the current active #news element (clicked on a URL containing that anchor name)</td></tr><tr>
<td>:valid</td><td>input:valid</td><td>Selects all &lt;input> elements with a valid value</td></tr><tr>
<td>:visited</td><td>a:visited</td><td>Selects all visited links</td></tr>
</table>

<h2> Pseudo Elements List </h2>

<table>
<tr>
<td>
<strong>Selector</strong></td><td><strong>Example</strong></td><td><strong>Example description</strong></td></tr>
<td>::after</td><td>p::after</td><td>Insert content after every &lt;p> element</td></tr>
<tr><td>::before</td><td>p::before</td><td>Insert content before every &lt;p> element</td></tr>
<tr><td>::first-letter</td><td>p::first-letter</td><td>Selects the first letter of every &lt;p> element</td></tr><tr>
<td>::first-line</td><td>p::first-line</td><td>Selects the first line of every &lt;p> element</td></tr><tr>
<td>::selection</td><td>p::selection</td><td>Selects the portion of an element that is selected by a user</td>
</tr>
</table>


<h2>CSS3 Properties List</h2>
<p> - Categorized. Alphabetically ordered - </p>
<h4>Animation Properties</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>
<tr><td>animation</td><td>Specifies the keyframe-based animations.</td></tr>
<tr><td>animation-delay</td><td>Specifies when the animation will start.</td></tr>
<tr><td>animation-direction</td><td>Specifies whether the animation should play in reverse on alternate cycles or not.</td></tr>
<tr><td>animation-duration</td><td>Specifies the number of seconds or milliseconds an animation should take to complete one cycle.</td></tr>
<tr><td>animation-fill-mode</td><td>Specifies how a CSS animation should apply styles to its target before and after it is executing.</td></tr>
<tr><td>animation-iteration-count</td><td>Specifies the number of times an animation cycle should be played before stopping.</td></tr>
<tr><td>animation-name</td><td>Specifies the name of @keyframes defined animations that should be applied to the selected element.</td></tr>
<tr><td>animation-play-state</td><td>Specifies whether the animation is running or paused.</td></tr>
<tr><td>animation-timing-function</td><td>Specifies how a CSS animation should progress over the duration of each cycle.</td></tr>
</table>

<h4>Background Properties</h4>
<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>
<tr><td>background</td><td>Defines a variety of background properties within one declaration.</td></tr>
<tr><td>background-attachment</td><td>Specify whether the background image is fixed in the viewport or scrolls.</td></tr>
<tr><td>background-blend-mode</td><td>Specifies the blending mode of each background layer (color/image)</td></tr>
<tr><td>background-clip</td><td>Specifies the painting area of the background.</td></tr>
<tr><td>background-color</td><td>Defines an element's background color.</td></tr>
<tr><td>background-image</td><td>Defines an element's background image.</td></tr>
<tr><td>background-origin</td><td>Specifies the positioning area of the background images.</td></tr>
<tr><td>background-position</td><td>Defines the origin of a background image.</td></tr>
<tr><td>background-repeat</td><td>Specify whether/how the background image is tiled.</td></tr>
<tr><td>background-size</td><td>Specifies the size of the background images.</td></tr>
</table>


<h4>Border Properties</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>
<tr><td>border</td><td>Sets the width, style, and color for all four sides of an element's border.</td></tr>
<tr><td>border-bottom</td><td>Sets the width, style, and color of the bottom border of an element.</td></tr>
<tr><td>border-bottom-color</td><td>Sets the color of the bottom border of an element.</td></tr>
<tr><td>border-bottom-left-radius</td><td>Defines the shape of the bottom-left border corner of an element.</td></tr>
<tr><td>border-bottom-right-radius</td><td>Defines the shape of the bottom-right border corner of an element.</td></tr>
<tr><td>border-bottom-style</td><td>Sets the style of the bottom border of an element.</td></tr>
<tr><td>border-bottom-width</td><td>Sets the width of the bottom border of an element.</td></tr>
<tr><td>border-color</td><td>Sets the color of the border on all the four sides of an element.</td></tr>
<tr><td>border-image</td><td>Specifies how an image is to be used in place of the border styles.</td></tr>
<tr><td>border-image-outset</td><td>Specifies the amount by which the border image area extends beyond the border box.</td></tr>
<tr><td>border-image-repeat</td><td>Specifies whether the image-border should be repeated, rounded or stretched.</td></tr>
<tr><td>border-image-slice</td><td>Specifies the inward offsets of the image-border.</td></tr>
<tr><td>border-image-source</td><td>Specifies the location of the image to be used as a border.</td></tr>
<tr><td>border-image-width</td><td>Specifies the width of the image-border.</td></tr>
<tr><td>border-left</td><td>Sets the width, style, and color of the left border of an element.</td></tr>
<tr><td>border-left-color</td><td>Sets the color of the left border of an element.</td></tr>
<tr><td>border-left-style</td><td>Sets the style of the left border of an element.</td></tr>
<tr><td>border-left-width</td><td>Sets the width of the left border of an element.</td></tr>
<tr><td>border-radius</td><td>Defines the shape of the border corners of an element.</td></tr>
<tr><td>border-right</td><td>Sets the width, style, and color of the right border of an element.</td></tr>
<tr><td>border-right-color</td><td>Sets the color of the right border of an element.</td></tr>
<tr><td>border-right-style</td><td>Sets the style of the right border of an element.</td></tr>
<tr><td>border-right-width</td><td>Sets the width of the right border of an element.</td></tr>
<tr><td>border-style</td><td>Sets the style of the border on all the four sides of an element.</td></tr>
<tr><td>border-top</td><td>Sets the width, style, and color of the top border of an element.</td></tr>
<tr><td>border-top-color</td><td>Sets the color of the top border of an element.</td></tr>
<tr><td>border-top-left-radius</td><td>Defines the shape of the top-left border corner of an element.</td></tr>
<tr><td>border-top-right-radius</td><td>Defines the shape of the top-right border corner of an element.</td></tr>
<tr><td>border-top-style</td><td>Sets the style of the top border of an element.</td></tr>
<tr><td>border-top-width</td><td>Sets the width of the top border of an element.</td></tr>
<tr><td>border-width</td><td>Sets the width of the border on all the four sides of an element.</td></tr>
<tr><td>box-decoration-break</td><td>Sets the behavior of the background and border of an element at page-break, or, for in-line elements, at line-break.</td></tr>
</table>


<h4>Color properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>
<tr><td>color</td><td>Specify the color of the text of an element; different formats available.</td></tr>
<tr><td>opacity</td><td>Specifies the transparency of an element.</td></tr>
</table>


<h4>Dimension properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>
<tr><td>height</td><td>Specify the height of an element.
<tr><td>max-height</td><td>Specify the maximum height of an element.</td></tr>
<tr><td>max-width</td><td>Specify the maximum width of an element.</td></tr>
<tr><td>min-height</td><td>Specify the minimum height of an element.</td></tr>
<tr><td>min-width</td><td>Specify the minimum width of an element.</td></tr>
<tr><td>width</td><td>Specify the width of an element.</td></tr>
</table>


<h4>Generated Content properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>
<tr><td>content</td><td>Inserts generated content.</td></tr>
<tr><td>quotes</td><td>Specifies quotation marks for embedded quotations.</td></tr>
<tr><td>counter-reset</td><td>Creates or resets one or more counters.</td></tr>
<tr><td>counter-increment</td><td>Increments one or more counter values.</td></tr>
</table>


<h4>Flexible Box Layout:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>align-content</td><td>Specifies the alignment of flexible container's items within the flex container.</td></tr>
<tr><td>align-items</td><td>Specifies the default alignment for items within the flex container.</td></tr>
<tr><td>align-self</td><td>Specifies the alignment for selected items within the flex container.</td></tr>
<tr><td>flex</td><td>Specifies the components of a flexible length.</td></tr>
<tr><td>flex-basis</td><td>Specifies the initial main size of the flex item.</td></tr>
<tr><td>flex-direction</td><td>Specifies the direction of the flexible items.</td></tr>
<tr><td>flex-flow</td><td>A shorthand property for the flex-direction and the flex-wrap properties.</td></tr>
<tr><td>flex-grow</td><td>Specifies how the flex item will grow relative to the other items inside the flex container.</td></tr>
<tr><td>flex-shrink</td><td>Specifies how the flex item will shrink relative to the other items inside the flex container.</td></tr>
<tr><td>flex-wrap</td><td>Specifies whether the flexible items should wrap or not.</td></tr>
<tr><td>justify-content</td><td>Specifies how flex items are aligned along the main axis of the flex container after any flexible lengths and auto margins have been resolved.</td></tr>
<tr><td>order</td><td>Specifies the order in which a flex items are displayed and laid out within a flex container.</td></tr>
</table>

<h4>Font Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>font</td><td>Defines a variety of font properties within one declaration.</td></tr>
<tr><td>font-family</td><td>Defines a list of fonts for element.</td></tr>
<tr><td>font-feature-settings</td><td>Allows control over advanced typographic features in OpenType fonts</td></tr>
<tr><td>font-kerning</td><td>Controls the usage of the kerning information (how letters are spaced)</td></tr>
<tr><td>font-language-override</td><td>Controls the usage of language-specific glyphs in a typeface
</td></tr>
<tr><td>font-size</td><td>Defines the font size for the text.</td></tr>
<tr><td>font-size-adjust</td><td>Preserves the readability of text when font fallback occurs.</td></tr>
<tr><td>font-stretch</td><td>Selects a normal, condensed, or expanded face from a font.</td></tr>
<tr><td>font-style</td><td>Defines the font style for the text.</td></tr>
<tr><td>font-synthesis</td><td>Controls which missing typefaces (bold or italic) may be synthesized by the browser.</td></tr>
<tr><td>font-variant</td><td>Specify the font variant.</td></tr>
<tr><td>font-variant-alternates</td><td>	Controls the usage of alternate glyphs associated to alternative names defined in @font-feature-values.</td></tr>
<tr><td>font-variant-caps</td><td>Controls the usage of alternate glyphs for capital letters
</td></tr>
<tr><td>font-variant-east-asian</td><td>Controls the usage of alternate glyphs for East Asian scripts (e.g Japanese and Chinese).</td></tr>
<tr><td>font-variant-ligatures</td><td>Controls which ligatures and contextual forms are used in textual content of the elements it applies to.</td></tr>
<tr><td>font-variant-numeric</td><td>Controls the usage of alternate glyphs for numbers, fractions, and ordinal markers.</td></tr>
<tr><td>font-variant-position</td><td>Controls the usage of alternate glyphs of smaller size positioned as superscript or subscript regarding the baseline of the font.</td></tr>
<tr><td>font-weight</td><td>Specify the font weight of the text.</td></tr>
</table>

<h4>Grid Layout Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>grid</td><td>A shorthand property for the grid-template-rows, grid-template-columns, grid-template-areas, grid-auto-rows, grid-auto-columns, and the grid-auto-flow properties.</td></tr>
<tr><td>grid-area</td><td>Either specifies a name for the grid item, or this property is a shorthand property for the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties.</td></tr>
<tr><td>grid-auto-columns</td><td>Specifies a default column size</td></tr>
<tr><td>grid-auto-flow</td><td>Specifies how auto-placed items are inserted in the grid.</td></tr>
<tr><td>grid-auto-rows</td><td>Specifies a default row size.</td></tr>
<tr><td>grid-column</td><td>A shorthand property for the grid-column-start and the grid-column-end properties.</td></tr>
<tr><td>grid-column-end</td><td>Specifies where to end the grid item.</td></tr>
<tr><td>grid-column-gap</td><td>Specifies the size of the gap between columns.</td></tr>
<tr><td>grid-column-start</td><td>Specifies where to start the grid item.</td></tr>
<tr><td>grid-gap</td><td>A shorthand property for the grid-row-gap and grid-column-gap properties.</td></tr>
<tr><td>grid-row</td><td>A shorthand property for the grid-row-start and the grid-row-end properties.</td></tr>
<tr><td>grid-row-end</td><td>Specifies where to end the grid item.</td></tr>
<tr><td>grid-row-gap</td><td>Specifies the size of the gap between rows.</td></tr>
<tr><td>grid-row-start</td><td>Specifies where to start the grid item.</td></tr>
<tr><td>grid-template</td><td>A shorthand property for the grid-template-rows, grid-template-columns and grid-areas properties.</td></tr>
<tr><td>grid-template-areas</td><td>Specifies how to display columns and rows, using named grid items.</td></tr>
<tr><td>grid-template-columns</td><td>Specifies the size of the columns, and how many columns in a grid layout.</td></tr>
<tr><td>grid-template-rows</td><td>Specifies the size of the rows in a grid layout.</td></tr>


</table>



<h4>List Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>list-style</td><td>Defines the display style for a list and list elements.</td></tr>
<tr><td>list-style-image</td><td>Specifies the image to be used as a list-item marker.</td></tr>
<tr><td>list-style-position</td><td>Specifies the position of the list-item marker.</td></tr>
<tr><td>list-style-type</td><td>Specifies the marker style for a list-item.</td></tr>
</table>


<h4>Margin Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>margin</td><td>Sets the margin on all four sides of the element.</td></tr>
<tr><td>margin-bottom</td><td>Sets the bottom margin of the element.</td></tr>
<tr><td>margin-left</td><td>Sets the left margin of the element.</td></tr>
<tr><td>margin-right</td><td>Sets the right margin of the element.</td></tr>
<tr><td>margin-top</td><td>Sets the top margin of the element.</td></tr>
</table>


<h4>Multi-column Layout Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>column-count</td><td>Specifies the number of columns in a multi-column element.
<tr><td>column-fill</td><td>Specifies how columns will be filled.</td></tr>
<tr><td>column-gap</td><td>Specifies the gap between the columns in a multi-column element.</td></tr>
<tr><td>column-rule</td><td>Specifies a straight line, or "rule", to be drawn between each column in a multi-column element.</td></tr>
<tr><td>column-rule-color</td><td>Specifies the color of the rules drawn between columns in a multi-column layout.</td></tr>
<tr><td>column-rule-style</td><td>Specifies the style of the rule drawn between the columns in a multi-column layout.</td></tr>
<tr><td>column-rule-width</td><td>Specifies the width of the rule drawn between the columns in a multi-column layout.</td></tr>
<tr><td>column-span</td><td>Specifies how many columns an element spans across in a multi-column layout.</td></tr>
<tr><td>column-width</td><td>Specifies the optimal width of the columns in a multi-column element.</td></tr>
<tr><td>columns</td><td>A shorthand property for setting column-width and column-count properties.</td></tr>
</table>


<h4>Outline Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>outline</td><td>Sets the width, style, and color for all four sides of an element's outline.</td></tr>
<tr><td>outline-color</td><td>Sets the color of the outline.</td></tr>
<tr><td>outline-offset</td><td>Set the space between an outline and the border edge of an element.</td></tr>
<tr><td>outline-style</td><td>Sets a style for an outline.</td></tr>
<tr><td>outline-width</td><td>Sets the width of the outline.</td></tr>
</table>

<h4>Padding Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>padding</td><td>Sets the padding on all four sides of the element.</td></tr>
<tr><td>padding-bottom</td><td>Sets the padding to the bottom side of an element.</td></tr>
<tr><td>padding-left</td><td>Sets the padding to the left side of an element.</td></tr>
<tr><td>padding-right</td><td>Sets the padding to the right side of an element.</td></tr>
<tr><td>padding-top</td><td>Sets the padding to the top side of an element.</td></tr>
</table>

<h4>Print Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>page-break-after</td><td>Insert a page breaks after an element.</td></tr>
<tr><td>page-break-before</td><td>Insert a page breaks before an element.</td></tr>
<tr><td>page-break-inside</td><td>Insert a page breaks inside an element.</td></tr>
</table>


<h4>Table Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>border-collapse</td><td>Specifies whether table cell borders are connected or separated.</td></tr>
<tr><td>border-spacing</td><td>Sets the spacing between the borders of adjacent table cells.</td></tr>
<tr><td>caption-side</td><td>Specify the position of table's caption.</td></tr>
<tr><td>empty-cells</td><td>Show or hide borders and backgrounds of empty table cells.</td></tr>
<tr><td>table-layout</td><td>Specifies a table layout algorithm.</td></tr>
</table>


<h4>Text Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>direction</td><td>Define the text direction/writing direction.</td></tr>
<tr><td>tab-size</td><td>Specifies the length of the tab character.</td></tr>
<tr><td>text-align</td><td>Sets the horizontal alignment of inline content.</td></tr>
<tr><td>text-align-last</td><td>Specifies how the last line of a block or a line right before a forced line break is aligned when text-align is justify.</td></tr>
<tr><td>text-decoration</td><td>Specifies the decoration added to text.</td></tr>
<tr><td>text-decoration-color</td><td>Specifies the color of the text-decoration-line.</td></tr>
<tr><td>text-decoration-line</td><td>Specifies what kind of line decorations are added to the element.</td></tr>
<tr><td>text-decoration-style</td><td>Specifies the style of the lines specified by the text-decoration-line property.</td></tr>
<tr><td>text-indent</td><td>Indent the first line of text.</td></tr>
<tr><td>text-justify</td><td>Specifies the justification method to use when the text-align property is set to justify.</td></tr>
<tr><td>text-overflow</td><td>Specifies how the text content will be displayed, when it overflows the block containers.</td></tr>
<tr><td>text-shadow</td><td>Applies one or more shadows to the text content of an element.</td></tr>
<tr><td>text-transform</td><td>Transforms the case of the text.</td></tr>
<tr><td>line-height</td><td>Sets the height between lines of text.</td></tr>
<tr><td>vertical-align</td><td>Sets the vertical positioning of an element relative to the current text baseline.</td></tr>
<tr><td>letter-spacing</td><td>Sets the extra spacing between letters.</td></tr>
<tr><td>word-spacing</td><td>Sets the spacing between words.</td></tr>
<tr><td>white-space</td><td>Specifies how white space inside the element is handled.</td></tr>
<tr><td>word-break</td><td>Specifies how to break lines within words.</td></tr>
<tr><td>word-wrap</td><td>Specifies whether to break words when the content overflows the boundaries of its container.</td></tr>
</table>



<h4>Transform Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>backface-visibility</td><td>Specifies whether or not the "back" side of a transformed element is visible when facing the user.</td></tr>
<tr><td>perspective</td><td>Defines the perspective from which all child elements of the object are viewed.</td></tr>
<tr><td>perspective-origin</td><td>Defines the origin (the vanishing point for the 3D space) for the perspective property.</td></tr>
<tr><td>transform</td><td>Applies a 2D or 3D transformation to an element.</td></tr>
<tr><td>transform-origin</td><td>Defines the origin of transformation for an element.</td></tr>
<tr><td>transform-style</td><td>Specifies how nested elements are rendered in 3D space.</td></tr>
</table>


<h4>Transtition Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>transition</td><td>Defines the transition between two states of an element.</td></tr>
<tr><td>transition-delay</td><td>Specifies when the transition effect will start.</td></tr>
<tr><td>transition-duration</td><td>Specifies the number of seconds or milliseconds a transition effect should take to complete.</td></tr>
<tr><td>transition-property</td><td>Specifies the names of the CSS properties to which a transition effect should be applied.</td></tr>
<tr><td>transition-timing-function</td><td>Specifies the speed curve of the transition effect.</td></tr>
</table>


<h4>Visual Formatting Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>caret-color</td><td>Specifies the color of the cursor (caret) in inputs, textareas, or any element that is editable</td></tr>
<tr><td>display</td><td>Specifies how an element is displayed onscreen.</td></tr>
<tr><td>position</td><td>Specifies how an element is positioned.</td></tr>
<tr><td>filter</td><td> Specifies a filter to apply over an element or multimedia file (images, videos..)</td></tr>
<tr><td>top</td><td>Specify the location of the top edge of the positioned element.</td></tr>
<tr><td>right</td><td>Specify the location of the right edge of the positioned element.</td></tr>
<tr><td>bottom</td><td>Specify the location of the bottom edge of the positioned element.</td></tr>
<tr><td>left</td><td>Specify the location of the left edge of the positioned element.</td></tr>
<tr><td>float</td><td>Specifies whether or not a box should float.</td></tr>
<tr><td>clear</td><td>Specifies the placement of an element in relation to floating elements.</td></tr>
<tr><td>z-index</td><td>Specifies a layering or stacking order for positioned elements.</td></tr>
<tr><td>overflow</td><td>Specifies the treatment of content that overflows the element's box.</td></tr>
<tr><td>overflow-x</td><td>Specifies how to manage the content when it overflows the width of the element's content area.</td></tr>
<tr><td>overflow-y</td><td>Specifies how to manage the content when it overflows the height of the element's content area.</td></tr>
<tr><td>overflow-wrap</td><td>	Specifies whether or not the browser may break lines within words in order to prevent overflow (when a string is too long to fit its containing box).</td></tr>
<tr><td>resize</td><td>Specifies whether or not an element is resizable by the user.</td></tr>
<tr><td>clip</td><td>Defines the clipping region.
<tr><td>visibility</td><td>Specifies whether or not an element is visible.</td></tr>
<tr><td>cursor</td><td>Specify the type of cursor.</td></tr>
<tr><td>box-shadow</td><td>Applies one or more drop-shadows to the element's box.</td></tr>
<tr><td>box-sizing</td><td>Alter the default CSS box model.</td></tr>
</table>

<h4>Other Properties:</h4>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>all</td><td>Resets all properties (except unicode-bidi and direction)</td></tr>
<tr><td>hanging-punctuation</td><td>Specifies whether a punctuation character may be placed outside the line box.</td></tr>
<tr>hyphens<td></td><td>Sets how to split words to improve the layout of paragraphs.</td></tr>
<tr><td>image-rendering</td><td>Gives a hint to the browser about what aspects of an image are most important to preserve when the image is scaled.</td></tr>
<tr><td>isolation</td><td>Defines whether an element must create a new stacking content.</td></tr>
<tr><td>mix-blend-mode</td><td>Specifies how an element's content should blend with its direct parent background</td></tr>
<tr><td>object-fit</td><td>Specifies how the contents of a replaced element should be fitted to the box established by its used height and width.</td></tr>
<tr><td>object-position</td><td>Specifies the alignment of the replaced element inside its box.</td></tr>
<tr><td>pointer-events</td><td>Defines whether or not an element reacts to pointer events.</td></tr>
<tr><td>
scroll-behavior</td><td>Specifies whether to smoothly animate the scroll position in a scrollable box, instead of a straight jump.</td></tr>
<tr><td>unicode-bidi</td><td>Used together with the direction property to set or return whether the text should be overridden to support multiple languages in the same document
</td></tr>
<tr><td>writing-mode</td><td>Specifies whether lines of text are laid out horizontally or vertically.</td></tr>
</table>



<h3>CSS3 At-Rules:</h3>

<table>
<tr><td><strong>Property</strong></td><td><strong>Description</strong></td></tr>

<tr><td>@charset</td><td>specifies the character encoding of an external style sheet.</td></tr>
<tr><td>@font-face</td><td>Enables the use of downloadable web fonts.</td></tr>
<tr><td>@import</td><td>Imports an external style sheet.</td></tr>
<tr><td>@keyframes</td><td>Specifies the values for the animating properties at various points during the animation.</td></tr>
<tr><td>@media</td><td>Sets the media types for a set of rules in a style sheet.</td></tr>
<tr><td>@page</td><td>Defines the dimensions, orientation, and margins of a page box for printing environments.</td></tr>
</table>


<small><a href="https://www.tutorialrepublic.com/css-reference/css3-properties.php" target="_blank"> source </a></small>


<h2>Comments on CSS:</h2>

<p> In HTML you can comment texts using &lt;!-- <em>comment </em> --></p>
<p> In CSS or SCSS you can comment using slash + asterisk (and asterisk + slash for closure) for multi-line comments like:

<pre>
/* 
<em>multi <br>
line<br>
comment</em>
*/
</pre>

If you are using Sass / SCSS you can also add comments using double slash // for single line comments, see example below
<pre>
// <em>single line comment</em>
#main-content.container { background: green; }
#main-content { background: red; }
// .container { background: blue; }
</pre>


<h2> Vendor prefix / Property Prefixing: </h2>
<p>So from the perspective of a front-end web developer, browser prefixes are used to add new CSS features onto a site while having comfort knowing that the browsers will support those styles. This can be especially helpful when different browser manufacturers implement properties in slightly different ways or with a different syntax.</p>

<p>The CSS browser prefixes that you can use (each of which is specific to a different browser) are:</p>

<table>
<tr>
<td>
Android, Chrome, iOS (including firefox for iOS), Safari, Opera (new versions); Any webkit-based browser.
</td>
<td>
-webkit-
</td></tr>
<tr><td>Mozilla Firefox</td><td>-moz-</td></tr>
<tr><td>Internet Explorer, Edge</td><td>-ms-</td></tr>
<tr><td>Opera (old pre-webkit versions)</td><td>-o-</td></tr>
</table>
<p>
In most cases, to use a brand new CSS style property, you take the standard CSS property and add the prefix for each browser. The prefixed versions would always come first (in any order you prefer) while the normal CSS property will come last. For example, if you want to add a CSS3 transition to your document, you would use the transition property as shown below:
</p>
<p>
-webkit-transition: all 4s ease;
</p><p>
-moz-transition: all 4s ease;
</p><p>
-ms-transition: all 4s ease;
</p><p>
-o-transition: all 4s ease;
</p><p>
transition: all 4s ease; 
</p>

<p>
Remember, some browsers have a different syntax for certain properties than others do, so don’t assume that the browser-prefixed version of a property is exactly the same as the standard property. For example, to create a CSS gradient, you use the linear-gradient property. Firefox, Opera, and modern versions of Chrome and Safari use that property with the appropriate prefix while early versions of Chrome and Safari use the prefixed property -webkit-gradient.
</p>
<p>
Also, Firefox uses different values than the standard ones.
</p>
<p>
The reason that you always end your declaration with the normal, non-prefixed version of the CSS property is so that when a browser does support the rule, it will use that one. Remember how CSS is read. The later rules take precedence over earlier ones if the specificity is the same, so a browser would read the vendor version of a rule and use that if it does not support the normal one, but once it does, it will override the vendor version with the actual CSS rule.</p>
</p>

<h2>CSS Properties Synergy:</h2>
<p>It's near impossible for me to create a full doc about all css synergies, but I am obliged to notify you about this. For many reasons:</p>
<ul>
<li>Possible unexpected behavior</li>
<li>Ways to reach things not defined by single properties or not working inside some layout.</li>
</ul>

<p>For example, you can set this properties into a div HTML element: <code>max-width: 600px; margin: 0 auto;</code> and it will be centered on the screen, occupying 600px as maximum.</p>
<p>We didn't set align-self: center, nor justif-content or other centering property or value, but setting the x-axis margin to auto jointly with max-width property (when the window is bigger than 600px, obviously) will make the div show centered respectively to the screen.</p>

<p>Of course you can reach the same setting a parent div with <code>display: flex; justify-content: center; </code> and then a child div with <code>max-width: 600px;</code></p>

{% codepen https://codepen.io/joelbonetr/pen/YzwQrrq %}

<p>There's a logic between the apparent chaos you may found after reading this last paragraph, simply think on what properties do:</p>

<ul>
<li>max-width: 600px; Limits the width of an element to 600px.</li>
<li>By default all items are positioned "top: 0; left: 0;" so it will start from left: 0; to left: 600;</li>
<li>Margin specifies the distance between objects, setting margin: 0 auto; means that we want no margin on Y-axis but we want X-axis margin for being auto, that means, read the available free space, divide it by 2 and set each half on each side of the element. Of course, this causes the item centering.</li>
</ul>

<p>So don't worry about synergies, when you find one simply try to understand why it's working that way and you'll learn fast.</p>

<h2>Advice:</h2>

<p>There are tones of properties I'm adding step by step. Some of them are not standard or not allowed by all browsers. Sometimes you'll find a workaround such prefixing the property or using javascript to reach the DOM property (if any).</p>
<p>I highly recommend you to search the properties you are going to use on <a href="https://caniuse.com/" target="_blank">can I use </a>. If you don't find what you want here then search for the property on <a href="https://developer.mozilla.org/en-US/docs/Web/CSS" target="_blank">mdn</a>.</p>
<p>If you are going to build something that works on chrome it's OK because it usually can use almost all properties, but if you need compatibility or retro-compatibility with old browsers, you'll need to search this property compatibility more accurately.</p>




<h2>Examples:</h2>

<p>I'm posting some posts about building interactive components using CSS that you may find useful, you can take a look at the posts here:</p>
<hr>
<ol>
<li><a href="https://dev.to/joelbonetr/build-your-own-css-only-components-part-i-4b83" target="_blank">Building CSS Only interactive components from scratch PART 1</a></li>
<li><a href="https://dev.to/joelbonetr/building-css-interactive-components-from-scratch-part-ii-4c22" target="_blank">Building CSS Only interactive components from scratch PART 2</a></li>
<li><a href="https://dev.to/joelbonetr/building-css-only-interactive-components-from-scratch-part-iii-tabs-4d13" target="_blank">Building CSS Only interactive components from scratch PART 3</a></li>
</ol>
<hr>


I'll add more content here to increase the informative content wrapped on a single post, like units, color formats and so on.

Hope you find all that useful and if you have any question please leave a comment and share :)


<hr>

<h2>EDIT / Changelog</h2>

<ul>
  <li>Added more than 40 properties, each with its description.</li>
  <li>Added Grid Layout Properties block. </li>
  <li>Added Other Properties block. </li>
  <li>Added prefixing documentation.</li>
  <li>Added advice, specially for newbies.</li>
  <li>Added external sources.</li>
  <li>Added css properties synergy explanation. </li>
  <li>Corrections about comments</li>
</ul>


<hr>


Best regards