<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matt Lawrence ☕</title>
    <description>The latest articles on DEV Community by Matt Lawrence ☕ (@mattlawrence).</description>
    <link>https://dev.to/mattlawrence</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F351578%2F7eb6fe5d-52db-4305-b973-2cc9e0ad6f20.jpg</url>
      <title>DEV Community: Matt Lawrence ☕</title>
      <link>https://dev.to/mattlawrence</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mattlawrence"/>
    <language>en</language>
    <item>
      <title>What are var, let, and const in JavaScript?</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Tue, 15 Jul 2025 18:27:09 +0000</pubDate>
      <link>https://dev.to/mattlawrence/what-are-var-let-and-const-in-javascript-36cb</link>
      <guid>https://dev.to/mattlawrence/what-are-var-let-and-const-in-javascript-36cb</guid>
      <description>&lt;p&gt;In JavaScript, &lt;code&gt;var&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt;, and &lt;code&gt;const&lt;/code&gt;are used to declare variables—but they differ in how they behave when it comes to scope, hoisting, and mutability. Choosing the right one helps prevent bugs and makes your code easier to reason about.&lt;/p&gt;

&lt;p&gt;In modern development, &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are preferred. &lt;code&gt;var&lt;/code&gt; is mostly reserved for legacy code or situations requiring function-scoped variables. Many developers search “what is let var const” — this guide breaks it all down so you can write cleaner, safer JavaScript.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔄 What's the difference between var, let, and const?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;&lt;code&gt;var&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;let&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;const&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scope&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Function scope&lt;/td&gt;
&lt;td&gt;Block scope&lt;/td&gt;
&lt;td&gt;Block scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hoisting&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes (initialized as &lt;code&gt;undefined&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;✅ Yes (not initialized)&lt;/td&gt;
&lt;td&gt;✅ Yes (not initialized)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reassignable&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Redeclarable&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Understanding scope in JavaScript
&lt;/h2&gt;

&lt;p&gt;Variable scope determines where a variable is accessible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; is function-scoped — accessible throughout the entire function.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are block-scoped — accessible only within the &lt;code&gt;{ }&lt;/code&gt; block they are defined in.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;    
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ✅ Outputs 1  &lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ ReferenceError&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What do hoisting, reassignable, and redeclarable mean?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Hoisting
&lt;/h3&gt;

&lt;p&gt;JavaScript moves variable declarations to the top of their scope.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With &lt;code&gt;var&lt;/code&gt; the variable is hoisted and initialized as undefined.&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; the declaration is hoisted but not initialized, so using them before their declaration results in a &lt;code&gt;ReferenceError&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reassignable
&lt;/h3&gt;

&lt;p&gt;Can you assign a new value to the variable after declaring it?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;var&lt;/code&gt; allow reassignment.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;const&lt;/code&gt; does not.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Redeclarable
&lt;/h3&gt;

&lt;p&gt;Can you declare the same variable name again in the same scope?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; allows it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; do not — which helps prevent accidental bugs.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to choose between var, let, and const
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;✅ Use &lt;code&gt;const&lt;/code&gt; by default.&lt;/li&gt;
&lt;li&gt;Prevents accidental reassignment and communicates intent clearly.&lt;/li&gt;
&lt;li&gt;🔁 Use &lt;code&gt;let&lt;/code&gt; when the variable will change.&lt;/li&gt;
&lt;li&gt;Useful in loops, state changes, toggles, and accumulations.&lt;/li&gt;
&lt;li&gt;🚫 Avoid &lt;code&gt;var&lt;/code&gt; unless maintaining legacy code&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; still works, but its function scope and redeclaration behavior make it error-prone in modern codebases.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  When to use var, let and const
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✅ Use const when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The variable should never be reassigned.&lt;/li&gt;
&lt;li&gt;You want stable, predictable references.&lt;/li&gt;
&lt;li&gt;You're working with arrays or objects that can be mutated but shouldn’t be reassigned entirely.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;debug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ✅ &lt;/span&gt;
&lt;span class="nx"&gt;allowedconfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error: Assignment to constant variable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🔁 Use let when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You need to reassign the variable later.&lt;/li&gt;
&lt;li&gt;You're using a variable inside a block (&lt;code&gt;for&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt;, etc.).&lt;/li&gt;
&lt;li&gt;You want to avoid accidental redeclaration.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🕰 Use var when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You're working in legacy ES5 codebases.&lt;/li&gt;
&lt;li&gt;You need function-level scope instead of block scope.&lt;/li&gt;
&lt;li&gt;You’re supporting very old browsers.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;legacyCode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
    &lt;span class="p"&gt;}&lt;/span&gt;  
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ✅ 42 (still accessible)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is it better to use let or const?
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;const&lt;/code&gt; whenever possible. It helps prevent bugs by signaling that the variable won’t change. Use &lt;code&gt;let&lt;/code&gt; when reassignment is necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is var discouraged in modern JavaScript?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;var&lt;/code&gt; is function-scoped and allows redeclaration, which can lead to confusing bugs. &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; offer safer scoping and behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is let faster than var?
&lt;/h3&gt;

&lt;p&gt;Not really. Performance is nearly identical in most cases. The real benefit is developer clarity and fewer bugs, not execution speed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can you reassign a const variable?
&lt;/h3&gt;

&lt;p&gt;No — but you can change the contents of arrays or objects declared with &lt;code&gt;const&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ✅ Works&lt;/span&gt;
&lt;span class="nx"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;yellow&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;  &lt;span class="c1"&gt;// ❌ Error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What happens if you use var inside a function?
&lt;/h3&gt;

&lt;p&gt;It’s hoisted and scoped to the entire function, initialized as &lt;code&gt;undefined&lt;/code&gt; no matter where you declare it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does let have block scope?
&lt;/h3&gt;

&lt;p&gt;Yes. &lt;code&gt;let&lt;/code&gt; only exists within the &lt;code&gt;{}&lt;/code&gt; block where it's declared.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can you redeclare variables with let or const?
&lt;/h3&gt;

&lt;p&gt;No — attempting to redeclare in the same scope throws a &lt;code&gt;SyntaxError&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Want to learn more JavaScript?
&lt;/h2&gt;

&lt;p&gt;Learn to code using Scrimba with their interactive follow-along code editor.&lt;/p&gt;

&lt;p&gt;Join their exclusive discord communities and network to find your first job!&lt;/p&gt;

&lt;p&gt;Use our &lt;a href="https://scrimba.com/?via=htmlallthethings" rel="noopener noreferrer"&gt;affiliate link&lt;/a&gt; for a 20% discount!!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click the link to take you to the Scrimba site&lt;/li&gt;
&lt;li&gt;A pop-up should appear on your screen with the discount amount and instructions on how to claim it&lt;/li&gt;
&lt;li&gt;Discount is for new accounts only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;We receive a monetary kickback if you use our affiliate link and make a purchase.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This and many other guides are available on &lt;a href="https://www.htmlallthethings.com" rel="noopener noreferrer"&gt;htmlallthethings.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>CSS Pseudo Class Explained: What It Is and How to Use It</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Fri, 20 Jun 2025 19:56:09 +0000</pubDate>
      <link>https://dev.to/mattlawrence/css-pseudo-class-explained-what-it-is-and-how-to-use-it-3db1</link>
      <guid>https://dev.to/mattlawrence/css-pseudo-class-explained-what-it-is-and-how-to-use-it-3db1</guid>
      <description>&lt;h2&gt;
  
  
  What are CSS pseudo-classes?
&lt;/h2&gt;

&lt;p&gt;CSS pseudo-classes are special keywords that let you apply styles to elements based on their state or position in the document—without needing to add extra classes or IDs in your HTML.&lt;/p&gt;

&lt;p&gt;For example, when a user hovers their mouse over a button, you might want it to change color. Instead of using JavaScript to detect that interaction, CSS pseudo-classes let you do it with just a few lines of CSS.&lt;/p&gt;

&lt;p&gt;These selectors start with a single colon (&lt;code&gt;:&lt;/code&gt;) and target elements dynamically based on conditions like user interaction, form validation, or document structure. They can be combined with additional pseudo-classes or other selectors to give you granular control over which element(s) you want to select.&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS pseudo-class example
&lt;/h3&gt;

&lt;p&gt;In this example, the &lt;code&gt;:hover&lt;/code&gt; pseudo-class applies a new background and text color when the user hovers over a button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#007bff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Common CSS pseudo-classes
&lt;/h2&gt;

&lt;p&gt;There are dozens of pseudo-classes available in CSS, but you won’t need to memorize them all to create most websites. Here are a few of the most common pseudo-classes, from our experience:&lt;/p&gt;

&lt;h3&gt;
  
  
  Hover
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;:hover&lt;/code&gt; pseudo-class targets an element when a user hovers their pointer over it. This is great for enhancing interactivity, especially on links and buttons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;underline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Required
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;:required&lt;/code&gt; pseudo-class selects input fields that have the &lt;code&gt;required&lt;/code&gt; attribute. You can use it to visually indicate that a field must be filled out before submitting a form.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:required&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Empty
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;:empty&lt;/code&gt; pseudo-class targets elements that have no children—no text nodes, no elements, nothing. This can be useful for debugging or conditionally styling placeholder containers. I personally use this when filling in a new website’s content for the first time to ensure I don’t miss anything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:empty&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f8d7da&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  nth-child()
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;:nth-child()&lt;/code&gt; pseudo-class targets elements based on their order in the DOM. It accepts values like numbers (&lt;code&gt;:nth-child(3)&lt;/code&gt;), keywords like &lt;code&gt;odd&lt;/code&gt; or &lt;code&gt;even&lt;/code&gt;, or formulas like &lt;code&gt;2n+1&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;odd&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f2f2f2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Visited
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;:visited&lt;/code&gt; pseudo-class applies styles to links that the user has already clicked. Most modern browsers limit what styles can be changed here for privacy reasons (ie color, background-color, border-color, etc.). Furthermore, this pseudo-class can only be applied to &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;area&amp;gt;&lt;/code&gt; elements that have an &lt;code&gt;href&lt;/code&gt; attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:visited&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;purple&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the difference between a pseudo-element and a pseudo-class?
&lt;/h3&gt;

&lt;p&gt;A pseudo-class is defined by a single colon (&lt;code&gt;:&lt;/code&gt;) and is used to target and style elements in a specific state (ie when a mouse is hovering over top). Meanwhile a pseudo-element is defined by a double colon (&lt;code&gt;::&lt;/code&gt;) and lets you target and style specific parts of a selected element, such as the first line of a paragraph. In some cases pseudo-elements can be used to generate content using the &lt;code&gt;content&lt;/code&gt; CSS property.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Pseudo-Class: Makes links with the class 'featured-link' red when hovered over */&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nc"&gt;.featured-link&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Pseudo-Element: Bolds the text in the first line of paragraphs */&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;::first-line&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is &lt;code&gt;:&lt;/code&gt; in CSS?
&lt;/h3&gt;

&lt;p&gt;The single colon (&lt;code&gt;:&lt;/code&gt;) is used to define pseudo-classes, like &lt;code&gt;:hover&lt;/code&gt;, &lt;code&gt;:focus&lt;/code&gt;, or &lt;code&gt;:first-child&lt;/code&gt;. It tells the browser to apply styles when a specific condition is met for an element.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is &lt;code&gt;::&lt;/code&gt; in CSS?
&lt;/h3&gt;

&lt;p&gt;The double colon (&lt;code&gt;::&lt;/code&gt;) is used for pseudo-elements, which let you style specific parts of an element or inject content (like &lt;code&gt;::before&lt;/code&gt;, &lt;code&gt;::after&lt;/code&gt;, or &lt;code&gt;::first-letter&lt;/code&gt;). &lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use multiple pseudo-classes on the same element?
&lt;/h3&gt;

&lt;p&gt;Yes! You can chain pseudo-classes together for more complex selection logic without the use of JavaScript.&lt;/p&gt;

&lt;p&gt;For example, The selector below targets a button that is both hovered and focused.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover:focus&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;orange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Do all browsers support CSS pseudo-classes?
&lt;/h3&gt;

&lt;p&gt;Most modern browsers support the majority of pseudo-classes. However, some newer or more complex pseudo-classes like &lt;code&gt;:is()&lt;/code&gt; or &lt;code&gt;:has()&lt;/code&gt;—may have limited support in older versions. Always check Can I Use (&lt;a href="https://caniuse.com/" rel="noopener noreferrer"&gt;https://caniuse.com/&lt;/a&gt;) if you're unsure about compatibility. &lt;/p&gt;

&lt;p&gt;And remember that there are a lot of ways to workaround browser limitations in CSS, meaning you can typically use an “advanced” feature for people using compatible browsers, then fall back on an alternative for those on incompatible browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Want to learn more CSS?
&lt;/h2&gt;

&lt;p&gt;Learn to code using Scrimba with their interactive follow-along code editor.&lt;/p&gt;

&lt;p&gt;Join their exclusive discord communities and network to find your first job!&lt;/p&gt;

&lt;p&gt;Use our &lt;a href="https://scrimba.com/?via=htmlallthethings" rel="noopener noreferrer"&gt;affiliate link&lt;/a&gt; for a 20% discount!!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click the link to take you to the Scrimba site&lt;/li&gt;
&lt;li&gt;A pop-up should appear on your screen with the discount amount and instructions on how to claim it&lt;/li&gt;
&lt;li&gt;Discount is for new accounts only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;We receive a monetary kickback if you use our affiliate link and make a purchase.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;More web development guides and podcast episodes on &lt;a href="https://www.htmlallthethings.com/" rel="noopener noreferrer"&gt;htmlallthethings.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Why Feature Phones are Important in 2025</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Mon, 12 May 2025 13:00:00 +0000</pubDate>
      <link>https://dev.to/mattlawrence/why-feature-phones-are-important-in-2025-3o0l</link>
      <guid>https://dev.to/mattlawrence/why-feature-phones-are-important-in-2025-3o0l</guid>
      <description>&lt;h2&gt;
  
  
  What is a feature phone?
&lt;/h2&gt;

&lt;p&gt;Feature phones (aka “dumb phones”) are mobile devices that offer basic features like text messaging and making phone calls. They often go against the modern smartphone form factor, including a set of buttons to navigate the software and a keypad to dial phone numbers. If you were around during the early 2000s, you’ll remember devices such as the &lt;a href="https://en.wikipedia.org/wiki/Motorola_Razr_V3" rel="noopener noreferrer"&gt;Motorola Razr v3&lt;/a&gt; and the &lt;a href="https://en.wikipedia.org/wiki/LG_Chocolate" rel="noopener noreferrer"&gt;LG Chocolate&lt;/a&gt; - these are prime examples of what you can roughly expect in a modern feature phone.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is considered a feature phone?
&lt;/h3&gt;

&lt;p&gt;Feature phones are considered less capable devices than modern smartphones, they typically have a small screen, physical keypad, limited internet capabilities, and a few built-in apps. In contrast, modern smartphones have large touch screens, advanced cameras setups, high-speed data, and millions of apps.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a feature phone and a smartphone?
&lt;/h3&gt;

&lt;p&gt;Feature phones offer only basic features, while smartphones try to offer cutting edge tech. The focus of a feature phone is communication (calling and texting), while a modern smartphone focuses on being an all-in-one computing device (communication, photography, games, and content creation).&lt;/p&gt;

&lt;h3&gt;
  
  
  What can you do with a feature phone?
&lt;/h3&gt;

&lt;p&gt;Feature phones are focused on communication - namely talk and text. However, like phones from the early 2000s, they also typically offer helpful built-in apps for note taking, calendar management, listening to music (local files, not streaming), and even email (although typically limited). Modern apps and functionality can be used on some feature phones using a service called &lt;a href="https://www.cloudfone.com/" rel="noopener noreferrer"&gt;Cloud Phone&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are feature phones making a comeback?
&lt;/h3&gt;

&lt;p&gt;Feature phones are making a comeback in 2025 largely due to a niche audience looking to do a digital detox. This audience is looking to ditch the constant stimulation and distraction (ie doomscrolling) that their smartphones offer, preferring to “go back to basics” when phones were primarily used for communication. &lt;/p&gt;

&lt;p&gt;In addition to this niche audience, there are several audiences around the world in countries that aren’t able to afford smartphones. These people are budget-forced to purchase and use dumbphones to keep in touch with friends and family. In this particular case, dumbphones are making less of a “comeback” and are more a “daily necessity.”&lt;/p&gt;

&lt;h2&gt;
  
  
  How much do feature phones cost?
&lt;/h2&gt;

&lt;p&gt;Feature phones are generally cheaper than the high-end smartphones of today, however, their prices range wildly due to their included features and capabilities. Roughly speaking, you can get a feature phone in 2025 for as little as $12 USD and as high as $700 USD. This wild range reflects the different demographics that feature phones serve, from people that are looking for a digital detox, to those that need a phone on a restrictive budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  Popular Feature Phones
&lt;/h2&gt;

&lt;p&gt;There are a lot of feature phones out there, the ones featured in this section are primarily focused on their recent virality in 2025. It’s important to note that the ones showcased here are just scratching the surface of what is available in terms of form factor and price.&lt;/p&gt;

&lt;h3&gt;
  
  
  Minimal Phone
&lt;/h3&gt;

&lt;p&gt;The Minimal Phone is really a hybrid device between smartphone and dumbphone. Our daily lives have largely been changed by the rise of the smartphone, making them essential in some use cases - such as Uber for travel, and data-driven chat apps for work (ie Slack). To bridge this gap, the Minimal phone sports an eInk display with a high refresh rate, a physical keyboard for that tactile feel, all while running on Android with full access to Google Play.&lt;/p&gt;

&lt;p&gt;Minimal Phone features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$399 USD MSRP&lt;/li&gt;
&lt;li&gt;E-Paper Display (eInk)&lt;/li&gt;
&lt;li&gt;Tactile QWERTY keyboard&lt;/li&gt;
&lt;li&gt;Android 14&lt;/li&gt;
&lt;li&gt;Headphone jack&lt;/li&gt;
&lt;li&gt;RCS messaging&lt;/li&gt;
&lt;li&gt;Full Google Play Store access&lt;/li&gt;
&lt;li&gt;4-day battery life&lt;/li&gt;
&lt;li&gt;NFC Payment support&lt;/li&gt;
&lt;li&gt;Android Auto&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full details on the &lt;a href="https://minimalcompany.com/" rel="noopener noreferrer"&gt;official Minimal Phone website&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Litephone III
&lt;/h3&gt;

&lt;p&gt;The Litephone III  has been making the rounds on YouTube lately for its unique form factor and dedication to keeping things simple. The device boasts metal side buttons, premium build quality, and AMOLED touch display. It’s shorter and thicker than a traditional smartphone, with a large speaker grill across the bottom of the device. It runs LightOS, a minimal software experience that offer a black and white list of utility-driven apps such as Alarm, Calculator, Podcast, Phone, and more.&lt;/p&gt;

&lt;p&gt;Lite Phone III features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Matte Glass 3.92” AMOLED (1080x1240) display&lt;/li&gt;
&lt;li&gt;1800mAH battery &lt;/li&gt;
&lt;li&gt;IP54 rated&lt;/li&gt;
&lt;li&gt;~1-2 days of battery life (still being determined as per the &lt;a href="https://www.thelightphone.com/faq" rel="noopener noreferrer"&gt;official FAQ&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full details on the &lt;a href="https://www.thelightphone.com/lightiii" rel="noopener noreferrer"&gt;official Litephone III website&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with modern feature phones
&lt;/h2&gt;

&lt;p&gt;The problem with modern feature phones is primarily the price, although that makes sense. Modern dumb phones are often tailored for those coming from the modern smartphone, serving people that need to keep some modern luxuries (ie mobile payments, navigation). Even still these dumb phones are often cheaper than many smartphones on the market - but not cheap enough for some.&lt;/p&gt;

&lt;p&gt;There is an entire demographic out there that have extremely limited budgets, but still need to be able to communicate with family and friends. Furthermore, as smartphones revolutionize what’s possible on-the-go, those that are budget-restricted have an increased need for more data-driven experiences. That means that we can’t just give these people a basic flip phone and call it a day. This is where Cloud Phone by &lt;a href="https://www.puffin.com/cloudmosa" rel="noopener noreferrer"&gt;CloudMosa&lt;/a&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cloud Phone?
&lt;/h2&gt;

&lt;p&gt;Cloud Phone is a revolutionary technology that brings modern web apps to basic dumb phones. Some of these dumb phones cost as little as $12 USD - so their onboard hardware is severely limited. If you think of modern websites and web apps, they have fancy hi-res images and animations that will struggle to run on anything but modern hardware, let alone tiny displays on phones with questionable reception. This is where Cloud Phone steps in.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Cloud Phone Works
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.cloudfone.com/" rel="noopener noreferrer"&gt;Cloud Phone&lt;/a&gt; uses cloud-based technology to offload computational tasks from low-end feature phones to cloud servers that allow these basic phones to function more like smartphones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Thin client architecture:&lt;/strong&gt; The feature phone acts as a lightweight terminal that connects to a virtualized environment in the cloud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote rendering and streaming:&lt;/strong&gt; User interactions are processed in the cloud and streamed back to the feature phone in real time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web-based applications:&lt;/strong&gt; Instead of installing apps like you would on an iPhone, users access cloud-hosted widgets for services like YouTube, Facebook, podcasts, news, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  In-depth look at Cloud Phone
&lt;/h3&gt;

&lt;p&gt;A few weeks ago Matt had the pleasure of sitting down with Cloud Phone’s Tom Barrasso on the HTML All The Things Podcast to discuss the importance of flip phones in 2025. The guys did a deep dive into flip phones for those looking at a digital detox, the limitations of RTOS, and the empowerment that Cloud Phone brings to devices with limited hardware.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/s1NvoexiNsw"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Also available on &lt;a href="https://open.spotify.com/episode/1KGW5wS5O6742MNvCKNHiB?si=s8LOgoVbQuWcW2oZwOYM3w" rel="noopener noreferrer"&gt;Spotify&lt;/a&gt; and &lt;a href="https://podcasts.apple.com/us/podcast/why-flip-phones-still-matter-in-2025-w-tom-barrasso/id1412209136?i=1000705658317" rel="noopener noreferrer"&gt;Apple Podcasts&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>discuss</category>
      <category>learning</category>
      <category>mobile</category>
    </item>
    <item>
      <title>The Toughest Concepts in Web Development</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Tue, 15 Oct 2024 20:04:18 +0000</pubDate>
      <link>https://dev.to/mattlawrence/the-toughest-concepts-in-web-development-3oi</link>
      <guid>https://dev.to/mattlawrence/the-toughest-concepts-in-web-development-3oi</guid>
      <description>&lt;p&gt;Web development is not easy! Many think it's as simple as choosing your favorite website builder, spending a few days uploading content, then pressing publish. If all you're looking for is a simple marketing website, then you're in luck...but if you're in need of anything else, you'll soon find yourself in the weeds.&lt;/p&gt;

&lt;p&gt;Some of the toughest concepts (according to us) include: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Asynchronous Programming and Promises&lt;/li&gt;
&lt;li&gt;State Management&lt;/li&gt;
&lt;li&gt;Security Concerns (XSS, CSRF, SQL Injection)&lt;/li&gt;
&lt;li&gt;Performance Optimization&lt;/li&gt;
&lt;li&gt;Scalability and Architecture&lt;/li&gt;
&lt;li&gt;Cross-Browser Compatibility&lt;/li&gt;
&lt;li&gt;Responsive Design&lt;/li&gt;
&lt;li&gt;Web Accessibility (a11y)&lt;/li&gt;
&lt;li&gt;SSR, SSG, CSR&lt;/li&gt;
&lt;li&gt;Event-Driven Architectures&lt;/li&gt;
&lt;li&gt;Dependency Management&lt;/li&gt;
&lt;li&gt;CI/CD&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Myself and my co-host, Mike Karan, discussed these topics below: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listen to &lt;a href="https://www.htmlallthethings.com/podcasts/the-toughest-concepts-in-web-development-part-1" rel="noopener noreferrer"&gt;Part 1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Listen to &lt;a href="https://www.htmlallthethings.com/podcasts/the-toughest-concepts-in-web-development-part-2" rel="noopener noreferrer"&gt;Part 2&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>podcast</category>
    </item>
    <item>
      <title>How to Create Blog Categories and Tags in Webflow</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Mon, 23 Sep 2024 20:22:50 +0000</pubDate>
      <link>https://dev.to/mattlawrence/how-to-create-blog-categories-and-tags-in-webflow-5607</link>
      <guid>https://dev.to/mattlawrence/how-to-create-blog-categories-and-tags-in-webflow-5607</guid>
      <description>&lt;p&gt;Blogging platforms like WordPress come with categories and tags that you can assign to blog posts right out of the box. This same functionality is available in Webflow, but it is not immediately obvious how to get it working. Unless you're using a template, Webflow websites require that we set up this functionality ourselves via the reference and multi-reference CMS fields. When working with Webflow it's important to remember that unlike WordPress, Webflow is not a blogging platform first. Webflow is a no-code website creation tool that can be used to create static sites, ecommerce stores, and blogs - therefore we need to utilize the power of the Webflow CMS to build out own blogging functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Guide Summary
&lt;/h2&gt;

&lt;p&gt;In this guide we will learn how to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use a reference field to create blog categories&lt;/li&gt;
&lt;li&gt;Use a multi-reference field to create blog tags
This guide does not require any custom code.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to create blog categories in Webflow
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This guide assumes you already have a CMS collection for your blog posts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Blog categories are a taxonomy that define the broad grouping that our blog post fall under. For example, a tech blog may have a category for their how-to guides and another category for their news posts. Using the steps below, we'll be allowing each of our blog posts to have a single category assigned to them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a category CMS collection
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open the CMS menu in the Webflow Designer&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv9e2diai15sl985asc0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv9e2diai15sl985asc0.png" alt="CMS menu item" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the "Create New Collection" button&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44mo3vw3lgf5g93eynro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44mo3vw3lgf5g93eynro.png" alt="Create New CMS Collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type in a name for the category collection&lt;br&gt;
-- We'll name ours "Blog Categories" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fysdyc9e7wxc5n44ghras.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fysdyc9e7wxc5n44ghras.png" alt="Naming New Collection - Blog Categories" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the collection by clicking "Create Collection"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr180uwb89ryto9b5xhe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr180uwb89ryto9b5xhe.png" alt="Save New Collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Create category fields
&lt;/h3&gt;

&lt;p&gt;By default, we're provided with a name field when we created the collection. Some websites will only need their categories to have a name and nothing else, if that's you, you can skip this step. Alternatively, categories need additional information other than just a name. For example, you may want a color selector so that content editors can control the color associated with each category. In this guide we'll assume we need this sort of color control.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hover over the "Blog Categories" collection and click on the cog icon&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fui70zae8je90bppqjswc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fui70zae8je90bppqjswc.png" alt="Blog Categories Setting" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "+ Add New Field" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmpdm1gqsf6vc6p7mp95.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmpdm1gqsf6vc6p7mp95.png" alt="Add New Field" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Color field and give it a name&lt;br&gt;
-- We'll call ours "Category Color"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fulsg5735zxen6rkgyuxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fulsg5735zxen6rkgyuxq.png" alt="Color CMS Field" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3w6nl4wqdavzq3n6ahk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3w6nl4wqdavzq3n6ahk.png" alt="Category Color" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the field and the collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqsc6x76f1w660zvjzfx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqsc6x76f1w660zvjzfx.png" alt="Save field" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcf3ntienn9yrk6toeb8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcf3ntienn9yrk6toeb8x.png" alt="Save Collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Create categories
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click on the "Blog Categories" collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6jribu2wt2j5d9qzwgy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6jribu2wt2j5d9qzwgy.png" alt="Blog Categories Collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the "+ New Blog Category" button&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fan5g2u0hovhb1cz4maym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fan5g2u0hovhb1cz4maym.png" alt="New Blog Category" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fill in a name and color for our category&lt;br&gt;
-- In this guide we'll add the "Guide" category in red and "News" category in green&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faken1p6e7eslef3gad8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faken1p6e7eslef3gad8h.png" alt="Fill In Category Name" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbl406uo0yl209wnqwn52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbl406uo0yl209wnqwn52.png" alt="Fill In Category Color" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save and publish your categories once you're done editing&lt;br&gt;
-- Note: You may need to publish your entire site before being able to publish single collection items&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0styhxqbeyk10namq9l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0styhxqbeyk10namq9l.png" alt="Publish your categories" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Make a reference field in your blog post CMS collection
&lt;/h3&gt;

&lt;p&gt;In this step we're going to add a reference field that will allow our blog posts to reference our categories collection. As a reference field you can reference a single category per blog post.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hover over the CMS collection you're using for your blog posts and click the cog icon&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-- In our case it's the "Blog Posts" collection&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnmqni6p02goezqoyq7cp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnmqni6p02goezqoyq7cp.png" alt="Image description" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click on "+ Add New Field" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flt3h7wrmz07h3a6mm69y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flt3h7wrmz07h3a6mm69y.png" alt="Add New Field" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Reference field and select your categories collection in the dropdown list&lt;br&gt;
-- In this guide, this is "Blog Categories"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faalzauv5a0pw8o5ldovh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faalzauv5a0pw8o5ldovh.png" alt="Select your categories collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give your reference field a recognizable name - we'll use "Category" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqe38fvcmtmxzmcsazr7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqe38fvcmtmxzmcsazr7.png" alt="Recognizable reference field name" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the field and the collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrmoh4k3ed1ahcy6ojqj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrmoh4k3ed1ahcy6ojqj.png" alt="Save field and collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Attach a category to your blog post
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Edit an existing, or create a new blog post&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5p5b77c9ey7tcolw4nwu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5p5b77c9ey7tcolw4nwu.png" alt="Edit an existing blog post or create a new one" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should see your reference field, where you can now select from any of the categories you've made&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyhsia8h3dwd0nqth15f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyhsia8h3dwd0nqth15f.png" alt="Use your new reference field and select a category" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to create blog tags in Webflow
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;This guide assumes you already have a CMS collection for your blog posts.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a tags CMS collection
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open the CMS menu in the Webflow Designer&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcdmv7ywza4bw1kqjor5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcdmv7ywza4bw1kqjor5.png" alt="Open CMS menu" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the "Create New Collection" button&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuija68tpwbgy72n6oku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuija68tpwbgy72n6oku.png" alt="Create new collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type in a name for the tags collection&lt;br&gt;
-- We'll name ours "Blog Tags" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wv4x4fi0w1vnolnvjf0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wv4x4fi0w1vnolnvjf0.png" alt="Naming the tags collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the collection by clicking on "Create Collection"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsmm65gka027hxkhrtb00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsmm65gka027hxkhrtb00.png" alt="Create collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Create tag fields
&lt;/h3&gt;

&lt;p&gt;By default, we're provided with a name field when we created the collection. Typically tags only need a name so you'll likely not have to add any additional fields - if this applies to you, you can skip this step. However, you can attach other fields to tags, much like categories. In this guide, we'll add a color control field so that site editors can control the affiliated color with each tag.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hover over the "Blog Tags" collection and click on the cog icon&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3pa18stczowo88rpelq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3pa18stczowo88rpelq.png" alt="Blog tags collection settings" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Add New Field" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Forq9e6mmnmhmwjb8f3ma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Forq9e6mmnmhmwjb8f3ma.png" alt="Add new field" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Color field and give it a name&lt;br&gt;
-- We'll call our "Tag Color"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1dc6a5w5s8v92bpe98yz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1dc6a5w5s8v92bpe98yz.png" alt="Select Color Field" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fplsxdf4ru8uruyh8o1l6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fplsxdf4ru8uruyh8o1l6.png" alt="Name your color field" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the field and the collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs29dcros4x2cl9f2ddry.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs29dcros4x2cl9f2ddry.png" alt="Save field" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdx75hfvkkmn8s2m7nod.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhdx75hfvkkmn8s2m7nod.png" alt="Save collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Create tags
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click on the "Blog Tags" collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5w31kv6m5qe35vqryra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5w31kv6m5qe35vqryra.png" alt="Click on blog tags collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the "+ New Blog Tag" button&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzuegz9a25go2p1xl56u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzuegz9a25go2p1xl56u.png" alt="Add a new blog tag" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fill in a name and color for our tag&lt;br&gt;
-- In this guide we'll add the "webdev" tag in blue and "html" tag in purple&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjexoqxv87tbaasgeeqaa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjexoqxv87tbaasgeeqaa.png" alt="Fill in tag name" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzkuox9ug10znzevmvq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzkuox9ug10znzevmvq1.png" alt="Fill in tag color" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save and publish your tags once you're done editing&lt;br&gt;
-- Note: You may need to publish your entire site before you'll be able to publish your tags&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbg6l2cuq8zl866ozqjwi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbg6l2cuq8zl866ozqjwi.png" alt="Save and publish tags" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Make a multi-reference field in your blog post CMS collection
&lt;/h3&gt;

&lt;p&gt;In this step we're going to add a multi-reference field that will allow our blog posts to reference our tags collection. As a multi-reference field, we'll be able to reference multiple tags at once.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hover over the CMS collection you're using for your blog posts and click the cog icon&lt;br&gt;
-- In our case it's the "Blog Posts" collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8afo9wwrjnafyhx5ctwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8afo9wwrjnafyhx5ctwx.png" alt="Blog Posts collection settings" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Add New Field"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a6lzs1bqyvv3rxfnftz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4a6lzs1bqyvv3rxfnftz.png" alt="Add new field" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Multi-Reference field and select your tags collection in the dropdown list&lt;br&gt;
-- In this guide, this is "Blog Tags"&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F398fws7vl37vwdvgs7c0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F398fws7vl37vwdvgs7c0.png" alt="Select multi-reference field" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyphh1bbp1r830zbi54mi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyphh1bbp1r830zbi54mi.png" alt="Select your tags collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give your multi-reference field a recognizable name - we'll use "Tags" &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewfbmkyolmoge1tdywqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewfbmkyolmoge1tdywqi.png" alt="Name your multi-reference field" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the field and the collection&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63u4bsd2a6ia77f3k59s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63u4bsd2a6ia77f3k59s.png" alt="Save field" width="800" height="523"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx1jut5rw1x50nqrs5ckp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx1jut5rw1x50nqrs5ckp.png" alt="Save collection" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Attach tags to your blog post
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Edit an existing, or create a new blog post&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsenf3jqvyzj5svp5rk7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsenf3jqvyzj5svp5rk7.png" alt="Edit existing or add new blog post" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should see your multi-reference field, where you can now select from any of the tags that you made&lt;br&gt;
-- Note that you can select multiple tags if you wish&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0e2vd3ja8c9p2c04ds2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0e2vd3ja8c9p2c04ds2.png" alt="Select any of the tags you made" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Support guides like this by checking out &lt;a href="https://www.htmlallthethings.com" rel="noopener noreferrer"&gt;our website&lt;/a&gt;, or giving Webflow a try with &lt;a href="https://try.webflow.com/f7xn5jp4zug3-variable?sub1=pricing" rel="noopener noreferrer"&gt;our link&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webflow</category>
      <category>webdev</category>
      <category>nocode</category>
      <category>writing</category>
    </item>
    <item>
      <title>How to Center Text in CSS</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Thu, 05 Oct 2023 20:49:21 +0000</pubDate>
      <link>https://dev.to/mattlawrence/how-to-center-text-in-css-5fbg</link>
      <guid>https://dev.to/mattlawrence/how-to-center-text-in-css-5fbg</guid>
      <description>&lt;h2&gt;
  
  
  How to center text in CSS
&lt;/h2&gt;

&lt;p&gt;You can center text in CSS both horizontally and vertically using a few different methods including margins, padding, flexbox, line-height, and text-align. How you center your text will depend on how your webpage is styled and whether you want to center horizontally, vertically, or both. Below, we'll explore centering text vertically using these methods in detail.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to horizontally center text in CSS
&lt;/h2&gt;

&lt;p&gt;Horizontally centering text in CSS can be achieved with the text-align and margin CSS properties. The text-align property will align the text itself, whereas the margin property will be used to center the container that the text resides in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxaomf1jipif1fswi4vmo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxaomf1jipif1fswi4vmo.png" alt="An example of centering text with text-align and margin: auto" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Horizontal text alignment with the text-align CSS property
&lt;/h3&gt;

&lt;p&gt;In your CSS, add text-align: center to a selector that contains the text you need to center.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"center-me"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Center this title!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.center-me&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsl5ub140x4vpulbjvzv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsl5ub140x4vpulbjvzv6.png" alt="Some centered text by using text-align: center in CSS" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want all your text centered across the entire page you can use the asterisk (*) or body selectors instead of a specific one (see CSS snippet below).&lt;/p&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Option 1 - Body Selector */&lt;/span&gt;
&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Option 2 - Asterisk Selector */&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Horizontal text alignment with the margin CSS property
&lt;/h3&gt;

&lt;p&gt;When you're working with a block-level element, you can center it using &lt;em&gt;&lt;strong&gt;margin: auto&lt;/strong&gt;&lt;/em&gt; in your CSS. This is a common practice when you want to center text that is contained inside a content box. The auto margin centers the containing box, but the text's alignment stays the same.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Heading&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean faucibus urna et turpis tempus pulvinar. Vestibulum laoreet lectus eget egestas mattis. Donec et leo consectetur, elementum est ac, aliquet nisl. Nunc aliquet, est sollicitudin suscipit auctor, lacus erat mattis ex, id bibendum lorem neque vitae mauris. Ut et tellus lectus. Maecenas non enim eget ante semper accumsan in at mi. Nam iaculis nec ex sed sodales. Morbi id euismod sapien.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlq2hrt756oufas6qymy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlq2hrt756oufas6qymy.png" alt="Text left-aligned within a horizontally centered content box" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This output shows us that the &lt;strong&gt;&lt;em&gt;margin: auto&lt;/em&gt;&lt;/strong&gt; centered the block-level content box (green), but did not change the alignment of the text itself (it is left as default, left-aligned in this case).&lt;/p&gt;

&lt;p&gt;If we want to alter the alignment of the text inside the content box, we can use the &lt;em&gt;&lt;strong&gt;text-align&lt;/strong&gt;&lt;/em&gt; property on it (see below).&lt;/p&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Note the addition of the text-align: center */&lt;/span&gt;
&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy47o0giws0157v2lkftl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy47o0giws0157v2lkftl.png" alt="Centered text inside a centered content box" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  How to vertically center text in CSS
&lt;/h2&gt;

&lt;p&gt;Vertically aligning text in CSS can be achieved with the line-height and padding CSS properties. Line-height adjusts the minimum height of each line that the text sits on - you can think of it as adjusting the space between the lines on a lined sheet of paper. Padding adds space between the edge of an element (border) and the elements it contains.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vertical text alignment with the line-height CSS property
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;line-height&lt;/em&gt;&lt;/strong&gt; CSS property is typically used to adjust the spacing between several lines of text (ie in the body of a blog post), but it can also be used to center text vertically if you know the height of the containing element.&lt;/p&gt;

&lt;p&gt;Here's an example of some text inside a containing div, the div has the height and width explicitly set.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is some text&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;As you can see below, our text will go to the top-left corner by default.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7h9mfmye67ylgrkvp1x6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7h9mfmye67ylgrkvp1x6.png" alt="Text in the top left of a content box" width="762" height="401"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  CSS w/ line-height centering
&lt;/h3&gt;

&lt;p&gt;Here we added the &lt;strong&gt;&lt;em&gt;line-height&lt;/em&gt;&lt;/strong&gt; property and set it to the height of the containing div.&lt;/p&gt;
&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;The text is now vertically aligned within it's containing div. Please note that if you write too much text to the point of the text wrapping to the next line, the results may be undesirable.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Free4vjpbaw3n9e5rtdzl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Free4vjpbaw3n9e5rtdzl.png" alt="Vertically centered text within a content box using hte line-height property" width="783" height="388"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Vertical alignment with the padding CSS property
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;padding&lt;/em&gt;&lt;/strong&gt; CSS property is typically used to add space between the edges (border) of an element and its contents. In some cases it can be used to center text vertically within an element.&lt;/p&gt;
&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is some text&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  CSS (long-form)
&lt;/h4&gt;

&lt;p&gt;This long-form CSS uses both the &lt;strong&gt;&lt;em&gt;padding-top&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;padding-bottom&lt;/em&gt;&lt;/strong&gt; properties. You can condense these properties into a single line as shown in the "CSS Alternative (shorthand)" section below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS Alternative (shorthand)
&lt;/h4&gt;

&lt;p&gt;Note the &lt;strong&gt;&lt;em&gt;padding&lt;/em&gt;&lt;/strong&gt; property pulls double duty, replacing &lt;strong&gt;&lt;em&gt;padding-top&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;padding-bottom&lt;/em&gt;&lt;/strong&gt; via the shorthand shown below. Both the long-form CSS above and the shorthand CSS shown here are valid.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;By setting the top and bottom padding to the same amount, our text containing div grows in height, pushing our text into the vertical center.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fizmiajngiayp8kcjqsx7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fizmiajngiayp8kcjqsx7.png" alt="Vertically centered text within a content box using padding" width="775" height="295"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  How to horizontally and vertically center text in CSS
&lt;/h2&gt;

&lt;p&gt;Sometimes you need to center text both horizontally and vertically. We can achieve this by using flexbox in our CSS, we'll explore this in detail below.&lt;/p&gt;
&lt;h3&gt;
  
  
  How to use flexbox to horizontally and vertically center text
&lt;/h3&gt;

&lt;p&gt;To horizontally and vertically center our text we can use &lt;strong&gt;&lt;em&gt;display: flex&lt;/em&gt;&lt;/strong&gt; alongside a couple other properties. In total we'll be setting the &lt;strong&gt;&lt;em&gt;display&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;justify-content&lt;/em&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;em&gt;align-items&lt;/em&gt;&lt;/strong&gt; properties.&lt;/p&gt;
&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;

&lt;p&gt;We've put our text in a containing element (div).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is some text&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;

&lt;p&gt;We set the containing div to flexbox and then align the text. We use &lt;strong&gt;&lt;em&gt;justify-content: center&lt;/em&gt;&lt;/strong&gt; to center the text horizontally and &lt;strong&gt;&lt;em&gt;align-items: center&lt;/em&gt;&lt;/strong&gt; to center the text vertically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;450px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F517cdogpknuu7ox8g73q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F517cdogpknuu7ox8g73q.png" alt="Vertically and horizontally centered text within a content box" width="748" height="478"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Scrimba Discount
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;If you use our link to purchase a plan, we will receive a monetary kickback&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn to code using Scrimba with their interactive follow-along code editor&lt;/li&gt;
&lt;li&gt;Join their exclusive Discord communities and network to find your first job!&lt;/li&gt;
&lt;li&gt;Use this URL to get 10% off on all their paid plans: &lt;a href="https://tinyurl.com/ScrimbaHATT" rel="noopener noreferrer"&gt;https://tinyurl.com/ScrimbaHATT&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;CSS Layout - Horizontal &amp;amp; Vertical Align (Source: &lt;a href="https://www.w3schools.com/css/css_align.asp" rel="noopener noreferrer"&gt;W3Schools&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;How to Center Text &amp;amp; Headers in CSS Using the Text-Align Property (Source: &lt;a href="https://blog.hubspot.com/website/center-text-in-css" rel="noopener noreferrer"&gt;HubSpot&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>frontend</category>
      <category>juniordeveloper</category>
    </item>
    <item>
      <title>What is VPS Hosting? How Does It Work? (Beginner's Guide)</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Mon, 18 Sep 2023 21:22:24 +0000</pubDate>
      <link>https://dev.to/mattlawrence/what-is-vps-hosting-how-does-it-work-beginners-guide-19de</link>
      <guid>https://dev.to/mattlawrence/what-is-vps-hosting-how-does-it-work-beginners-guide-19de</guid>
      <description>&lt;h2&gt;
  
  
  What is VPS hosting?
&lt;/h2&gt;

&lt;p&gt;VPS hosting stands for Virtual Private Server hosting, it serves as the middle option among the traditional hosting types (shared, VPS, dedicated). With VPS hosting, multiple users share a single piece of hardware (server), the server is divided up according to the amount of resources and specifications you've purchased from the hosting provider. The hosting provider manages the server with a hypervisor, a type of software that lets them divide up the server's resources into separate sections for each of their customers. These sections can have different operating systems installed, be given access to different types of storage (ie HDD vs SSD), and be powered by individual CPUs at varying performance levels.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does VPS hosting compare to shared and dedicated hosting?
&lt;/h3&gt;

&lt;p&gt;VPS hosting finds itself in the middle ground between shared hosting and dedicated hosting in terms of capability, price, and performance.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is shared hosting?
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-shared-hosting" rel="noopener noreferrer"&gt;Shared hosting&lt;/a&gt; provides a budget-friendly and low-performance solution for those with small-to-medium websites by sharing a single server among multiple hosting customers. With shared hosting, there is minimal administrative freedom, you can't install apps and configure the server any way you want, you're stuck working with whatever the hosting provider allows you to do. This lack of freedom benefits those that want an easy-to-setup environment with minimal technical knowhow.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is dedicated hosting?
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-dedicated-hosting" rel="noopener noreferrer"&gt;Dedicated hosting&lt;/a&gt; is the most expensive of the traditional hosting types, but it also provides the most administrative freedom and computing power. When you purchase a dedicated hosting plan, you're given access to an entire server, that you can setup and use as you see fit. These added capabilities allow dedicated hosting to power demanding websites and web apps, even if they have special configuration requirements. The downside is that you're in charge of the entire server and therefore there is quite a lot of technical debt added to your project in the form of server administration (installs, updates, maintenance).&lt;/p&gt;

&lt;h4&gt;
  
  
  VPS vs shared vs dedicated
&lt;/h4&gt;

&lt;p&gt;There is a great disparity between shared hosting and dedicated hosting. In summary, shared hosting provides a budget-friendly and low-technical skill solution for small-to-medium websites. Dedicated hosting on the other hand is very expensive and adds a lot technical debt to your workflow, but is capable of powering demanding websites and web apps. VPS hosting lives between shared and dedicated hosting, it acts as the middle ground in capability, price, and performance.&lt;/p&gt;

&lt;p&gt;Many projects (ie a niche blog) will start out on shared hosting, but as the site grows in popularity, shared hosting may not provide enough performance for the amount of users on the site. Instead of investing in a very expensive dedicated hosting plan and a server administrator to setup and maintain it, a VPS hosting plan is a more flexible option for your growing site. VPS hosting offers flexibility via managed and unmanaged options. Managed VPS hosting lets your hosting provider manage and maintain the server, just like they would with their shared hosting plans. This is a great option for those that don't need a lot of administrative freedoms, but have outgrown a shared hosting plan. On the flip side, an unmanaged VPS hosting plan gives you more administrative freedoms, but requires that you maintain the server yourself. This option is ideal for projects that require special server configurations to work, but aren't busy enough to justify a dedicated hosting plan.&lt;/p&gt;




&lt;h2&gt;
  
  
  How does VPS hosting work?
&lt;/h2&gt;

&lt;p&gt;VPS hosting works by dividing up a single piece of hardware (server) into separate sections that hosting customers rent from a hosting provider. The hosting provider divides up their server through the use of a hypervisor, a type of software that allows multiple operating systems to share a single piece of hardware through the creation and management of virtual machines (VMs). Hypervisors can be installed on top of an operating system (type-2 hypervisor), or can be installed on the physical server without an operating system (type-1 hypervisor).&lt;/p&gt;

&lt;p&gt;As a customer of a hosting provider, you don't need to worry about interacting with the hypervisor layer, instead, you'll be provisioned one of the virtual machines that the hypervisor helps manage. Each virtual machine can have its own operating system (ie Linux, Windows) and resource allocation (ie 4GHz 2-core CPU, 3GB RAM, 128GB SSD). Oftentimes, the servers that hosting providers use for their VPS offerings have redundant components, like multiple CPUs installed, meaning that an entire dedicated CPU can be allocated to a single VM.&lt;/p&gt;

&lt;p&gt;Each VM operates as it's own individual server, the resource limits are hard set so that a single hosting customer can't hog too many resources (something that can happen rarely in shared hosting). If managed properly, you should never see, or notice, any other hosting customer that is on the same physical server as you.&lt;/p&gt;




&lt;h2&gt;
  
  
  When should I use VPS hosting?
&lt;/h2&gt;

&lt;p&gt;VPS hosting is best used for websites and web apps that are not suitable for shared hosting (ie too much traffic), but don't require the amount of computing power that dedicated hosting provides. The middle ground, where VPS hosting sits, offers an environment that is much more powerful than shared hosting and optionally provides more administrative freedom. We'll explore the differences between managed and unmanaged VPS hosting below alongside examples of projects that would commonly use them.&lt;/p&gt;

&lt;p&gt;Each hosting provider may treat managed versus unmanaged VPS hosting differently, with some even offering a semi-managed solution. Make sure you research exactly what you're purchasing from the hosting provider. Personally, I always reach out to my selected hosting provider before purchasing a plan, to confirm that the solution that I'm choosing does exactly what I want it to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is managed VPS hosting?
&lt;/h3&gt;

&lt;p&gt;Managed VPS hosting offloads the server management (server administration) duties onto the hosting provider. These duties will vary from provider-to-provider, but in general, they'll continue caring for the server in the same way they do on their shared hosting plans. This frees up their customers to continue working on their website without having to worry about installing, updating, or maintaining the server's core functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example: When to use managed VPS hosting
&lt;/h4&gt;

&lt;p&gt;A common use case for VPS hosting is a niche website that has increased its traffic to the point where shared hosting cannot continue to provide a good experience for readers. Outgrowing shared hosting this way leads naturally to managed VPS hosting, as it provides vastly superior performance, with minimal technical knowhow.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is unmanaged VPS hosting?
&lt;/h3&gt;

&lt;p&gt;Unmanaged VPS hosting puts the server management (server administration) duties onto the customer. The hosting provider will provision a VM to their customer, leaving them to maintain and configure it as they see fit. This emulates the freedoms that dedicated hosting provides, without the steep costs. However, it's important to note that if you're not tech-savvy, server administration duties have a steep learning curve and can take a long time - adding to your technical debt.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example: When to use unmanaged VPS hosting
&lt;/h4&gt;

&lt;p&gt;A startup is creating a web app that has a lot of server configuration requirements. These requirements go beyond the customization capabilities that shared hosting provides (ie root access). Because the development team needs these freedoms, server management (sever administration) is not needed from the hosting provider. Since this is a new web app that is still not all that popular and is being developed on a startup's budget, unmanaged VPS hosting fits into this scenario almost perfectly.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is VPS hosting used for?
&lt;/h2&gt;

&lt;p&gt;VPS hosting is commonly used to host websites and web apps that are too much for shared hosting, and not enough for dedicated hosting. However, because you have an entire VM at your disposal (especially if it's unmanaged), then there are some alternative use cases for VPS hosting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Alternative VPS hosting use cases
&lt;/h3&gt;

&lt;p&gt;If you've read our article on &lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-dedicated-hosting#alternatives" rel="noopener noreferrer"&gt;dedicated hosting&lt;/a&gt;, it contains alternatives to just hosting websites and web apps. Because VPS is similar to dedicated in a lot of ways, namely in administrative freedom and computing power, the same alternative use cases that we mentioned for dedicated can apply to VPS as well. The benefit here is that VPS is a more budget-friendly option than dedicated, but because it is more locked down (ie managed VPS) you may need to shop around a bit more for a hosting provider that can give you a VPS that is appropriate for your alternative use case.&lt;/p&gt;

&lt;p&gt;I recommend reaching out to the sales/support of your preferred hosting provider to ask them if their VPS is capable of running your use case. Since VPS lies between the restriction of shared hosting and the freedom of dedicated hosting, sometimes web hosts will put some limitations on VPS that echo that of shared hosting. These restrictions may prevent specific applications (ie a Minecraft server) from being installed in the first place.&lt;/p&gt;

&lt;h4&gt;
  
  
  Hosting game servers
&lt;/h4&gt;

&lt;p&gt;Many video games allow you to host private game servers for your friends and/or community. Some VPS hosting plans will allow you to install whatever you'd like and are powerful enough to run a game server with quite a few people playing at once (these requirements vary per game). With many unmanaged VPS hosting plans you can even choose Windows over Linux as an operating system, an option that can open up a large list of game server compatibility. Keep in mind though, that VPS is typically not as powerful as dedicated, so a demanding game server - and especially a demanding game sever on Windows, may be too difficult to run on VPS. Check with your hosting provider for their hardware specifications.&lt;/p&gt;

&lt;h4&gt;
  
  
  IT infrastructure
&lt;/h4&gt;

&lt;p&gt;IT departments are responsible for setting up and maintaining several pieces of infrastructure, some of which may benefit from being hosted on the cloud. If compatible, VPS can offer a budget-friendly way to host some infrastructure instead of reaching for a traditional cloud hosting service (ie &lt;a href="https://azure.microsoft.com/" rel="noopener noreferrer"&gt;Azure&lt;/a&gt;, &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;), or even dedicated hosting.&lt;/p&gt;

&lt;h4&gt;
  
  
  Remote Workstation
&lt;/h4&gt;

&lt;p&gt;Sometimes you may need a workstation that is geographically close to a particular place. For example, if you hire someone from Australia, and they're required to FTP projects onto a Canadian server, they may experience disconnects and errors due to high latency (ping) between their computer and the Canadian server. By remotely accessing a server (remote workstation) that is closer to the Canadian server, these errors can be mitigated.&lt;/p&gt;




&lt;h2&gt;
  
  
  Is VPS hosting good?
&lt;/h2&gt;

&lt;p&gt;VPS hosting is good as long as you use it for what it is designed for, projects that can't run on shared hosting, but aren't demanding enough for dedicated hosting. These projects are typically websites and web apps that have outgrown their beginnings on shared hosting. For example, shared hosting is a perfect place to start a niche blog, but once the traffic picks up, performance may suffer. When that happens, it's time to upgrade your hosting - VPS is a great option in this particular case because it can handle a lot more traffic than shared, and is much cheaper than dedicated. VPS hosting is also ideal for people that have minimal technical knowhow in server administration, many hosting providers offer "managed VPS hosting" plans meaning they deal with the majority of the server maintenance for you.&lt;/p&gt;

&lt;p&gt;Choosing the best hosting type for you comes down to selecting the right tool for the job. In general this means...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Shared hosting&lt;/strong&gt; for small-to-medium websites and web apps. You can read more about shared hosting &lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-shared-hosting" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;VPS hosting&lt;/strong&gt; for websites and web apps that have outgrown shared hosting, but don't need the full power of a dedicated server&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Dedicated hosting&lt;/strong&gt; for demanding websites and web apps (and other server applications) that are very demanding, or need specialized configuration(s). You can read more about dedicated hosting &lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-dedicated-hosting" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pros and cons of VPS hosting
&lt;/h2&gt;

&lt;p&gt;Like all other hosting types, VPS hosting comes with its fair share of advantages and disadvantages. Please note that hosting providers operate as independent businesses and therefore some of the advantages and disadvantages listed below may not apply. After choosing a VPS hosting plan, I recommend reaching out to your chosen hosting provider to make sure that the project you plan to host will run without issues on their service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of using VPS hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Flexible offerings

&lt;ul&gt;
&lt;li&gt;Managed VPS hosting lets you offload the majority of the server maintenance and administration duties onto the hosting provider. Typically, this results in less administrative freedoms, but allows those with minimal technical knowhow to take advantage of the increased computing power that VPS offers&lt;/li&gt;
&lt;li&gt;Unmanaged VPS hosting lets you get one step closer to dedicated hosting without a huge increase in budget by giving you more administrative freedoms for more demanding projects&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  Budget-friendly upgrade

&lt;ul&gt;
&lt;li&gt;VPS gives you a budget-friendly upgrade option when you're coming from shared hosting. Jumping from shared to dedicated requires a large bump in the budget and the ability to take on a heap of technical debt&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  Testing and training friendly

&lt;ul&gt;
&lt;li&gt;If you're training a new employee, or testing out a client project in a private environment then you probably don't want to pay the high cost of a dedicated server. VPS gives you the freedom and power to run most websites, web apps, and other projects - especially if the only traffic is the development team&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of using VPS hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  The allure and constraint of the middle ground

&lt;ul&gt;
&lt;li&gt;Since VPS is a lot cheaper than dedicated hosting, it may be difficult to convince a purchasing manager to upgrade to dedicated when the time comes&lt;/li&gt;
&lt;li&gt;It's easy for a manager to keep asking their developers to increase site performance to stretch the host to the absolute limit, but there are only so many efficiencies that can be done before an upgrade to dedicated is required&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  Confusing offerings

&lt;ul&gt;
&lt;li&gt;Some hosting providers aren't real clear on what they're offering&lt;/li&gt;
&lt;li&gt;For example, all their VPS hosting plans may be managed, or unmanaged, without clearly stating which is which. Other hosting providers will offer managed and unmanaged, but may call them by different names&lt;/li&gt;
&lt;li&gt;This "marketing confusion" can cause more shopping around than normal for VPS versus shared or dedicated options&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Related Podcast Episode
&lt;/h2&gt;

&lt;p&gt;If you want to learn more about dedicated hosting and other traditional hosting types like shared and VPS, we have a recent podcast that you might be interested in listening to titled "What Type of Hosting Should You Use? (Shared, VPS, Dedicated, Reseller, WordPress, NodeJS)"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can give it a listen right&lt;/strong&gt; &lt;a href="https://www.htmlallthethings.com/podcasts/what-type-of-hosting-should-you-use-shared-vps-dedicated-reseller-wordpress-nodejs" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcgu1mkt8ssfpywdfqhsi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcgu1mkt8ssfpywdfqhsi.png" alt="HTML All The Things Podcast episode 260 thumbnail" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Scrimba Discount
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;If you use our link to purchase a plan, we will receive a monetary kickback&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Learn to code using Scrimba with their interactive follow-along code editor&lt;/li&gt;
&lt;li&gt;  Join their exclusive Discord communities and network to find your first job!&lt;/li&gt;
&lt;li&gt;  Use this URL to get 10% off on all their paid plans: &lt;a href="https://tinyurl.com/ScrimbaHATT" rel="noopener noreferrer"&gt;&lt;strong&gt;https://tinyurl.com/ScrimbaHATT&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Support Us On Patreon
&lt;/h2&gt;

&lt;p&gt;If you'd like to support more articles like this and future podcast episodes, please consider checking us out on &lt;a href="https://www.patreon.com/htmlallthethings" rel="noopener noreferrer"&gt;Patreon&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  What Is VPS Hosting? All You Need to Know About Virtual Private Servers (Source: &lt;a href="https://www.hostinger.com/tutorials/what-is-vps-hosting" rel="noopener noreferrer"&gt;Hostinger Tutorials&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;  What Is a Virtual Private Server (VPS)? (Source: &lt;a href="https://cloud.google.com/learn/what-is-a-virtual-private-server" rel="noopener noreferrer"&gt;Google Cloud&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;  Thumbnail made with &lt;a href="https://www.bing.com/create" rel="noopener noreferrer"&gt;Bing Image Creator&lt;/a&gt; and &lt;a href="https://www.canva.com/" rel="noopener noreferrer"&gt;Canva&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd like to support more articles like this and future podcast episodes, please consider checking us out on &lt;a href="https://www.patreon.com/htmlallthethings" rel="noopener noreferrer"&gt;Patreon&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webhosting</category>
      <category>webdev</category>
      <category>vps</category>
      <category>aws</category>
    </item>
    <item>
      <title>How to Center an Image with CSS</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Thu, 31 Aug 2023 21:34:36 +0000</pubDate>
      <link>https://dev.to/mattlawrence/how-to-center-an-image-with-css-3e43</link>
      <guid>https://dev.to/mattlawrence/how-to-center-an-image-with-css-3e43</guid>
      <description>&lt;p&gt;In this comprehensive guide, learn how to center an image vertically and horizontally using vanilla CSS. There are several methods that you can pick-and-choose from based on your project's needs and your own personal preference. As a junior developer it can be difficult to understand how each method works and which method to choose - we'll be covering several of these methods with examples below to help guide you.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Center an Image Horizontally
&lt;/h2&gt;

&lt;p&gt;Using CSS to center an image horizontally means you're centering it on the x-axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqq73dyzkx0xtbt8n0fh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqq73dyzkx0xtbt8n0fh.png" alt="An example shwoing a horizontally centered HTML All The Things logo" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 1: Margin Auto
&lt;/h3&gt;

&lt;p&gt;Using automatic margins on the left and right will align a block-level image element as long as it has a width that's less than 100%.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;display: block |&lt;/strong&gt; Changes our image element to a block-level element from it's inline-level default&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 250px |&lt;/strong&gt; Gives the image a set width lower than 100% (you can use a % instead of px value here to help with responsiveness)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;margin-left: auto &amp;amp; margin-right: auto |&lt;/strong&gt; These two properties horizontally center our image property&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Instead of using margin-left: auto and margin-right: auto you can alternatively use the margin: auto shorthand, however, it sets all margin directions (margin-top, margin-right, margin-bottom, margin-left) to auto. This might disrupt your layout if you're using specific margin values on the top and bottom of your image.&lt;/p&gt;

&lt;h4&gt;
  
  
  Alternative CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Alternative: Using margin auto shorthand */&lt;/span&gt;
&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Method 2: Display Flex
&lt;/h3&gt;

&lt;p&gt;If you're using flexbox throughout your project, this is a great method to horizontally center an image. For this method you'll need to have a container div that wraps around the image element.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;display: flex |&lt;/strong&gt; Applying flexbox to our wrapper div&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;justify-content: center |&lt;/strong&gt; Centers flex children horizontally (assuming the flex-direction property is left as default)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 250px |&lt;/strong&gt; Gives the image a set width lower than 100% (you can use a % instead of px value here to help with responsiveness)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Method 3: Text Align
&lt;/h3&gt;

&lt;p&gt;Images are inline-level elements by default, when contained by a block-level element, you can use the text-align property on the container to center the image horizontally.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;display: block |&lt;/strong&gt; Ensures our wrapper div is a block-level element so that text-align works (by default a div is block-level, so in this context it is redundant, however the element you use as a wrapper may not be block-level by default and will need this applied)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;text-align: center |&lt;/strong&gt; Applied on a block-level wrapper element, it will center the image element that it contains&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 250px |&lt;/strong&gt; Gives the image a set width lower than 100% (you can use a % instead of px value here to help with responsiveness)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Method 4: Position Absolute, CSS Calc &amp;amp; CSS Transform
&lt;/h2&gt;

&lt;p&gt;This method is a manual way of centering our image horizontally, it is more involved than the other methods covered in this guide, but it is still responsive.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS - Calc
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="m"&gt;125px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;position: relative |&lt;/strong&gt; Makes the image align in relation to the container div&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;position: absolute |&lt;/strong&gt; Lets you set where the image will be positioned exactly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;left: calc(50% - 125px) |&lt;/strong&gt; Horizontally centers our image

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;left: 50%&lt;/em&gt; alone would move the left side of the image to be horizontally centered&lt;/li&gt;
&lt;li&gt;We know the width of our image (250px), to center the image horizontally we need to move it over by half of that width (125px)&lt;/li&gt;
&lt;li&gt;calc(50% - 125px) moves our image over by 50% minus half of the image's width (125px), horizontally centering the image&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Alternative CSS - Transform &amp;amp; Translate
&lt;/h2&gt;

&lt;p&gt;This alternative method swaps out the calc function in our left property and replaces it with a transform property + translate function. This method is arguably better for responsivity as you don't need to know what the width of our image is - allowing our image to be dynamically sized as needed without additional media queries in our CSS to compensate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The differences between the previous CSS example and this alternative version lie in the top, transform, and width properties (we removed the height property).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;left: 50% |&lt;/strong&gt; Moves the left side of the image over to the horizontally aligned position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;transform: translateX(-50%) |&lt;/strong&gt; This moves the image left by 50% of it's height so that the center of the image aligns with the horizontally centered position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 25% |&lt;/strong&gt; We set our width to 25% to show that we have not explicitly set our height + width, meaning it can responsively change as needed and this method will continue horizontally centering our image&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to Center an Image Vertically
&lt;/h2&gt;

&lt;p&gt;Using CSS to center an image horizontally means you're centering it on the y-axis. Centering an image vertically has less methods than horizontally, but luckily the more modern methods like flexbox and grid make the task easy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuifet4m752nilk1o2wts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuifet4m752nilk1o2wts.png" alt="Example of the HTML All The Things logo vertically centered" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 1: Display Flex
&lt;/h3&gt;

&lt;p&gt;You'll need a container div wrapped around the image you're centering, you'll also need to give the container a height that is larger than the image's height so that we can vertically center it within the container.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;display: flex |&lt;/strong&gt; Sets the wrapper div to flexbox&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;align-items: center |&lt;/strong&gt; Centers flex-items to be vertically centered, our image is the only flex-item in this example (assuming the flex-direction property is left as default)‍&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;height: 500px |&lt;/strong&gt; The container needs to be taller than the image we are centering so that the image can be centered vertically inside of it&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Method 2: Position Absolute, CSS Calc &amp;amp; CSS Transform
&lt;/h3&gt;

&lt;p&gt;This method is a manual way of centering our image vertically, it is more involved than the other methods covered in this guide, but it is still responsive.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS - Calc
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="m"&gt;37.5px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;75px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;position: relative |&lt;/strong&gt; Makes the image align in relation to the container div&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;height: 500px |&lt;/strong&gt; Sets a height for the container div that is higher than the height of the image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;position: absolute |&lt;/strong&gt; Lets you set where the image will be positioned exactly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;top: calc(50% - 37.5px) |&lt;/strong&gt; Sets the position of the image as vertically centered

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;top: 50%&lt;/em&gt; alone would move the top of the image to be vertically centered&lt;/li&gt;
&lt;li&gt;We need to move the image up a bit so that the center of the image lines up to be vertically centered&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;calc(50% - 37.5px)&lt;/em&gt; moves the image down by 50%, then we subtract half the image image's height (image height: 75px, half of that is: 37.5px) from that figure to move the image up to be vertically centered&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Alternative CSS - Transform &amp;amp; Translate
&lt;/h3&gt;

&lt;p&gt;This alternative method swaps out the calc function in our top property and replaces it with a transform property + translate function. This method is arguably better for responsivity as you don't need to know what the height of our image is - allowing our image to be dynamically sized as needed without additional media queries in our CSS to compensate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The differences between the previous CSS example and this alternative version lie in the top, transform, and width properties (we removed the height property).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;top: 50% |&lt;/strong&gt; Moves the top of the image down to the vertically aligned position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;transform: translateY(-50%) |&lt;/strong&gt; This moves the image up by 50% of it's height so that the center of the image aligns with the vertically centered position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 25% |&lt;/strong&gt; We set our width to 25% to show that we have not explicitly set our height + width, meaning it can responsively change as needed and this method will continue to vertically center our image&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How to Center an Image Horizontally and Vertically at the Same Time
&lt;/h2&gt;

&lt;p&gt;Centering an image vertically and horizontally means you're centering it on both the x and y axes. You can think of it of placing your image right in the center of a page (wrapper div).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fejbt4vzsi0nmy0d2suaz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fejbt4vzsi0nmy0d2suaz.png" alt="Example of centering the HTML All The Things logo horizontally and vertically" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 1: How to Center an Image with CSS Grid
&lt;/h3&gt;

&lt;p&gt;Using this centering method with CSS Grid will center our image both horizontally and vertically at the same time. This is arguably the easiest way to vertically and horizontally center an image.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;place-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;display: grid |&lt;/strong&gt; Applies grid layout to our wrapper div&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;place-items: center |&lt;/strong&gt; Vertically and horizontally centers our image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;height: 500px |&lt;/strong&gt; Sets a height for the container div that is higher than the height of the image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 250px |&lt;/strong&gt; Gives the image a set width lower than 100% (you can use a % instead of px value here to help with responsiveness)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Method 2: Display Flex (horizontal &amp;amp; vertical)
&lt;/h3&gt;

&lt;p&gt;Using flexbox to center an image horizontally and vertically is just a matter of combining both the horizontal and vertical methods together.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;height: 500px |&lt;/strong&gt; Sets a height for the container div that is higher than the height of the image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;display: flex |&lt;/strong&gt; Sets the wrapper div to flexbox&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;justify-content: center |&lt;/strong&gt; Centers flex-items horizontally, our image is the only flex-item in this example (assuming the flex-direction property is left as default)‍&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;align-items: center |&lt;/strong&gt; Centers flex-items to be vertically centered, our image is the only flex-item in this example (assuming the flex-direction property is left as default)‍&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;width: 250px |&lt;/strong&gt; Gives the image a set width lower than 100% (you can use a % instead of px value here to help with responsiveness)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Method 3: Position Absolute, CSS Transform &amp;amp; CSS Translate (horizontal &amp;amp; vertical)
&lt;/h3&gt;

&lt;p&gt;This method is a manual way of centering our image vertically and horizontally, it is more involved than the other methods covered in this guide, but it is still responsive.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://uploads-ssl.webflow.com/5f188c7c01b1cd56e383610e/5f21f00868fd8ee81abc29de_logo_transparency.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;div |&lt;/strong&gt; A container (aka wrapper) div that contains the image that we need to center&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;position: relative |&lt;/strong&gt; Makes the image align in relation to the container div&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;height: 500px |&lt;/strong&gt; Sets a height for the container div that is higher than the height of the image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;position: absolute |&lt;/strong&gt; Lets you set where the image will be positioned exactly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;left: 50% |&lt;/strong&gt; Sets the left side of the image to be horizontally centered&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;top: 50% |&lt;/strong&gt; Sets the top side of the image to be vertically centered&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;transform: translate(-50%, -50%) |&lt;/strong&gt; Adjusts the image position to move up by 50% of its height and left by 50% of its width so that the center of the image is centered horizontally and vertically

&lt;ul&gt;
&lt;li&gt;The translate CSS function is shorthand for the translateX and translateY functions&lt;/li&gt;
&lt;li&gt;It can be broken down as translate(X, Y)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;width: 25% |&lt;/strong&gt; We set our width to 25% to show that we have not explicitly set our height + width, meaning it can responsively change as needed and this method will continue vertically center our image&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Learn More CSS
&lt;/h2&gt;

&lt;p&gt;If you're looking for more CSS content we have a couple of podcast episodes that you might be interested in:&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS Attribute Selectors &amp;amp; Custom Attributes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Listen Here: &lt;a href="https://www.htmlallthethings.com/podcasts/css-attribute-selectors-custom-attributes" rel="noopener noreferrer"&gt;Episode Link&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn how to select elements based on the presence of an attribute, or the presence of an attribute with a specific value&lt;/li&gt;
&lt;li&gt;Filter through attribute values with vanilla CSS features&lt;/li&gt;
&lt;li&gt;Create and work with custom attributes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  CSS Selectors Crash Course
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Listen Here: &lt;a href="https://www.htmlallthethings.com/podcasts/css-selectors-crash-course" rel="noopener noreferrer"&gt;Episode Link&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn how to select elements based on their class, ID, or HTML element type&lt;/li&gt;
&lt;li&gt;CSS selector structure

&lt;ul&gt;
&lt;li&gt;Simple selector&lt;/li&gt;
&lt;li&gt;Compound selector&lt;/li&gt;
&lt;li&gt;Relative selector&lt;/li&gt;
&lt;li&gt;Selector List&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Grouping selectors&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Scrimba Discount!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Learn to code using Scrimba with their interactive follow along code editor&lt;/li&gt;
&lt;li&gt;Join their exclusive discord communities and network to find your first job!&lt;/li&gt;
&lt;li&gt;Use this URL to get 10% off on all their paid plans: &lt;a href="https://tinyurl.com/ScrimbaHATT" rel="noopener noreferrer"&gt;https://tinyurl.com/ScrimbaHATT&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to Vertically &amp;amp; Horizontally Center an Image in HTML &amp;amp; CSS (&lt;a href="https://blog.hubspot.com/website/center-an-image-in-html" rel="noopener noreferrer"&gt;Hubspot&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;HTML Center Image – CSS Align Img Center Example (&lt;a href="https://www.freecodecamp.org/news/html-center-image-css-align-img-center-example/#howtocenteranimagewithcssgrid" rel="noopener noreferrer"&gt;Free Code Camp&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;How to Center an Image Vertically and Horizontally with CSS (&lt;a href="https://www.freecodecamp.org/news/how-to-center-an-image-in-css/" rel="noopener noreferrer"&gt;Free Code Camp&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>frontend</category>
    </item>
    <item>
      <title>What Is Dedicated Hosting? How Does It Work? (Beginner’s Guide)</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Thu, 31 Aug 2023 20:40:39 +0000</pubDate>
      <link>https://dev.to/mattlawrence/articlewhat-is-dedicated-hosting-how-does-it-work-beginners-guide-1dlp</link>
      <guid>https://dev.to/mattlawrence/articlewhat-is-dedicated-hosting-how-does-it-work-beginners-guide-1dlp</guid>
      <description>&lt;h2&gt;
  
  
  What is dedicated hosting?
&lt;/h2&gt;

&lt;p&gt;Dedicated hosting is a type of web hosting that gives you access to an entire physical server. It is designed to give you the freedom to configure and install whatever you need to, to get your website/web app up and running. Out of all the hosting types offered by traditional web hosts (shared, VPS, dedicated), dedicated hosting gives you the most computing power, perfect for complex web apps, or websites with a lot of traffic.&lt;/p&gt;

&lt;p&gt;You can compare dedicated hosting to using your own personal computer. Nobody else uses it and you're free to install and uninstall any programs that you want. Because nobody else is using your computer, you have all its power at your disposal to run a program, play a game, convert files, and more.&lt;/p&gt;

&lt;p&gt;Note: Despite the power and freedoms found with dedicated hosting, I recommend contacting your hosting provider with your project's use case and requirements to ensure that you're purchasing the plan that is right for you. Hosting providers are all separate and competing businesses, so they're offerings will vary depending on the needs of their customers.&lt;/p&gt;




&lt;h2&gt;
  
  
  How does dedicated hosting work?
&lt;/h2&gt;

&lt;p&gt;When you purchase a dedicated hosting plan, you're renting a server in a hosting provider's datacenter. A server is a computer that, in this context, you access remotely to setup and configure a website, web app, or other server application. Unlike other hosting types like shared and VPS where you need to share the server with some of the hosting provider's other customers, dedicated hosting gives you an entire server just for yourself. The hosting provider is responsible for keeping that server running through power outages, hardware failures, and network problems. Your responsibility is for everything on the server itself, including the programs you need to install and how they're configured. Sometimes you can purchase additional support from the hosting provider to help you manage the server's software - some hosting providers will include support for no additional cost.&lt;/p&gt;




&lt;h2&gt;
  
  
  When should I use dedicated hosting?
&lt;/h2&gt;

&lt;p&gt;Dedicated hosting should be used for websites and web apps that have a lot of traffic (high bandwidth), need a lot of computing power (complex), and/or require a specialized configuration. Some projects need a high-level of security and may gravitate towards dedicated hosting just so they're not sharing hardware with any other customers like on VPS, or shared hosting. Dedicated hosting is typically sold as web hosting (websites and web apps), but because you have access to a powerful server sitting on the cloud, some people will use it for other server-based applications like game servers, or IT infrastructure - you can read more about this in the "&lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-dedicated-hosting#alternatives" rel="noopener noreferrer"&gt;Alternative uses for dedicated hosting&lt;/a&gt;" section below.&lt;/p&gt;




&lt;h2&gt;
  
  
  Is dedicated hosting good?
&lt;/h2&gt;

&lt;p&gt;Dedicated hosting is good as long as you use it for what it's designed for, very high demand websites, web apps, and server-based projects. It is very high performance, but also very expensive in comparison to other hosting types like shared hosting. Some projects will work just fine under the constraints of shared hosting at a fraction of the cost, so it's important that you check if your project needs dedicated hosting before committing to it.&lt;/p&gt;

&lt;p&gt;Choosing the best hosting type for you comes down to selecting the right tool for the job. In general this means...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shared hosting&lt;/strong&gt; for small-to-medium websites and web apps. You can read more about shared hosting &lt;a href="https://www.htmlallthethings.com/blog-posts/what-is-shared-hosting" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VPS hosting&lt;/strong&gt; for websites and web apps that have outgrown shared hosting, but don't need the full power of a dedicated server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dedicated hosting&lt;/strong&gt; for demanding websites and web apps (and other server applications) that are very demanding, or need specialized configuration(s)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pros and cons of dedicated hosting
&lt;/h2&gt;

&lt;p&gt;Like all other hosting types, dedicated hosting comes with its fair share of advantages and disadvantages. It's important to note that hosting providers are businesses that compete with each other and therefore some of the points listed below may not apply to you (ie your hosting provider may give you comprehensive support for free).&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of using dedicated hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Freedom of configuration
-- You'll have the freedom to install, configure, and uninstall programs that you might need. You may even be given the choice of OS (Windows Server, Linux Server - various distros)&lt;/li&gt;
&lt;li&gt;A lot of computing resources
-- If your project requires a lot of computing power, then dedicated hosting provides the highest amount of computing power out of the traditional hosting types (shared, VPS, dedicated)&lt;/li&gt;
&lt;li&gt;Hardware insights and selection
-- When you purchase dedicated hosting from a hosting provider, they'll usually give you insights into the components they're using (ie type of CPU, amount of RAM, storage amount + speed). Typically hosting providers will keep some of these details under wraps (unless asked) for other hosting types like shared and VPS. Some dedicated hosting packages even let you choose from a pre-selected list of hardware options.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of using dedicated hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Added technical debt
-- You're almost always responsible for the entire server's configuration and maintenance. That means you'll need to perform OS and software updates as well as software installations - this includes testing if the updates work before making them live to avoid as much downtime as possible. These skills are often called "server administration" and they have an extremely high learning curve, with a big time commitment required to learn and implement all the things that keep your server working as intended&lt;/li&gt;
&lt;li&gt;Increased expense
-- Dedicated hosting is the most expensive of the traditional web hosting types (shared, VPS, dedicated)&lt;/li&gt;
&lt;li&gt;The expense increase can be quite considerable with shared hosting plans starting at ~$10CAD/month and dedicated starting at ~$100CAD/month&lt;/li&gt;
&lt;li&gt;Less comprehensive or more expensive support
-- Hosting providers will often offer comprehensive support for their shared and managed VPS hosting plans. This offering is much more rare for dedicated hosting as you have free reign over the server, so they aren't experienced with your unique configurations&lt;/li&gt;
&lt;li&gt;Some hosting providers will offer comprehensive support for their dedicated hosting at a premium hourly rate&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Alternative uses for dedicated hosting
&lt;/h2&gt;

&lt;p&gt;Servers aren't just used for websites and web apps, there are plenty of reasons why you'd want to have a computer sitting in the cloud at your disposal. Because you have virtually free reign over dedicated hosting, some people will use them for other use cases like hosting game servers, or IT infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important note:&lt;/strong&gt; Dedicated hosting is typically sold as web hosting. If you are trying to use a dedicated hosting plan for something other than a website/web app, I recommend contacting the hosting provider to ask them if your intended use case is supported.&lt;/p&gt;

&lt;h3&gt;
  
  
  Examples of alternative use cases for dedicated hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Remote workstation
-- Sometimes you may need a workstation that is geographically close to a particular place. For example, you may have a developer located in Australia that constantly needs to upload and interact with servers in Canada. These interactions may be slow and timeout frequently, because of how far away they are from what they're working on. To remedy this, they could remote into a workstation (ie dedicated server running Windows) located in Canada, and perform those troublesome actions on there.&lt;/li&gt;
&lt;li&gt;Video game server
-- Some games require, or have the option for you to run your own server (ie Minecraft). Your home computer may not be able to keep up with hosting a game server due to the computing requirements, internet speed, or even electricity required (if you live in an area with frequent power outages, the server will keep going down). Dedicated servers are typically powerful enough in computing power and have enough networking capability to keep up with you and your friends playing together.
-- You may need to limit the population of a game server if it gets too popular as some game servers are very demanding, with demand climbing considerably as new users log in.&lt;/li&gt;
&lt;li&gt;IT infrastructure
-- Some of IT's systems may benefit from sitting on a dedicated server. While this is typically done on cloud hosting with providers such as &lt;a href="https://azure.microsoft.com/" rel="noopener noreferrer"&gt;Azure&lt;/a&gt;, some small-to-medium businesses may find that dedicated hosting is more budget friendly to run apps that IT is comfortable running on a dedicated server.
-- It's important to note that a lot of IT systems need a good amount of security, so an internal server, or secured Azure offering may be preferred
-- An example of an IT system that could work on dedicated hosting is a video streaming server. The power of dedicated hosting would allow for transcoding, and the increased storage space has room for high-quality 4K videos. If the videos are meant for marketing on a digital display (ie on a retail smart display), then security may not be an issue as the videos are already suitable for public-viewing.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Related Podcast Episode
&lt;/h2&gt;

&lt;p&gt;If you want to learn more about dedicated hosting and other traditional hosting types like shared and VPS, we have a recent podcast that you might be interested in listening to titled "What Type of Hosting Should You Use? (Shared, VPS, Dedicated, Reseller, WordPress, NodeJS)"&lt;/p&gt;

&lt;p&gt;You can give it a listen right &lt;a href="https://www.htmlallthethings.com/podcasts/what-type-of-hosting-should-you-use-shared-vps-dedicated-reseller-wordpress-nodejs" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvchjh4xcwh736tfzuvz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvchjh4xcwh736tfzuvz.png" alt="HTML All The Things Podcast thumbnail for episode 260 - What type of hosting should you use?" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Scrimba Discount!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Learn to code using Scrimba with their interactive follow-along code editor&lt;/li&gt;
&lt;li&gt;Join their exclusive Discord communities and network to find your first job!&lt;/li&gt;
&lt;li&gt;Use this URL to get 10% off on all their paid plans: &lt;a href="https://tinyurl.com/ScrimbaHATT" rel="noopener noreferrer"&gt;https://tinyurl.com/ScrimbaHATT&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What is Dedicated Hosting? (Source: &lt;a href="https://www.wpbeginner.com/glossary/dedicated-hosting/" rel="noopener noreferrer"&gt;wpbeginner&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Shared Hosting vs. Dedicated Hosting (Source: &lt;a href="https://www.domain.com/blog/shared-hosting-vs-dedicated-hosting/" rel="noopener noreferrer"&gt;domain.com&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;WHC Pricing pages for &lt;a href="https://whc.ca/canadian-web-hosting" rel="noopener noreferrer"&gt;shared hosting&lt;/a&gt; and &lt;a href="https://whc.ca/dedicated-servers" rel="noopener noreferrer"&gt;dedicated hosting&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Thumbnail made with &lt;a href="https://www.bing.com/create" rel="noopener noreferrer"&gt;Bing Image Creator&lt;/a&gt; and &lt;a href="https://www.canva.com/" rel="noopener noreferrer"&gt;Canva&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webhosting</category>
      <category>serveradmin</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What Is Shared Hosting? How Does It Work? (Beginner’s Guide)</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Thu, 24 Aug 2023 18:51:25 +0000</pubDate>
      <link>https://dev.to/mattlawrence/what-is-shared-hosting-how-does-it-work-beginners-guide-h5a</link>
      <guid>https://dev.to/mattlawrence/what-is-shared-hosting-how-does-it-work-beginners-guide-h5a</guid>
      <description>&lt;h2&gt;
  
  
  What is shared hosting?
&lt;/h2&gt;

&lt;p&gt;Shared hosting is a type of web hosting that is a budget and beginner-friendly option offered by most "traditional web hosts." Shared hosting allows you to share a single piece of hardware (a server) with other web hosting customers, a method that keeps costs down for those that run small low-traffic websites, or are just getting started online. The server is managed by the hosting provider, so you won't need to do any sort of server administration tasks. Instead of managing the server, the provider will give you a small piece of the server to work with, within the freedoms that they allow.&lt;/p&gt;

&lt;p&gt;For example, many hosting providers will give you access to your account via cPanel, a web app that you can log in to, to manage your little piece of the server. Within &lt;a href="https://cpanel.net/" rel="noopener noreferrer"&gt;cPanel&lt;/a&gt; you'll have the power to upload files, manage databases, install site builders (ie WordPress), configure PHP versions, and more.* Not all hosting providers use cPanel, some will use their own custom management software, while others will use more widespread cPanel alternatives such as &lt;a href="https://www.plesk.com/" rel="noopener noreferrer"&gt;Plesk&lt;/a&gt;. The hosting provider has the ultimate say in what goes on, on their server, they'll choose what you can and cannot do on your account. This means that when you're shopping for shared hosting, they're not all built the same, it's important that you check that you have the ability to configure and install all you need to for your website to work properly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;* Available features are dictated and controlled by the hosting provider&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a traditional web host?
&lt;/h3&gt;

&lt;p&gt;Traditional web hosts are hosting provider businesses that offer hosting services on a single server within a single datacenter. They typically offer three hosting types including shared hosting, VPS hosting, and dedicated hosting. This is unlike hosting providers like AWS (sometimes called cloud hosting), that provide services capable of scaling up and down across multiple datacenters and servers as needed and as purchased.&lt;/p&gt;

&lt;p&gt;In my experience, traditional web hosts are commonly associated with selling a "complete package"  - using Linux as their OS (pre-installed), running WHM and/or cPanel for management (pre-installed), MySQL for databases (configurable from cPanel), with Apache as their web server. Although they're not limited to these options of course.&lt;/p&gt;




&lt;h2&gt;
  
  
  How does shared hosting work?
&lt;/h2&gt;

&lt;p&gt;Shared hosting works by taking a single server (computer) and dividing its resources up amongst several of a hosting provider's customers. Each customer is given a pool of resources that they're allowed to use (ie 2GB of memory, 5GB of storage space), most modern shared hosting will treat this pool of resources as a hard limit. This means that if a customer is limited to 2GB of memory, the provider's management software won't allow them to go over this limit - this ensures that a single customer won't hog all the available server resources. Each customer is typically given access to their piece of the server via a control panel web app where they can configure and install their website. Since the hosting provider manages the server, they have the ultimate say on what their customers are allowed to configure and install in their control panels.&lt;/p&gt;




&lt;h2&gt;
  
  
  Is shared hosting good?
&lt;/h2&gt;

&lt;p&gt;Shared hosting is good, as long as you use it for what it's designed for. It is designed for small websites with low-to-medium traffic and minimal required computing power. The traffic amount is usually easy enough to figure out, but the required computing power is not. For example, having images on your website is easy for shared hosting to handle...but having videos that need to be transcoded (changing the quality between say 1080p through 720p) will most likely max out the amount of CPU power that you're allotted - even if your traffic is low. It is important to research and test your project's needs before deploying it to production as the amount of computing power you have at your disposal on shared hosting is usually very limited.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of shared hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Budget Friendly:&lt;/strong&gt; Only one server is being used for several customers and therefore the provider's costs are lower than other hosting types. Those savings get passed down to you in the form of budget-friendly pricing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Minimal Administrative Overhead:&lt;/strong&gt; The hosting provider deals with all the server's OS updates, networking, and app installations. You don't need to do all that management yourself - a time consuming task with a steep learning curve.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Low Technical Ability Friendly:&lt;/strong&gt; The hosting provider manages the server and almost always provides comprehensive support for anything that goes wrong (with some exceptions that vary provider-to-provider). This makes shared hosting one of the easiest hosting types for people that don't have much technical knowhow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Commonly, websites will overrun their storage requirements before generating enough traffic to justify upgrading to a more powerful hosting type. There are usually several tiers of shared hosting available at most hosting providers and upgrading through them is commonly as easy as paying for a new plan to raise your resource allotment.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of shared hosting
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Limited Freedoms:&lt;/strong&gt; The hosting provider dictates what you can and cannot install, configure, and use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Low computing power:&lt;/strong&gt; If your web app needs to use anything that is computationally heavy (ie transcode a video on the fly) then you'll be susceptible to poor performance and crashes.&lt;br&gt;
Lack of technical insight: Shared hosting is often sold with minimal technical details short of the amount of storage space and management software they'll be selling you. For example, it's common you won't know how fast the NIC (Network Interface Card) is, or what processor is being used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security Risks:&lt;/strong&gt; You're sharing a server/computer with strangers and while it's very rare that you'll ever see their data, a bug or bad actor could cause trouble on your server. If you're using webmail, you could find yourself temporarily blocked from sending email to popular services (ie Outlook/Hotmail, Gmail) if someone else on the server (with the same IP address) sent out a lot of spam.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What type of projects is shared hosting good for?
&lt;/h2&gt;

&lt;p&gt;Shared hosting is good for projects with low-to-medium traffic, and minimal computational power requirements.&lt;/p&gt;

&lt;p&gt;Shared hosting is good for these types of projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blogs (including ones with a database-driven CMS like WordPress)&lt;/li&gt;
&lt;li&gt;Landing pages&lt;/li&gt;
&lt;li&gt;Small business websites&lt;/li&gt;
&lt;li&gt;Static sites (no CMS, no databases)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;_Remember to check with the hosting provider to ensure your project's needs are met by your selected hosting plan and be sure to test your project extensively before launching. Even if you're launching "just a blog" you may not realize that a feature of your site could overrun the capabilities of a shared hosting.&lt;br&gt;
_&lt;/p&gt;




&lt;h2&gt;
  
  
  How to select a shared hosting plan
&lt;/h2&gt;

&lt;p&gt;In order to select the shared hosting plan that is right for you, you'll need to know what your website's requirements are. One key requirement is how much storage space your project needs now and in the immediate future. Most hosting providers offer multiple tiers of shared hosting plans that come with various perks and capabilities. Commonly, the biggest difference between the tiers will be how much storage space will be made available to you, but there are some other things you should be aware of.&lt;/p&gt;

&lt;p&gt;Whenever I select a shared hosting plan I review:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Storage Type:&lt;/strong&gt; Some shared hosting plans still come with an HDD for storage. HDD is an older storage method that is significantly slower than SSD technology.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage Amount:&lt;/strong&gt; Ensure that you're purchasing enough space for your project to run today and at a minimum into the immediate future. You don't want to hit your storage limits too quickly - ideally never (if possible).Filling up your storage allotment can cause your website to perform poorly, or become inaccessible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility:&lt;/strong&gt; You need to ensure that your website will run on the OS installed by the hosting provider and that you have access to the configuration options you need. For example, if your website requires node.js and the shared hosting you've selected doesn't support it, then your project won't work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unlisted Specs &amp;amp; Limitations:&lt;/strong&gt; Some hosting plans don't clearly state everything that you need to know. For example, I've been hit by a mailbox size limitation that wasn't listed in the original purchase order - it was instead buried in the hosting provider's blog. Maybe your project needs a particular amount of memory to run, or you're worried that it may need more CPU power than shared hosting can provide. To alleviate these concerns, I contact the hosting provider's support and/or sales team to discuss my project and its requirements. Sometimes they'll notice that your project can't run on their shared hosting plan, or maybe that you should upgrade to a higher tier to get access to more memory, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fve6gh68lchycqcz5xped.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fve6gh68lchycqcz5xped.jpg" alt="Pricing chart for shared hosting from WHC" width="800" height="626"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Screenshot from &lt;a href="https://whc.ca/" rel="noopener noreferrer"&gt;Web Hosting Canada&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Using node.js with shared hosting
&lt;/h2&gt;

&lt;p&gt;Node.js is a popular tool for building websites and web apps, but it is typically barred from using shared hosting because in order to install and configure Node.js, you typically need more access than what is provided with most shared hosting plans. Many traditional web hosts will recommend using their VPS or dedicated hosting plans in order to install Node.js, but unfortunately, these hosting types are considerably more expensive than shared.&lt;/p&gt;

&lt;p&gt;Luckily as Node.js matures, traditional web hosts are taking notice and some are starting to offer the ability to install and configure Node.js apps on their shared hosting services. Two such hosting providers are &lt;a href="https://www.a2hosting.com/kb/cpanel/cpanel-software/create-application-with-nodejs-selector/" rel="noopener noreferrer"&gt;A2 Hosting&lt;/a&gt; and &lt;a href="https://www.inmotionhosting.com/support/edu/cpanel/setup-node-js-app/" rel="noopener noreferrer"&gt;InMotion Hosting&lt;/a&gt;, both provide a GUI tool within the cPanel that they give their customers access to.&lt;/p&gt;




&lt;h2&gt;
  
  
  Related Podcast Episode
&lt;/h2&gt;

&lt;p&gt;If you're interested in learning more about different types of hosting including shared, VPS, dedicated, and WordPress then you might be interested our podcast episode entitled "What Type of Hosting Should You Use? (Shared, VPS, Dedicated, Reseller, WordPress, NodeJS)"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtut3w5wa8a5mlw4ezb7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtut3w5wa8a5mlw4ezb7.png" alt="HTML All The Things Podcast episode 261 thumbnail" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
You can give it a listen &lt;a href="https://www.htmlallthethings.com/podcasts/what-type-of-hosting-should-you-use-shared-vps-dedicated-reseller-wordpress-nodejs" rel="noopener noreferrer"&gt;right here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What Is Shared Hosting? The Ultimate Guide for Beginners (Source: &lt;a href="https://www.dreamhost.com/blog/what-is-shared-hosting/" rel="noopener noreferrer"&gt;Dreamhost&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;How To Create Node.js App With cPanel With Node.js Selector (Source: &lt;a href="https://www.a2hosting.com/nodejs-hosting/" rel="noopener noreferrer"&gt;A2 Hosting&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Shared Hosting for Fast &amp;amp; Secure Websites (Source: &lt;a href="https://www.inmotionhosting.com/shared-hosting" rel="noopener noreferrer"&gt;InMotion Hosting&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Header/OpenGraph image created with &lt;a href="https://www.bing.com/create" rel="noopener noreferrer"&gt;Bing Image Creator&lt;/a&gt; and &lt;a href="https://www.canva.com/" rel="noopener noreferrer"&gt;Canva&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webhosting</category>
      <category>webdev</category>
      <category>node</category>
      <category>sharedhosting</category>
    </item>
    <item>
      <title>CSS Variables – What Are They &amp; How to Use Them</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Tue, 22 Nov 2022 13:40:00 +0000</pubDate>
      <link>https://dev.to/mattlawrence/css-variables-what-are-they-how-to-use-them-ok9</link>
      <guid>https://dev.to/mattlawrence/css-variables-what-are-they-how-to-use-them-ok9</guid>
      <description>&lt;h1&gt;
  
  
  What Is a CSS Variable?
&lt;/h1&gt;

&lt;p&gt;CSS custom properties are often referred to as CSS variables. They allow you to set and store values within them for use throughout your stylesheet(s). For example, you could have a primary-color variable that is set to the hex value of red (#FF0000).&lt;/p&gt;

&lt;h1&gt;
  
  
  What Are CSS Variables Used for?
&lt;/h1&gt;

&lt;p&gt;CSS variables allow you to use a value throughout your stylesheet without the need for typing it in repeatedly. Modifying the value of a variable updates all the places in your stylesheet where the variable was used, preventing the need to go back and edit several instances of the same value in the future.*&lt;/p&gt;

&lt;p&gt;For example, if the primary color of your website is red (#FF0000), then you'd have several places throughout your CSS that would need to be set to #FF0000. If, in the future, the primary color of the website was to change to blue (#0000FF), you'd have to go through your stylesheet and update every instance where red was used, manually. With CSS variables you'd only have to change the variable's value for it to update throughout the stylesheet.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;There are some exceptions to this, especially when a variable's value is set in multiple locations. Example 3 below covers this in more detail.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How to Set Up and Use a CSS Variable
&lt;/h1&gt;

&lt;p&gt;Like other programming languages, CSS variables need to be declared with a valid name and an appropriate value before they can be used. Once declared their value can be called upon by using the var() function throughout the scope (global or local) in which the variable was declared. CSS variables can be declared both globally and locally as needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Global Versus Local CSS Variables
&lt;/h2&gt;

&lt;p&gt;A CSS global variable is declared such that it can be used throughout your styles, this includes the stylesheet in which the variable was declared, but also other stylesheets (other files) as well. An example of this can be found on &lt;a href="https://stackoverflow.com/questions/45581135/are-css-custom-properties-global-across-linked-css-documents" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;. As for a local variable, they're declared on a smaller scope than global, commonly on a specific class, or ID. The variable cannot be used outside the local scope in which it was declared.&lt;/p&gt;

&lt;p&gt;The image below shows an example of how a local CSS variable works.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The variable &lt;em&gt;primary-color&lt;/em&gt; is set to red and is declared locally on the featured class.&lt;/li&gt;
&lt;li&gt;The color property is then set to the value of &lt;em&gt;primary-color&lt;/em&gt; on all paragraphs (p elements).&lt;/li&gt;
&lt;li&gt;The output shows, that the red color is exclusively applied to the paragraphs that are contained by the div with the &lt;em&gt;featured&lt;/em&gt; class and not any other paragraphs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3p0n0ggm2he5qoz7vu4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3p0n0ggm2he5qoz7vu4.jpg" alt="3 Paragraph CodePen Example" width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you're a little confused by this example, don't worry, we have more explanations and three detailed examples still coming up!&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How to Declare a CSS Variable
&lt;/h1&gt;

&lt;p&gt;CSS variables are declared by using two dashes (--) followed by a valid variable name. Remember, they can be declared both globally and locally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvia0khvya0iaz5d3721.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvia0khvya0iaz5d3721.png" alt="CSS variable declartion" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Valid CSS Variable Names
&lt;/h2&gt;

&lt;p&gt;CSS variable names can contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;alphanumeric characters&lt;/li&gt;
&lt;li&gt;dashes&lt;/li&gt;
&lt;li&gt;underscores&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see an example of the same "primary color" variable declared with variety of character configurations in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2gig4hvslg6sfgy7hp7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2gig4hvslg6sfgy7hp7m.png" alt="Valid CSS variable names" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Declare a CSS Variable Globally
&lt;/h2&gt;

&lt;p&gt;To declare a CSS variable globally, we use the :root pseudo-class. Since we are working with HTML, the :root pseudo-class applies to the HTML element, and therefore globally throughout our page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78hb9l313k9z635xged9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78hb9l313k9z635xged9.png" alt="Declare global CSS variable" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Declare a CSS Variable Locally
&lt;/h2&gt;

&lt;p&gt;To declare a CSS variable locally, we declare the variable in a desired scope - like a class, or an ID. Once delcared locally, the variable can only be used within that scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foyup4v9e42v34lbp3959.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foyup4v9e42v34lbp3959.png" alt="Declare local CSS variable" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use a CSS Variable
&lt;/h2&gt;

&lt;p&gt;To use a CSS variable in your stylesheet, you need to use the var() function. The var() function inserts the variable's value wherever it is used. Simply enter the variable name between the brackets like so, var(--variablename). Remember you need to declare your variable before using it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l994k1edcg0y3hgqtmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l994k1edcg0y3hgqtmt.png" alt="CSS Var Function" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  CSS Variable Examples
&lt;/h1&gt;

&lt;p&gt;Below are some detailed examples of how global and local CSS variables work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1 - The Global Scope
&lt;/h2&gt;

&lt;p&gt;In this example, you can see that we've globally declared the red-text variable and then applied it's value to the color property, which is being applied to all paragraph elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqvk6hiwcp0dqebm1rhyv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqvk6hiwcp0dqebm1rhyv.jpg" alt="Example 1 CodePen" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the image above, all the paragraphs have red text because the red-text variable was declared globally and applied to all paragraphs. Remember that global variables can be used throughout your CSS stylesheets, this includes across multiple files (ie variables.css, styles.css, etc.).&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 1 Breakdown
&lt;/h3&gt;

&lt;p&gt;In our HTML we have two paragraph elements...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Paragraph 1 is contained within a div that has the &lt;em&gt;featured&lt;/em&gt; class applied to it.&lt;/li&gt;
&lt;li&gt;Paragraph 2 is NOT contained within the div with the &lt;em&gt;featured&lt;/em&gt; class&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffz5lfp02boh00swpews6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffz5lfp02boh00swpews6.png" alt="Example 1 HTML" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our CSS we have three aspects to focus on...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;em&gt;red-text&lt;/em&gt; variable is being declared on the &lt;em&gt;:root&lt;/em&gt; pseudo-class (which is the same as declaring it on the HTML element)&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;color&lt;/em&gt; property is being set to the value of the red-text variable&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;color&lt;/em&gt; property mentioned above is being applied to all paragraphs (p tags) in the HTML&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi7mt2c984lqkyqe2lty7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi7mt2c984lqkyqe2lty7.png" alt="Example 1 CSS" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our output/webpage we can see that both Paragraph 1 and Paragraph 2 have red text. Despite Paragraph 1 being contained within a div, and Paragraph 2 being a direct child of the HTML element, the value of the &lt;em&gt;red-text&lt;/em&gt; variable applies. The red-text variable is global and therefore applies not just to direct children of the HTML element, but throughout other scopes that may be present - like the &lt;em&gt;featured&lt;/em&gt; class scope that Paragraph 1 finds itself in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylszoq51yantdyhl8oqb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylszoq51yantdyhl8oqb.jpg" alt="Example 1 Output" width="557" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 2 - The Local Scope
&lt;/h2&gt;

&lt;p&gt;In this example, you can see that we've locally declared the &lt;em&gt;red-text&lt;/em&gt; variable on the &lt;em&gt;featured&lt;/em&gt; class. This means that the value of &lt;em&gt;red-text&lt;/em&gt; can only be applied to elements that are within the scope of the &lt;em&gt;featured&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fey2i5hamt7cc1uaqh36k.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fey2i5hamt7cc1uaqh36k.jpg" alt="Example 2 CodePen" width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see above, we have a div and two paragraphs. The div has the &lt;em&gt;featured&lt;/em&gt; class applied to it. In our CSS we're applying the &lt;em&gt;red-text&lt;/em&gt; variable to the color property on all paragraphs, but the second paragraph's text did not change color. This is because the second paragraph is not within the scope of the &lt;em&gt;featured&lt;/em&gt; class.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 2 Breakdown
&lt;/h3&gt;

&lt;p&gt;In our HTML we have two aspects to focus on...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Paragraph 1 is contained within a div that has the &lt;em&gt;featured&lt;/em&gt; class applied to it&lt;/li&gt;
&lt;li&gt;Paragraph 2 is NOT contained within the div with the &lt;em&gt;featured&lt;/em&gt; class&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F474j5z3xo8ydzzhw02gz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F474j5z3xo8ydzzhw02gz.png" alt="Example 2 HTML" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our CSS we have three aspects to focus on...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;em&gt;red-text&lt;/em&gt; variable is being declared on the &lt;em&gt;featured&lt;/em&gt; class&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;color&lt;/em&gt; property is being set to the value of the &lt;em&gt;red-text&lt;/em&gt; variable&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;color&lt;/em&gt; property mentioned above is being applied to all paragraphs (p tags) in the HTML&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjh8znwxs08ij0kcz7vdv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjh8znwxs08ij0kcz7vdv.png" alt="Example 2 CSS" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our output/webpage, we can see that only Paragraph 1 is showing red text, when in fact we've applied the &lt;em&gt;red-text&lt;/em&gt; variable's value to the color property on all paragraph HTML elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft5ytcbzz5h1xmk3xgz6q.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft5ytcbzz5h1xmk3xgz6q.jpg" alt="Example 2 Output" width="581" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reason Paragraph 2 does not have red text, is because we've declared the &lt;em&gt;red-text&lt;/em&gt; variable locally, on the &lt;em&gt;featured&lt;/em&gt; class's scope. Paragraph 2 falls outside of this scope and therefore the value of the &lt;em&gt;red-text&lt;/em&gt; variable does not apply.&lt;/p&gt;

&lt;p&gt;Let's build on what we've learned here with Example 3 below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 3 - Local &amp;amp; Global
&lt;/h2&gt;

&lt;p&gt;In this example we're going to combine the use of both globally and locally declared variables at the same time, with a bit of a twist - we'll be declaring the same variable twice, in both the local and global scopes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb1f82zbg6gk8d2n94633.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb1f82zbg6gk8d2n94633.jpg" alt="Example 3 CodePen" width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see above, we've declared two variables, in three different instances:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;text-color&lt;/em&gt; is declared globally and is set to the hex value &lt;em&gt;#FF0000&lt;/em&gt; (red)&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;text-size&lt;/em&gt; is declared globally and is set to &lt;em&gt;25px&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;text-color&lt;/em&gt; is declared again, locally under the scope of the featured class, set to the hex value &lt;em&gt;#0000FF&lt;/em&gt; (blue)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final result is that Paragraph 1 has blue text, from the locally declared version of the text-color variable. Paragraph 1 also has larger text than Paragraph 2, because its font-size is being set to 25px by the &lt;em&gt;text-size&lt;/em&gt; variable. Paragraph 2 has blue text because its color property is being set by the globally declared version of the text-color variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 3 Breakdown
&lt;/h3&gt;

&lt;p&gt;Just like Example 2, in our HTML we have two aspects to focus on...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Paragraph 1 is contained within a div that has the &lt;em&gt;featured&lt;/em&gt; class applied to it.&lt;/li&gt;
&lt;li&gt;Paragraph 2 is NOT contained within the div with the &lt;em&gt;featured&lt;/em&gt; class&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fix5t8tp854rdms5lx1cx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fix5t8tp854rdms5lx1cx.png" alt="Example 3 HTML" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the CSS we have a few aspects to focus on...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;text-color&lt;/em&gt; is declared globally as the color red&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;text-size&lt;/em&gt; is declared globally as the value 25px&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;text-color&lt;/em&gt; is declared again, but locally this time as the color blue&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F966guxbn6zm4quljpsah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F966guxbn6zm4quljpsah.png" alt="Example 3 CSS" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, our output/webpage for this example displays as you can see in the image below. Paragraph 1 is larger and is blue, while Paragraph 2 is the default font size and is red.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6p1gu9qw86f6rkpdsmp8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6p1gu9qw86f6rkpdsmp8.jpg" alt="Example 3 Output" width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's break down this output piece-by-piece:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Paragraph 1&lt;/strong&gt; is larger than the default font size due to the &lt;em&gt;text-size&lt;/em&gt; variable being applied to the featured class&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Paragraph 2&lt;/strong&gt; is red because the value of the &lt;em&gt;text-color&lt;/em&gt; global variable is being applied to all paragraphs&lt;/li&gt;
&lt;li&gt;Despite &lt;em&gt;text-color&lt;/em&gt; being applied to all paragraphs, &lt;strong&gt;Paragraph 1&lt;/strong&gt; is not red, instead it shows up as blue. This is because we've declared the &lt;em&gt;text-color&lt;/em&gt; variable again locally in our CSS on the &lt;em&gt;featured&lt;/em&gt; class. The local declaration is more specific to Paragraph 1 than the global declaration, and therefore the local declaration wins out. You can read a little more about cascading and specificity with variables in &lt;a href="https://dev.to/nirazanbasnet/understanding-css-variables-4cj0"&gt;this DEV article&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Theming a Website With CSS Variables
&lt;/h1&gt;

&lt;p&gt;In this article we focused on CSS variable basics, but I think it's important to showcase some real-world applications of CSS variables so that you can see them in a more practical setting. One of the most common real-world uses for CSS variables is theming a website with a different colour scheme based on a set of parameters, such as toggling between a light and dark mode.&lt;/p&gt;

&lt;p&gt;Toggling between dark and light modes is a popular option for a lot of software out there, including websites and web apps. Using CSS variables alongside additional HTML, CSS, and JS, you can put together a practical theme switcher. &lt;a href="https://dev.to/ananyaneogi"&gt;Ananya Neogi&lt;/a&gt; was able to make a dark/light mode toggle switch - detailed guide in this article: &lt;a href="https://dev.to/ananyaneogi/create-a-dark-light-mode-switch-with-css-variables-34l8"&gt;Create A Dark/Light Mode Switch with CSS Variables&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, Praveen on the Tech Inscribed blog, has a guide for making a theme selector with a focus on a light/dark theme in this guide: &lt;a href="https://techinscribed.com/multiple-themes-using-css-variables/" rel="noopener noreferrer"&gt;Developing Websites with Multiple Themes using CSS Variables&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Sources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Free CSS variables course (&lt;a href="https://scrimba.com/learn/cssvariables" rel="noopener noreferrer"&gt;Scrimba&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Using CSS custom properties (variables) (&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties" rel="noopener noreferrer"&gt;MDN Docs&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;CSS Variables - The var() Function (&lt;a href="https://www.w3schools.com/css/css3_variables.asp" rel="noopener noreferrer"&gt;W3Schools&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Understanding CSS Variables (&lt;a href="https://dev.to/nirazanbasnet/understanding-css-variables-4cj0"&gt;DEV&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Working from Home</title>
      <dc:creator>Matt Lawrence ☕</dc:creator>
      <pubDate>Tue, 17 Mar 2020 00:29:03 +0000</pubDate>
      <link>https://dev.to/mattlawrence/working-from-home-21df</link>
      <guid>https://dev.to/mattlawrence/working-from-home-21df</guid>
      <description>&lt;p&gt;If you’re new to working from home, then you’re probably a little nervous about how it’s all going to work out. How will you be productive without your team members next to you? How are you going to avoid all those distractions at home? Will you be able to get all your work done? With the sad development of coronavirus (COVID-19) ravaging through many countries worldwide, many companies and individuals have made the choice to close the office in favour of remote work. While most programmers and technical staff are used to some sort of working from home scenario, there are a lot of us that are being torn from our comfort zone of commuting to the office and chatting at the water cooler. As an entrepreneur, I’ve been working from home for the past ~5 years, and while I used to work in an office prior to opening my own business, I’m happy to report that you can be super productive with just some adapting. So, let’s address some of the most common questions…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How will you be productive without your team members next to you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the most common gripes I hear about remote work is that you don’t have the convenience of tapping on your colleague’s shoulder to ask a question. While this is true, we have the next best thing – chatting apps. Whether it be Slack, or WhatsApp, or whatever solution your workplace uses, chatting apps are more than just a tool to keep in touch when you’re out of your normal working hours. &lt;br&gt;
Let’s take a common scenario for a web developer. You receive an AdobeXD prototype from the design team and you’re tasked with creating a client’s website from it. You start coding away and suddenly you realize – Is that a slider from left-to-right? Or does it just fade through the images in place? &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ideal Office Solution&lt;/em&gt;&lt;br&gt;
You get up from your desk, walk over to the designer’s desk and ask them how the slider works. You then take that information, go back to your desk and continue developing away. But…this isn’t the utopia of offices and it’s hardly ever this easy…&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Typical Office Solution&lt;/em&gt;&lt;br&gt;
You get up from your desk, walk over to the designer’s desk and they’re not there. So you ask one of their team members and they say something like “Oh they left a little while ago, they’ll probably be back in a few minutes” Since you’ve got a few minutes to spare, you’ll probably end up chatting with that team member for 10 minutes before realizing the designer you came to speak to isn’t back yet – so you go back to your desk and send them a message (email or otherwise) asking for information. In this scenario you not only wasted time walking over, but you also wasted yours and your colleague’s time chatting while waiting for someone that might be gone for hours.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Working from Home Solution&lt;/em&gt;&lt;br&gt;
You send a message (email or otherwise) to the designer asking them for additional details and then begin work on another portion of the page while you wait for the designer to respond. You’re not only saving the time it took to walk over to your colleague’s desk (which is minimal I know), but you’re also saving yourself from potential distraction of chatting with one of their team, or another colleague you might bump into.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How are you going to avoid all those distractions at home?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’re like most people, then your home is designed to distract you after a long day of work. It’s the place where you might play some Xbox, watch a little Netflix, hangout in the workshop, or even take a nap on the couch. As a result, many new remote workers are often worried about their own ability to set these distractions aside and get some work done. Not everyone’s work ethic or discipline is iron clad, and it’s just too easy to lay down after lunch for a nap. &lt;/p&gt;

&lt;p&gt;Luckily though, and I’m a bit of an outlier in this regard, I actually don’t think you should fight these distractions too much. As discussed in the episode “&lt;a href="https://htmlallthethings.com/Podcast/5e6bd9c56a070d0011eb65a7" rel="noopener noreferrer"&gt;What We Need to Do Better&lt;/a&gt;” of the &lt;a href="https://podcast.htmlallthethings.com/" rel="noopener noreferrer"&gt;HTML All The Things Podcast&lt;/a&gt;, I mentioned that instead of fighting off my distractions all the time, I indulge them – within reason. If I’m really not into the work I’m about to do and I’d rather watch something, I’ll pull up some Netflix, throw it onto my second monitor and then continue to work and watch. Slowly but surely, I get into what I’m working on and the Netflix becomes a distraction, so I pause it. This also works when I start getting worked up about something, when I get anxious, I take a brief video break, and slowly head back into the work. The key is not doing something that you know will pull your attention away for hours, or that’s too involved. If you like to build things for a hobby, you shouldn’t “take a brief break” and build an entire table – that’s not going to work. However, if you’re really itching to get back into the workshop, maybe you can start drafting up some plans for a new project, or finish sanding a section of a work in progress. If you’re like me, you’ll eventually start feeling guilty about stepping away from the computer, so you’ll sit back down refreshed and ready to get back to work. I believe it’s unrealistic that humans won’t be distracted in this day and age between our smartphones delivering hundreds of push notifications, to news reports piling in, and just the everyday workplace stress level – we’ll inevitably want to step away and do something else. Get it out of your system, then get back to work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Will you be able to get all your work done?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Speaking generally, this relies on you not your environment. Some people work better with a lot of background noise and goings-on that happen in an office, while others need silence to focus - everyone is different. While a lot of remote workers will tell you to work in a café, you might be hesitant due to the climate (coronavirus). Assuming you’re staying in you can do a few things to help you get the environment you need.&lt;/p&gt;

&lt;p&gt;If you need a quiet environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding a quiet room in solidarity might do the trick&lt;/li&gt;
&lt;li&gt;If your home is noisy, then grabbing some ear plugs – or even noise cancelling headphones with nothing playing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need a noisy environment: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playing a podcast, or a TV show that you’ve seen before (so you mostly listen to the audio)&lt;/li&gt;
&lt;li&gt;Having a fan, or other white noise playing&lt;/li&gt;
&lt;li&gt;Utilizing a variety of different “Focus” playlists that can be found on Spotify and other music streaming services&lt;/li&gt;
&lt;li&gt;Moving from a quiet study, or home office, into the one of the more lived in areas of your home like a kitchen or living room&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If all else fails:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you’re a person that really needs that office environment and you’re not allowed to go in, you could always utilize something like a co-working space. Co-working spaces are offices that you can rent a space in for a day/week/month sometimes even just a few hours. They’re generally filled with a bunch of different businesses all doing different things, but together they generate the same sort of typical office environment you’d probably expect. Again, however, these co-working spaces can be crowded and with the current COVID-19 situation you’ll probably want to try and stay home as much as possible.&lt;/li&gt;
&lt;li&gt;Force yourself to adapt – yeah, I know it sucks – But at the end of the day you’ll eventually get used to working in your home office. It might take a couple days before your productivity starts to improve, but if you stick with it, you’ll eventually find the home environment that’s right for you. It’s important to not focus on how uncomfortable you are working from home, how much you want to work in the office, or how unproductive you are. Just sit down and keep at it, it’s just like a new job, you get overwhelmed the first few days or weeks, but slowly you learn little tricks and adaptations that get you through the workdays with ease.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This article is also available on &lt;a href="https://medium.com/html-all-the-things/working-from-home-d722c3eff293?source=friends_link&amp;amp;sk=30a5be90a05e42e12bb2e6e1f59390d0" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>remoteworking</category>
      <category>workfromhome</category>
      <category>coronavirus</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
