<?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: Priyanshu</title>
    <description>The latest articles on DEV Community by Priyanshu (@kumar_sons_off).</description>
    <link>https://dev.to/kumar_sons_off</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%2F737225%2F03773be5-fc4e-41ed-aee7-e37892196ea7.png</url>
      <title>DEV Community: Priyanshu</title>
      <link>https://dev.to/kumar_sons_off</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kumar_sons_off"/>
    <language>en</language>
    <item>
      <title>CSS Interview Questions</title>
      <dc:creator>Priyanshu</dc:creator>
      <pubDate>Sun, 20 Mar 2022 15:10:58 +0000</pubDate>
      <link>https://dev.to/kumar_sons_off/css-interview-questions-3352</link>
      <guid>https://dev.to/kumar_sons_off/css-interview-questions-3352</guid>
      <description>&lt;p&gt;Hey Readers, hope you all are good and doing great. In today's world of tech, it's not easy to land a job while it's impossible to know answers to all questions that an interviewer may ask you, but you can feel more confident if you have known to some of those type of questions. &lt;/p&gt;

&lt;p&gt;People have no idea of what kind of questions should they expect when they apply for a Job. 🤷‍♂️ In this article, I'll be sharing some frequently asked CSS questions. These are the ones that are asked in different interviews from many different developers and programmers at different levels. 😀&lt;/p&gt;

&lt;p&gt;Before we go, I let you remind that &lt;strong&gt;Cascading Stylesheet Sheet&lt;/strong&gt; is a stylesheet language that determines how the elements and content should look on the page. CSS is used to develop a consistent look and feel to the webpage. 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  Here is the list of the most frequently asked CSS interview questions
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oi1pwhpM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media4.giphy.com/media/JRmKnYCDaAHOQFUeW1/giphy.gif%3Fcid%3De826c9fcyd4w59j0g2nlennzmi2w4d8sq2wz5skoxyrmzn74%26rid%3Dgiphy.gif%26ct%3Dg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oi1pwhpM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media4.giphy.com/media/JRmKnYCDaAHOQFUeW1/giphy.gif%3Fcid%3De826c9fcyd4w59j0g2nlennzmi2w4d8sq2wz5skoxyrmzn74%26rid%3Dgiphy.gif%26ct%3Dg" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the advantages of using CSS?
&lt;/h3&gt;

&lt;p&gt;The main advantages of using CSS are the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSS provides a way to present the same content in multiple presentations formats on mobile, desktop, or laptop. &lt;/li&gt;
&lt;li&gt;Used effectively, the style sheet will be stored in the browser cache and they can be used on multiple pages, without having to download again.&lt;/li&gt;
&lt;li&gt;CSS is built effectively such that it can be used to change the look and feel completely by making small changes. To make a global change, simply change the style, and all elements in all web pages will be automatically updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What do you know about CSS sprites?
&lt;/h3&gt;

&lt;p&gt;A sprite is a collection of many images put into a single image file to be used in a webpage, these are used because a webpage with too many images may take too long to load as it generates several server requests.&lt;/p&gt;

&lt;p&gt;Using image sprites we can reduce the number of server requests and save bandwidth. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is Box Model in CSS? Which properties are a part of it?
&lt;/h3&gt;

&lt;p&gt;This is the most basic and most frequent question asked multiple times in multiple interviews, you should know.&lt;/p&gt;

&lt;p&gt;CSS draws boxes during the layout process. Everything in CSS has a box around it, this is known as the box model. Each box is made up of four areas which are &lt;code&gt;content&lt;/code&gt;, &lt;code&gt;padding&lt;/code&gt;, &lt;code&gt;border&lt;/code&gt;, &lt;code&gt;margin&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is how a box model looks like:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BKLr5pGX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647763699189/1fO46vIta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BKLr5pGX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647763699189/1fO46vIta.png" alt="image.png" width="469" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;𝗖𝗼𝗻𝘁𝗲𝗻𝘁: The content area contains just that: the content! &lt;strong&gt;For example:&lt;/strong&gt; a text element's content area would be the &lt;code&gt;text content&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;𝗣𝗮𝗱𝗱𝗶𝗻𝗴: Padding area is the amount of empty space between its content and its border. This can be changed just by changing the element's padding, using the &lt;code&gt;padding-left&lt;/code&gt;, &lt;code&gt;padding-right&lt;/code&gt;, &lt;code&gt;padding-top&lt;/code&gt;, &lt;code&gt;padding-bottom&lt;/code&gt; properties or by using the shorthand property which is more common &lt;code&gt;padding: top, right, bottom, left&lt;/code&gt; in their respective units)&lt;/li&gt;
&lt;li&gt;𝗕𝗼𝗿𝗱𝗲𝗿: Area surrounding the padding. We can change an element’s border using the &lt;code&gt;border-width&lt;/code&gt;, &lt;code&gt;border-style&lt;/code&gt;, and &lt;code&gt;border-color&lt;/code&gt; properties, or the shorthand property border.&lt;/li&gt;
&lt;li&gt;𝗠𝗮𝗿𝗴𝗶𝗻: This is the outermost area of the &lt;strong&gt;box model&lt;/strong&gt;.  Similar to the others, we can also change the margin size.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  What are the limitations of using CSS?
&lt;/h3&gt;

&lt;p&gt;Main Disadvantages with CSS are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;𝗕𝗿𝗼𝘄𝘀𝗲𝗿 𝗰𝗼𝗺𝗽𝗮𝘁𝗶𝗯𝗶𝗹𝗶𝘁𝘆 𝗶𝘀𝘀𝘂𝗲𝘀 - Some style selectors are not supported in many old browsers. We have to determine whether the style we are using is supported or not using the &lt;code&gt;@support&lt;/code&gt; selector.&lt;/li&gt;
&lt;li&gt;𝗡𝗼 𝗽𝗮𝗿𝗲𝗻𝘁 𝘀𝗲𝗹𝗲𝗰𝘁𝗼𝗿 - Currently using CSS, you can't select a parent.&lt;/li&gt;
&lt;li&gt;𝗖𝗿𝗼𝘀𝘀 𝗕𝗿𝗼𝘄𝘀𝗲𝗿 𝗶𝘀𝘀𝘂𝗲𝘀 - Some of the selectors behave differently in different browsers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  What are CSS preprocessors? What are Sass, Less, and Stylus? Why do people use them?
&lt;/h3&gt;

&lt;p&gt;CSS preprocessors are the tools that help us to extend the basic functionality of the default CSS through their own scripting language. This helps us to use complex logic syntax like - functions, mixins, code nesting, inheritance to name a few in your default vanilla CSS.&lt;/p&gt;

&lt;p&gt;SASS stands for &lt;strong&gt;Syntactically Awesome Style Sheet&lt;/strong&gt;. SASS can be written in two different syntaxes using SASS or SCSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SASS Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sass"&gt;&lt;code&gt;&lt;span class="nv"&gt;$font-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ffe41e&lt;/span&gt; 
&lt;span class="nv"&gt;$bg-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#00f&lt;/span&gt;

&lt;span class="nn"&gt;#box&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$font-color&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$bg-color&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SCSS Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nv"&gt;$font-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ffe41e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$bg-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fcba03&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nn"&gt;#box&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="nv"&gt;$font-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$bg-color&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;𝗦𝗔𝗦𝗦 uses &lt;code&gt;.sass&lt;/code&gt; while 𝗦𝗖𝗦𝗦 uses &lt;code&gt;.scss&lt;/code&gt; extension.&lt;/li&gt;
&lt;li&gt;𝗦𝗔𝗦𝗦 doesn't use curly braces or semicolons while 𝗦𝗖𝗦𝗦 uses these, just like CSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;𝗟𝗘𝗦𝗦:&lt;/strong&gt; less stands for &lt;strong&gt;Leaner Stylesheets&lt;/strong&gt;. LESS is easy to add to any JavaScript project by using NPM or less.js file. This file uses &lt;code&gt;.less&lt;/code&gt; extension.&lt;/p&gt;

&lt;p&gt;𝗟𝗘𝗦𝗦 syntaxis the same as the SCSS with some exceptions. LESS uses &lt;code&gt;@&lt;/code&gt; to define the variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@font-color: #ffe41e;
@bg-color: #fcba03

#box{
    color: @font-color;
    background: @bg-color;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Stylus:&lt;/strong&gt; Stylus offers a great flexibility in writing syntax, supports native CSS as well as allows omission of brackets, colons, and semicolons. It doesn’t use &lt;code&gt;@&lt;/code&gt; or &lt;code&gt;$&lt;/code&gt; for defining variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* STYLUS SYNTAX WRITTEN LIKE NATIVE CSS */
font-color= #ffe41e;
bg-color = #fcba03;

#box {
    color: font-color;
    background: bg-color;
}

/* OR */

/* STYLUS SYNTAX WITHOUT CURLY BRACES */
font-color= #ffe41e;
bg-color = #fcba03;

#box
    color: font-color;
    background: bg-color;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Is it important to test the webpage in different browsers?
&lt;/h3&gt;

&lt;p&gt;It's most important to test a website in different browsers when you're first designing it, or making major changes.&lt;/p&gt;

&lt;p&gt;However, it's also important to repeat these tests periodically, since browsers go through a lot of updates and changes, and we know that some of the CSS properties do not support in many browsers.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is viewport height and viewport width in CSS?
&lt;/h3&gt;

&lt;p&gt;It's used to measure the height and width in percentage concerning the viewport.&lt;/p&gt;

&lt;p&gt;If the height of the browser is equal to 1000px, 1vh is equal to 10px, similar for the width.&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference between reset vs normalize CSS? How do they differ?
&lt;/h3&gt;

&lt;p&gt;𝗥𝗲𝘀𝗲𝘁 𝗖𝗦𝗦 - CSS reset aims to remove all built-in browser styling. &lt;strong&gt;For example&lt;/strong&gt;, &lt;code&gt;paddings&lt;/code&gt;, &lt;code&gt;margin&lt;/code&gt;, &lt;code&gt;font-size&lt;/code&gt; of all elements back to the same.&lt;br&gt;
𝗡𝗼𝗿𝗻𝗮𝗹𝗶𝘇𝗲 𝗖𝗦𝗦 - aims to make built-in browser styling consistent across browsers. It also corrects bugs for common browser dependencies.&lt;/p&gt;




&lt;p&gt;⚠ &lt;strong&gt;You can also modify answers as per your convenience, it's not recommended to cram these ones. Also, this article does not claim that you will find the exact same questions in your interview.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;It's totally ok to feel stressed in interviews and everyone does, but just be yourself, you will gonna make it.&lt;/p&gt;

&lt;p&gt;Also, a more important thing is that there is no one who knows all the answers and all frameworks of a language. So don't be shy to say no about the thing you don't know. This will not take your image down, but if you try to frame something that you don't know about, then there is a possibility that the interviewer will caught you. 😅 I'm saying again....just be yourself.&lt;/p&gt;

&lt;p&gt;Ok! It's wrap-up time, that's pretty much for this blog. I'm getting late for an important meeting, see you in the next one.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We have covered some of the &lt;strong&gt;frequently asked interview questions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If you find this useful, then please let me know in the comments below, and consider sharing it with your audience.&lt;/li&gt;
&lt;li&gt;More blogs related to this are about to come, follow &lt;a href="https://dev.to/kumar_sons_off"&gt;Priyanshu&lt;/a&gt; to stay tuned. 😉&lt;/li&gt;
&lt;li&gt;Also, You can Join me on 🐦 &lt;a href="https://twitter.com/Kumar_Sons_off"&gt;Twitter&lt;/a&gt;, where I tweet more frequently about Tips and Resources for web developers. &lt;/li&gt;
&lt;li&gt;Good luck for your interview. 👍&lt;/li&gt;
&lt;li&gt;Thanks for Reading. 😊&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;You can extend your Support by Buying me a coffee here.&lt;/strong&gt;🌴&lt;br&gt;
&lt;a href="https://www.buymeacoffee.com/Kumar_sons_off"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_fXhVr6E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644160648145/jcCO-V5ENx.png" alt="yellow-button.png" width="174" height="49"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Published on: 03/20/2022.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>career</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Create Your Word Portrait using CSS</title>
      <dc:creator>Priyanshu</dc:creator>
      <pubDate>Mon, 07 Feb 2022 04:42:46 +0000</pubDate>
      <link>https://dev.to/kumar_sons_off/create-your-word-portrait-using-css-24kc</link>
      <guid>https://dev.to/kumar_sons_off/create-your-word-portrait-using-css-24kc</guid>
      <description>&lt;p&gt;In this article, I'll introduce you with the &lt;code&gt;background-clip&lt;/code&gt; property of CSS, with the help of which, we will make our &lt;strong&gt;Word portrait&lt;/strong&gt;. Even if you are a beginner at CSS and HTML, you'll be able to do that. 😃&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You might have seen a word portrait? ofcourse yes! But if I ask you that, have you ever created Your word portrait by yourself using CSS? Might not! But don't be worry about that, this article is for you, and by the end of this article, you will be able to create one for yourself.&lt;/strong&gt; 💻&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we get started, I recommend that you have these prerequisites to follow along with this article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very Basic HTML Knowledge&lt;/li&gt;
&lt;li&gt;Basic CSS knowledge&lt;/li&gt;
&lt;li&gt;Code Editing Software (or an account on Codepen.io)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If I say that it's &lt;strong&gt;only 2 lines of code&lt;/strong&gt; to create a &lt;strong&gt;portrait&lt;/strong&gt; using CSS. You might think, I'm kidding you! 😅, but no, actually I'm not. You can indeed create a &lt;strong&gt;word portrait&lt;/strong&gt; using CSS with only a few lines of code only, and this could be made possible by the &lt;code&gt;background-clip&lt;/code&gt; property. Before we go, we first need to know about the &lt;code&gt;background-clip&lt;/code&gt; property in CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the &lt;code&gt;background-clip&lt;/code&gt; property in CSS? What does it use for ??
&lt;/h2&gt;

&lt;p&gt;In CSS, the &lt;code&gt;background-clip&lt;/code&gt; property is used to add/clip Images, GIFs, Gradients, etc as a background of different content-boxes, elements including text. This property can be used for creating clip text, about which we will talk later in this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  what can be the values of the &lt;code&gt;background-clip&lt;/code&gt; property?
&lt;/h2&gt;

&lt;p&gt;Let's have a look at the following &lt;strong&gt;flow-chart&lt;/strong&gt; which shows the implementations of the &lt;code&gt;background-clip&lt;/code&gt; property, that how &lt;code&gt;background-clip&lt;/code&gt; works in different scenarios.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gBLrGQJu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644134131100/0IXhFHI1Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gBLrGQJu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644134131100/0IXhFHI1Q.png" alt="blog post.drawio (1).png" width="880" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Including &lt;code&gt;text&lt;/code&gt;, we have these values for the &lt;code&gt;background-clip&lt;/code&gt; property: 👇👇
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;border-box&lt;/code&gt;&lt;/strong&gt; is the default value. This allows the background to extend all the ways to the outside edges of the element's border.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;padding-box&lt;/code&gt;&lt;/strong&gt; clips the background to the outside edge of the padding region.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;content-box&lt;/code&gt;&lt;/strong&gt; clips the background to the outside edge of the element's content region.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;initial&lt;/code&gt;&lt;/strong&gt; sets the property to its initial/default value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;inherit&lt;/code&gt;&lt;/strong&gt; applies the background-clip setting of the parent to the selected element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;text&lt;/code&gt;&lt;/strong&gt; is used for adding a background clip to the text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;That was the theory part you need to know to get started, Let's now understand it better with the help of the following code example:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Code:&lt;/strong&gt;&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;"container-fluid"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"border-box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; border-box extends background behind the borders&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"padding-box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;padding-box clips the background till border&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"content-box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; content-box clips the background till padding area&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; background is clipped to 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;p&gt;&lt;strong&gt;CSS Style:&lt;/strong&gt; This is how the &lt;code&gt;background-clip&lt;/code&gt; property is implemented.&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;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;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5rem&lt;/span&gt; &lt;span class="nb"&gt;dashed&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;2rem&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="m"&gt;#d00000&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="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('https://images.unsplash.com/photo-1642444525640-d3eb287ed389?crop=entropy&amp;amp;cs=tinysrgb&amp;amp;fit=max&amp;amp;fm=jpg&amp;amp;ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTY0NDEyOTE3Nw&amp;amp;ixlib=rb-1.2.1&amp;amp;q=80&amp;amp;w=400')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* default --&amp;gt; border-box */&lt;/span&gt;
&lt;span class="nc"&gt;.border-box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* Padding-box */&lt;/span&gt;
&lt;span class="nc"&gt;.padding-box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nl"&gt;background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;padding-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* content-box */&lt;/span&gt;
&lt;span class="nc"&gt;.content-box&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nl"&gt;background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* text */&lt;/span&gt;
&lt;span class="nc"&gt;.text&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="nl"&gt;-webkit-background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&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="nb"&gt;transparent&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;&lt;strong&gt;Output:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Kumar_Sons_off/embed/RwjaOxe?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is how the &lt;code&gt;background-clip&lt;/code&gt; property works in CSS. It clips this background to different boxes of an element as we have seen in the above example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Animated Clip-Text
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--62MTfc0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644150992448/wgniDHqoI.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--62MTfc0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644150992448/wgniDHqoI.gif" alt="Animated-clip-text.gif" width="320" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above was the simple implementation of the background-clip property, but more interestingly, we can create an Animated clip-text by the use of this &lt;code&gt;background-clip&lt;/code&gt; property, without using any &lt;strong&gt;animation&lt;/strong&gt; property.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is how:&lt;/strong&gt; You know what, for me, this was the best use case of this property when I discovered it accidentally. ☺️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML Code:&lt;/strong&gt;&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;"clip-text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    @Kumar_Sons_off
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CSS Code:&lt;/strong&gt; You need the following CSS code for creating an &lt;strong&gt;animated-clip text.&lt;/strong&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="nc"&gt;.clip-text&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* You need a URL for a Gif */&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url(http://i.giphy.com/fsULJFFGv8X3G.gif)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-position&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;-webkit-background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&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="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;set&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;transparent,&lt;/span&gt; &lt;span class="err"&gt;otherwise&lt;/span&gt; &lt;span class="err"&gt;you&lt;/span&gt; &lt;span class="err"&gt;won't&lt;/span&gt; &lt;span class="err"&gt;see.&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;300px&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;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&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;38px&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="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="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-shrink&lt;/span&gt;&lt;span class="p"&gt;:&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;p&gt;&lt;strong&gt;Output:&lt;/strong&gt; This is how it looks.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--62MTfc0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644150992448/wgniDHqoI.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--62MTfc0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644150992448/wgniDHqoI.gif" alt="Animated-clip-text.gif" width="320" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The &lt;strong&gt;&lt;code&gt;background-clip: text&lt;/code&gt;&lt;/strong&gt; property does not support many old browsers, So I created a GIF and added it here for the above output. But you can have the live codepen view from this &lt;a href="https://codepen.io/Kumar_Sons_off/pen/BadmxbK"&gt;CodePen&lt;/a&gt; link.&lt;/p&gt;

&lt;p&gt;That was a lot much for the &lt;code&gt;background-clip&lt;/code&gt; property for you to know, but let's have one more implementation or use case of this property.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Word Portrait
&lt;/h2&gt;

&lt;p&gt;I thought this is the most awaited part of this article. Finally, now, we are known enough to the &lt;code&gt;background-clip&lt;/code&gt; property to create a &lt;strong&gt;word portrait.&lt;/strong&gt; For that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First of all, you need to have your photo with a plain background (for a better look) or it would be more better if it is with no background. You can use certain tools to remove background like remove.bg and all.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code a Paragraph with the HTML of your wish. (don't forget to link the CSS file if you are using something other than codepen.io)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the CSS &lt;code&gt;background-clip&lt;/code&gt; property and set its value to text like the following, and you need a &lt;strong&gt;direct link&lt;/strong&gt; for your image if you are using &lt;strong&gt;Codepen.io&lt;/strong&gt;. For that, you can use certain tools like postimages.org, or any other of your choice.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&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;#000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* adjust font accordingly */&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url("https://i.postimg.cc/2jhGPtDJ/profile-pic-resized.png")&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&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="nb"&gt;transparent&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;0.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cover&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;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is the view of the most awaited output of this article. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FT7Szj1e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644158743307/1BZ4SvDkg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FT7Szj1e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644158743307/1BZ4SvDkg.png" alt="screenshot-2022.02.06-18_45_07.png" width="472" height="568"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I mentioned before, the &lt;code&gt;background-clip: text&lt;/code&gt; property is not supported in many versions of browsers that are still in use, so I've added an image here instead of the codepen live view. Yup, but you can see its live view from this &lt;a href="https://codepen.io/Kumar_Sons_off/pen/XWevyZo"&gt;CodePen&lt;/a&gt;. 😉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's all you need to know about the &lt;code&gt;background-clip&lt;/code&gt; property in CSS.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We have covered all one need to know about &lt;code&gt;background-clip&lt;/code&gt; property.&lt;/li&gt;
&lt;li&gt;I hope you find it useful. If yes, then let me know in the comments below, and consider sharing it with your friends.&lt;/li&gt;
&lt;li&gt;I would love to see if you have tried creating your portrait, feel free to drop a link to your &lt;strong&gt;Portrait codepen&lt;/strong&gt; below.&lt;/li&gt;
&lt;li&gt;Also, You can Join me on &lt;a href="https://twitter.com/Kumar_Sons_off"&gt;Twitter 🐦&lt;/a&gt;, where I tweet more frequently about Tips and Resources for web developers.&lt;/li&gt;
&lt;li&gt;Thanks for Reading.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;You can extend your Support by Buying me a coffee here.&lt;/strong&gt;🌴&lt;br&gt;
&lt;a href="https://www.buymeacoffee.com/Kumar_sons_off"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_fXhVr6E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644160648145/jcCO-V5ENx.png" alt="yellow-button.png" width="174" height="49"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Last updated on: 07/02/2022.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
