<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>CSS &#8211; Tips for your Website</title>
	<atom:link href="https://tipsforyourwebsite.com/category/technical-stuff/css/feed/" rel="self" type="application/rss+xml" />
	<link>https://tipsforyourwebsite.com</link>
	<description>Tips for websites success</description>
	<lastBuildDate>Tue, 28 Jun 2022 01:40:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.2</generator>
	<item>
		<title>CSS font sizes overview</title>
		<link>https://tipsforyourwebsite.com/css-font-sizes-overview/</link>
		
		<dc:creator><![CDATA[uacit]]></dc:creator>
		<pubDate>Tue, 28 Jun 2022 01:40:45 +0000</pubDate>
				<category><![CDATA[Beginners]]></category>
		<category><![CDATA[CSS]]></category>
		<guid isPermaLink="false">https://tipsforyourwebsite.com/?p=529</guid>

					<description><![CDATA[px vs em vs rem In print copy we use pt for font sizes because usually we want a &#8220;fixed&#8221; size because it is going to be printed out on a piece of paper that we have specified the size of. And in a similar fashion px, are fixed not relative sizes and it means [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">px vs em vs rem</h1>



<p>In print copy we use pt for font sizes because usually we want a &#8220;fixed&#8221; size because it is going to be printed out on a piece of paper that we have specified the size of.  And in a similar fashion px, are fixed not relative sizes and  it means that we have hardcoded the font-size to all of the users of the text on our webpage. This means that no matter whether our users are on a phone, desktop computer or tablet the font size will be exactly the same. Which will more than likely mean the font size will be tiny on a phone device. The end device can&#8217;t change the value so if they have set their device to show text at a large size you have said no way I know better and I&#8217;m not letting you.</p>



<h2 class="wp-block-heading">So what is the CSS font best practice or solution? <br>REM and EM</h2>



<p>Rem and Em is a relative unit that many developers use to preserve accessibility.</p>



<blockquote class="wp-block-quote"><p>Rem (root em) stands for &#8220;root element&#8217;s font-size&#8221;</p></blockquote>



<p>If the default root font-size is <code>12px</code>. So, if we see a font-size that is 1rem, we are looking at 12px but if a user has set their default root size to be 18px then our 1rem will be 18px not 12px.</p>



<p>Because Rem means root element&#8217;s font-size, we can also override the default value by using CSS like this:</p>



<pre class="wp-block-code"><code>:root {
  font-size: 20px;
}
</code></pre>



<p>So now you have changed the root font-size, now <code>1rem = 20px</code></p>



<h3 class="wp-block-heading">What if we want to use values on our pages other that  other than 18px?</h3>



<p>We can get the rem value of a pixels by using decimal options to go up or down sizes. For example, if we want to use a larger font-size we will write <code>font-size: 1.25rem</code>. And if we want a smaller font size we use 0.8rem</p>



<h3 class="wp-block-heading">But it&#8217;s so annoying ?!</h3>



<p>Yep, using rem will make the development process longer because we need to calculate the rem value. But this gives some freedom to the user, and we are not messing with the accessibility.</p>



<h2 class="wp-block-heading">So how do em works?</h2>



<blockquote class="wp-block-quote"><p>Em stands for &#8220;parent element&#8217;s font-size&#8221;</p></blockquote>



<p>Because css is cascading and support inheritance then em will inherit font-size value from the parent element. For example, we have a parent div, and p tag inside:</p>



<pre class="wp-block-code"><code>&lt;div>
  &lt;p>hello work &lt;/p>
&lt;/div>

&lt;style>
  div {
    font-size: 0.5rem; // 8px
  }

  p {
    font-size: 1em; // ??px
  }
&lt;/style>
</code></pre>



<p>Because <code>p</code> inherit the parent element&#8217;s font-size, so <code>1em = 8px</code>. This means, that the <code>p</code> will have <code>font-size: 8px</code>.</p>



<p>You can read more on <a rel="noreferrer noopener" href="https://www.w3schools.com/css/css_font_size.asp" target="_blank">W3Cschools site</a></p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
