<?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: Duck Programmer</title>
    <description>The latest articles on DEV Community by Duck Programmer (@duck_programmer).</description>
    <link>https://dev.to/duck_programmer</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%2F454572%2F43b1f6b8-bebb-4594-b09f-abe5e01bd595.jpg</url>
      <title>DEV Community: Duck Programmer</title>
      <link>https://dev.to/duck_programmer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/duck_programmer"/>
    <language>en</language>
    <item>
      <title>Can You Explain the Difference among Image File Formats like JPG, PNG, GIF, TIF and BMP?</title>
      <dc:creator>Duck Programmer</dc:creator>
      <pubDate>Thu, 03 Sep 2020 08:57:52 +0000</pubDate>
      <link>https://dev.to/duck_programmer/can-you-explain-the-difference-among-image-file-formats-like-jpg-png-gif-tif-and-bmp-5epf</link>
      <guid>https://dev.to/duck_programmer/can-you-explain-the-difference-among-image-file-formats-like-jpg-png-gif-tif-and-bmp-5epf</guid>
      <description>&lt;h2&gt;
  
  
  JPG/JPEG
&lt;/h2&gt;

&lt;p&gt;JPEG stands for &lt;strong&gt;Joint Photographic Experts Group&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference between JPG and JPEG
&lt;/h3&gt;

&lt;p&gt;You may have seen two types of extension, &lt;strong&gt;.jpg&lt;/strong&gt; and &lt;strong&gt;.jpeg&lt;/strong&gt;. In fact, there is no difference in functionality between the two, just a difference in the extensions. That's because MS-DOS, which is a OS widely used in the 1980s, has a restriction on file extensions of up to 3 characters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;p&gt;It is a format for compressing image files. Its way of compressing is a little complicated and is &lt;strong&gt;lossy compression&lt;/strong&gt; so you can't restore the image to its original state. If you want to know its compression algorithm, click &lt;a href="https://medium.com/breaktheloop/jpeg-compression-algorithm-969af03773da" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;br&gt;
24-bit color depth is mostly used. 24-bit color is a method of expressing about 16.7 million different colors by assigning 8 bits, or 256 shades, to each of red, blue and green.&lt;br&gt;
You can use jpeg format on web. But its background cannot be transparent. &lt;/p&gt;

&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;Digital cameras often use jpeg format for their photos. It is suitable for &lt;strong&gt;phots&lt;/strong&gt;. It's not suitable for images with a few colors because of its compression algorithm. Also, it is used on web because of its high compression rate.&lt;/p&gt;

&lt;h2&gt;
  
  
  PNG
&lt;/h2&gt;

&lt;p&gt;PNG stands for &lt;strong&gt;Portable Network Graphics&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;p&gt;It is a format for compressing image files. Its way of compressing is very simple so I'm going to explain the algorithm in next header. You can restore the image to its original state.&lt;br&gt;
24-bit color depth is mostly used.&lt;br&gt;
You can use png format on web. Also, its background can be &lt;strong&gt;transparent&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Compression Algorithm
&lt;/h3&gt;

&lt;p&gt;In a image, there are always a lot of pixels that are the same color, pixel by pixel. So instead of storing each pixel data, you can store data like the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FBXP7AgH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FBXP7AgH.png" alt="comp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mostly, its compression rate is lower than jpeg.&lt;/p&gt;

&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;If you want the background of your image &lt;strong&gt;transparent&lt;/strong&gt;, it's the only choice. It is suitable on web. &lt;/p&gt;

&lt;h2&gt;
  
  
  GIF
&lt;/h2&gt;

&lt;p&gt;GIF stands for &lt;strong&gt;Graphics Interchange Format&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;p&gt;It is a format for compressing image files. Its way of compressing is called &lt;strong&gt;LZW compression&lt;/strong&gt;. If you want to learn LZW compression algorithm, click &lt;a href="https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Using its algorithm, You can restore the image to its original state.&lt;br&gt;
8-bit color depth is used. So the data size is small.&lt;br&gt;
You can use gif format on web. &lt;br&gt;
You can use gif for &lt;strong&gt;animation&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;It is suitable for images with a small number of colors, like &lt;strong&gt;logos&lt;/strong&gt; and &lt;strong&gt;illustrations&lt;/strong&gt;. It's good on web. Also, if you want to save easy animation for a small size, it's a choice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extra Talk
&lt;/h3&gt;

&lt;p&gt;There's been a debate whether the pronunciation is "gif" or "jif" over years. If you have an interest, click &lt;a href="https://time.com/5791028/how-to-pronounce-gif/" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see the history.&lt;/p&gt;

&lt;h2&gt;
  
  
  TIF/TIFF
&lt;/h2&gt;

&lt;p&gt;TIFF stands for &lt;strong&gt;Tag Image File Format&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference between TIF and TIFF
&lt;/h3&gt;

&lt;p&gt;It is the same reason as jpg/jpeg.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;p&gt;It is basically &lt;strong&gt;uncompressed&lt;/strong&gt; format. 24-bit color depth is mostly used. You can't use tiff format on web. &lt;/p&gt;

&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;Digital cameras often use tiff format for their &lt;strong&gt;photos&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  BMP
&lt;/h2&gt;

&lt;p&gt;BMP stands for &lt;strong&gt;bitmap&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Characteristics
&lt;/h3&gt;

&lt;p&gt;It is basically &lt;strong&gt;uncompressed&lt;/strong&gt; format. 24-bit color depth is mostly used. You can't use bmp format on web.&lt;/p&gt;

&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;When you want a high resolution image and you don't care the file size, it can be an option. Or, when you want to render or edit an image by programming, it can be one of the easiest formats. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>image</category>
    </item>
    <item>
      <title>Surprising Facts about  How Browsers Interpret CSS</title>
      <dc:creator>Duck Programmer</dc:creator>
      <pubDate>Sun, 30 Aug 2020 06:34:54 +0000</pubDate>
      <link>https://dev.to/duck_programmer/surprising-facts-about-how-browsers-interpret-css-54nf</link>
      <guid>https://dev.to/duck_programmer/surprising-facts-about-how-browsers-interpret-css-54nf</guid>
      <description>&lt;p&gt;First, Let me get straight to the point, browsers match css selectors from right to left. If you already know, you don't need to keep reading. If not, please go ahead. &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrong Idea
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.sample&lt;/span&gt; &lt;span class="nt"&gt;table&lt;/span&gt; &lt;span class="nt"&gt;td&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you see the above code, browsers interpret abd execute it in the following order.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the sample class&lt;/li&gt;
&lt;li&gt;Find the table element of descendants of 1.&lt;/li&gt;
&lt;li&gt;Find the td elements of descendants of 2.&lt;/li&gt;
&lt;li&gt;Make the text color red.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you don't think this order seems wrong, maybe you should keep reading this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Correct Idea
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.sample&lt;/span&gt; &lt;span class="nt"&gt;table&lt;/span&gt; &lt;span class="nt"&gt;td&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you see the above code, browsers interpret and execute it in the following order.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find all td elements&lt;/li&gt;
&lt;li&gt;Check if the table element is present in the ancestor element of 1.&lt;/li&gt;
&lt;li&gt;Check if the sample class exists in the ancestor element of the table element in 2.&lt;/li&gt;
&lt;li&gt;Make the text color red.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CSS selectors are collated from right to left like the above order.&lt;br&gt;
The rightmost selector is called "key selector".&lt;br&gt;
This means that if you specify a selector with a large range of applicability for the key selector, it will likely take a long time to match it.&lt;/p&gt;
&lt;h2&gt;
  
  
  What's the Problem
&lt;/h2&gt;

&lt;p&gt;Let's say you wrote the code below. &lt;/p&gt;

&lt;p&gt;It will first find all td elements in the DOM, and then it will try to confirm the existence of the table element and the sample class.&lt;br&gt;
Since the text color of the table under the sample2 class remains black, there is no need to find the td elements under the sample2 class.&lt;br&gt;
This is an obvious &lt;strong&gt;waste of cost&lt;/strong&gt;.&lt;br&gt;
If the number of td elements under the sample2 class increases, it may lead to &lt;strong&gt;performance problems&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&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;"sample"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&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;"sample2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Balck&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt; 
    &lt;span class="nc"&gt;.sample&lt;/span&gt; &lt;span class="nt"&gt;table&lt;/span&gt; &lt;span class="nt"&gt;td&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="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So, in this case, it's better to give a red class only to the cells where you want the text color to be red like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&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;"sample"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;red&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&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;"sample2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;black&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt; 
    &lt;span class="nc"&gt;.red&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="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Why Does Your Website Look Different In Different Browsers?</title>
      <dc:creator>Duck Programmer</dc:creator>
      <pubDate>Sun, 23 Aug 2020 07:00:40 +0000</pubDate>
      <link>https://dev.to/duck_programmer/why-does-your-website-look-different-in-different-browsers-283e</link>
      <guid>https://dev.to/duck_programmer/why-does-your-website-look-different-in-different-browsers-283e</guid>
      <description>&lt;h2&gt;
  
  
  The Role of Browser
&lt;/h2&gt;

&lt;p&gt;The main function of a browser is to present the user's selected web resources, such as html documents, pdfs, images and so on, by requesting the server to display them in a browser window.&lt;br&gt;
For some documents like html, css need to be interpreted by the rendering engine in the browser.&lt;/p&gt;
&lt;h2&gt;
  
  
  Reason of Difference
&lt;/h2&gt;

&lt;p&gt;Different browsers have different &lt;strong&gt;rendering engines&lt;/strong&gt; and often interpret source code like HTML and CSS in slightly different ways, so that website looking can be different or not be displayed properly.&lt;/p&gt;
&lt;h2&gt;
  
  
  Difference in Box
&lt;/h2&gt;

&lt;p&gt;In CSS, each element, such as div, h, p and etc., has a concept of &lt;strong&gt;box&lt;/strong&gt;. A box consists of, from the outside, &lt;strong&gt;margin&lt;/strong&gt;, &lt;strong&gt;border&lt;/strong&gt;, &lt;strong&gt;padding&lt;/strong&gt; and &lt;strong&gt;content&lt;/strong&gt; like text or image.&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;box&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;400px&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;Sometimes you might define the width of the content like above, and &lt;a href="https://en.wikipedia.org/wiki/World_Wide_Web_Consortium" rel="noopener noreferrer"&gt;W3C&lt;/a&gt; box model, which is the the main international standards organization for the World Wide Web, defines the width as &lt;strong&gt;content width&lt;/strong&gt; while the Internet Explorer box model, which is one of the major browser and installed in windows computer since the beginning, defines width as &lt;strong&gt;content + padding + border&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fy6PiO85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fy6PiO85.png" alt="box interpret"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  DOCTYPE
&lt;/h2&gt;

&lt;p&gt;You must have seen the code like below if you have the experience coding html.&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="cp"&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&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="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;DOCTYPE is a declaration of the &lt;strong&gt;DTD&lt;/strong&gt;, which stands for "Document Type Definition" and not an HTML tag.&lt;/p&gt;

&lt;p&gt;HTML is a language based on &lt;strong&gt;SGML&lt;/strong&gt; (Standard Generalized Markup Language) and the DOCTYPE declaration and DTD are derived from SGML.&lt;br&gt;
Many web browsers display documents in different ways such as &lt;strong&gt;standard-compliant mode&lt;/strong&gt; and &lt;strong&gt;compatibility mode&lt;/strong&gt; depending on the presence or absence of the DOCTYPE declaration and its content. This switching of the display method is called &lt;strong&gt;DOCTYPE switch&lt;/strong&gt;. A simple explanation of how the DOCTYPE switch works is that if a DOCTYPE declaration is not placed at the beginning of an HTML sentence, it will be adapted to an older version of the browser's display.&lt;/p&gt;

&lt;p&gt;HTML5 is no longer a language based on SGML. Therefore, unlike the language used up to HTML4, no DTD is required. However, the DOCTYPE declaration itself is still required in HTML5 since the DOCTYPE switch allows the browser to operate in standards-compliant mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fr6ptWxl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fr6ptWxl.png" alt="doctype"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Knowledge
&lt;/h2&gt;

&lt;p&gt;If you want to know more about the browser, click &lt;a href="https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/" rel="noopener noreferrer"&gt;here&lt;/a&gt; to access the best resource that I think.&lt;/p&gt;

&lt;p&gt;If you can't click the text link above, copy and paste the URL below into your internet browser: &lt;br&gt;
&lt;a href="https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/" rel="noopener noreferrer"&gt;https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Let's Be Familiar with Character Encoding</title>
      <dc:creator>Duck Programmer</dc:creator>
      <pubDate>Tue, 18 Aug 2020 07:49:46 +0000</pubDate>
      <link>https://dev.to/duck_programmer/let-s-be-familiar-with-character-encoding-4h70</link>
      <guid>https://dev.to/duck_programmer/let-s-be-familiar-with-character-encoding-4h70</guid>
      <description>&lt;h2&gt;
  
  
  What is "Character Encoding"
&lt;/h2&gt;

&lt;p&gt;A character encoding is a numeric representation of binary numbers so that a computer can handle the characters.&lt;/p&gt;

&lt;p&gt;It is also referred to as the &lt;strong&gt;character set&lt;/strong&gt;, &lt;strong&gt;charset&lt;/strong&gt;, and &lt;strong&gt;character code&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  ASCII (American Standard Code for Information Interchange)
&lt;/h2&gt;

&lt;p&gt;ASCII is one of the Charset which contains Latin alphabets. Since English consists of about 100 characters including not only alphabets but also numbers and other symbols, ASCII is made of 7 bits which can represent 2^7=128 characters. ISO/IEC 646 is the nationalized version of ASCII.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0QM8tndx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/Vc0Paql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0QM8tndx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/Vc0Paql.png" alt="ISO/IEC 646"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8bits Code
&lt;/h2&gt;

&lt;p&gt;The 8bits character code can be divided into the CL, GL, CR and GR areas as shown in the figure below. In CL and GL, the 8th bit is 0; in CR and GR, the 8th bit is 1; C and G mean control and graphical; L and R mean left and right, respectively. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NI1nkOHp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/gYTVSYt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NI1nkOHp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/gYTVSYt.png" alt="ISO/IEC 2022"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ISO/IEC 2022 makes it possible to use different character set by using &lt;strong&gt;Escape Sequence&lt;/strong&gt; to invoke another character set to GL or GR area from buffers. &lt;/p&gt;

&lt;p&gt;Also, in 8bits code, 2 byte character can represent 94x94 or 96x96 characters while keeping extensibility of the ASCII code. It is accomplished by setting ASCII in GL area and 2 byte code in GR area.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unicode
&lt;/h2&gt;

&lt;p&gt;Unicode is a character code based on the idea of putting all the world's characters in one table. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OcMBNea_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/qQ0LIcM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OcMBNea_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/qQ0LIcM.png" alt="What is Unicode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unicode, which is correspondent table from character to code point, is called &lt;strong&gt;Coded Character Set&lt;/strong&gt;, and the one from code point to code such as UTF-8 is called &lt;strong&gt;Character Encoding Scheme&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_VhwRURr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/1FUd2d0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_VhwRURr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/1FUd2d0.png" alt="Structure of Unicode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;UCS-4, which is known as Unicode,  consists of four bytes, which are groups, planes, rows and cells. Groups are from 00 to 7F and planes, rows and cells are from 00 to FF in hexadecimal. Plane00 in Group00 is called BMP (Basic Multilingual Plane) and also known as UCS-2, which is original Unicode. Most of the commonly used letters are included in BMP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---IZHMOnT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/KGmanqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---IZHMOnT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/KGmanqi.png" alt="Combined Character"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the complex structures of unicode is that there are two ways to represent combined characters.&lt;br&gt;
However, there are some exceptions, such as combined emoji, which are only represented using ZWJ (Zero-Width Joiner), a kind of control character, and there's only one way of code to represent the combined emoji.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fg3Fap9l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/1NyebqB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fg3Fap9l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/1NyebqB.png" alt="combined emoji"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  UTF-8
&lt;/h2&gt;

&lt;p&gt;UTF-8 (Unicode Encoding Forms 8) is a variable length encoding scheme whose length varies from 1 to 4 bytes, depending on the value of the code point. It's compatible with ASCII, highly efficient and the most popular encoding scheme.&lt;/p&gt;

&lt;p&gt;The steps encoding by UTF-8 varies depending the range of codepoint. First, divide the code into 1 to 4 parts. And then, add value in the front  to make them bytes. Below is the table which shows what value is added.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bo9UjsqC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/msoo5bX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bo9UjsqC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/msoo5bX.png" alt="UTF-8"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the example to encode U+611F which is represented by 3 bytes.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change it to binary&lt;/li&gt;
&lt;li&gt;Divide it into 4 bits, 6 bits and 6 bits&lt;/li&gt;
&lt;li&gt;Add 11100000, 100000000, 100000000 to each value&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_MFkdT3_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/zwvED3Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_MFkdT3_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/zwvED3Z.png" alt="Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  UTF-16
&lt;/h2&gt;

&lt;p&gt;UTF-16 is an encoding scheme that encodes code point as 16 bits fixed-length data. Non-BMP characters are expressed using &lt;strong&gt;surrogate pairs&lt;/strong&gt;.　The same range as ASCII is not compatible with ASCII because it is also represented by 16 bits.&lt;/p&gt;

&lt;p&gt;Surrogate pairs are a method of handling all code points in 16 bit * 2 pairs since 16 bits are not enough to represent over U+10000 codepoints. There are unused area in BMP which is U+D800 to U+DBFF (1024 bits) and U+DC00 to U+DFFF (1024 bits). Using these pairs to represent 1024 * 1024 = over 1,000,000 characters, which are allocated from U+10000 to U+10FFFF.&lt;/p&gt;

&lt;p&gt;The steps converting from codepoint to surrogate pairs is below.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Subtract U+10000 from the code point&lt;/li&gt;
&lt;li&gt;Change it to 20 bits by making it binary&lt;/li&gt;
&lt;li&gt;Divide it into 10 bits each&lt;/li&gt;
&lt;li&gt;Add U+D800(1101100000000000), U+DC00(1101110000000000) to each value&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hA9OEMGk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/uefclwv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hA9OEMGk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/uefclwv.png" alt="Surrogate pairs"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ascii</category>
      <category>unicode</category>
      <category>utf8</category>
      <category>utf16</category>
    </item>
  </channel>
</rss>
