<?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>Forem: Michael Sayapin</title>
    <description>The latest articles on Forem by Michael Sayapin (@michael_sayapin).</description>
    <link>https://forem.com/michael_sayapin</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%2F445611%2F06afaba4-8e02-4af5-af79-5995564b6025.jpg</url>
      <title>Forem: Michael Sayapin</title>
      <link>https://forem.com/michael_sayapin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/michael_sayapin"/>
    <language>en</language>
    <item>
      <title>JavaScript - Array.concat()</title>
      <dc:creator>Michael Sayapin</dc:creator>
      <pubDate>Sat, 07 Nov 2020 15:49:30 +0000</pubDate>
      <link>https://forem.com/michael_sayapin/javascript-array-concat-1gp8</link>
      <guid>https://forem.com/michael_sayapin/javascript-array-concat-1gp8</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flur8by70yjg9nsmm1e5u.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flur8by70yjg9nsmm1e5u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today I will talk about the Array.concat() method in JavaScript.&lt;/p&gt;

&lt;p&gt;The concat() method returns a new array, build of this array joined with other arrays and/or values.&lt;/p&gt;

&lt;p&gt;let's take a look at its syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newArray = oldArray.concat(optinalValues);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;oldArray - The array we call the concat method on.&lt;br&gt;
concat() - The method receives 0 or more parameters.&lt;br&gt;
optionalValues - An optional value to pass to the method, it can be an array, a primitive data type, a function, or an object.&lt;/p&gt;

&lt;p&gt;An alternative syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newArray = [].concat(oldArray, optionalValues);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Personally, I like the alternative syntax, because it is more readable and easier for me to understand that we create a new array from all the elements of the passed parameters, and not adding new elements to the old array.&lt;/p&gt;



&lt;h2&gt;
  
  
  Examples:
&lt;/h2&gt;

&lt;p&gt;1) Passing Data Types: &lt;/p&gt;

&lt;p&gt;The method copies the data types into the new array.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing a number
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const number = 5;

const newArray = oldArray.concat(number);
// result =&amp;gt; [1, 2, 3, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Passing a string
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const string = 'Web Cat';

const newArray = oldArray.concat(string);
// result =&amp;gt; [1, 2, 3, 'Web Cat']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Passing a boolean
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const flag = true;

const newArray = oldArray.concat(flag);
// result =&amp;gt; [1, 2, 3, true]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Passing undefined
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const variable = undefined;

const newArray = oldArray.concat(variable);
// result =&amp;gt; [1, 2, 3, undefined]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Passing null
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const emptyObj = null;

const newArray = oldArray.concat(emptyObj);
// result =&amp;gt; [1, 2, 3, null]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;2) Passing Arrays&lt;/p&gt;

&lt;p&gt;The method creates a new array consisting of the elements in the array on which it is called and each of the elements of the passing array.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing a different array
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const anotherArray = [4, 5, 6];

const newArray = oldArray.concat(anotherArray);
// result =&amp;gt; [1, 2, 3, 4, 5, 6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Passing itself
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];

const newArray = oldArray.concat(oldArray);
// result =&amp;gt; [1, 2, 3, 1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;3) Passing Structural Types&lt;/p&gt;

&lt;p&gt;The method makes a shallow copy of structural data types into the new array. It means that if we change the original parameter, it will change it in the new array as well.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing a nested array
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const nestedArray = [4, 5, 6, [7]];

const newArray = oldArray.concat(nestedArray);
// Result =&amp;gt; [1, 2, 3, 4, 5, 6, [7]]

nestedArray[3].push(6);
// Result =&amp;gt; [1, 2, 3, 4, 5, 6, [7, 6]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Passing an object
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const obj = {
  name: 'Mike',
  nickname: 'Web Cat'
};

const newArray = oldArray.concat(obj);
// result =&amp;gt; [1, 2, 3, { name: 'Mike', nickname: 'Web Cat' }]

obj.age = 25;
// result =&amp;gt; [1, 2, 3, { 
     age: 25, 
     name: 'Mike',
     nickname: 'Web Cat'
   }]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;4) Passing functions&lt;/p&gt;

&lt;p&gt;The method takes the function and pushed it into the array as if it was a regular data type.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing a function declaration
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
function myFunc() {
    return this[0] + this[1];
}

const newArray = oldArray.concat(myFunc);
// result =&amp;gt; [1, 2, 3, function myFunc() {
    return this[0] + this[1];
}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case we pass a function declaration to the concat() method, the function will get the context of the array.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing an arrow function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const myFunc = x =&amp;gt; x;

const newArray = oldArray.concat(myFunc);
// result =&amp;gt; [1, 2, 3, x =&amp;gt; x]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case we pass an arrow function to the concat() method, the function will not get a new context.&lt;/p&gt;




&lt;p&gt;5) Omitting parameters&lt;/p&gt;

&lt;p&gt;If we call the function without parameters, it will create a shallow copy of the original array.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing no parameters
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];

const newArray = oldArray.concat();
// result =&amp;gt; [1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;6) Passing multiple parameters&lt;/p&gt;

&lt;p&gt;When we pass multiple parameters to the method, it makes a new array with all its elements in the same order they got passed to the method.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passing no parameters
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const oldArray = [1, 2, 3];
const val1 = 4;
const val2 = '5';
const val3 = {
    value: 'sixth',
}
const val4 = [[7]];

const newArray = oldArray.concat(val1, val2, val3, val4);
// result =&amp;gt; [1, 2, 3, 4, "5", {
  value: "sixth"
}, [7]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is only one part of a series of posts about the different methods in JavaScript.&lt;br&gt;
Stay tuned for more posts weekly :D &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webcat</category>
    </item>
    <item>
      <title>CSS - Position</title>
      <dc:creator>Michael Sayapin</dc:creator>
      <pubDate>Wed, 02 Sep 2020 06:12:27 +0000</pubDate>
      <link>https://forem.com/michael_sayapin/css-position-4nb2</link>
      <guid>https://forem.com/michael_sayapin/css-position-4nb2</guid>
      <description>&lt;p&gt;The position CSS property is one of the most important layout properties to know as a beginner web developer. With it, we can control the position and the "place" of the elements in the natural flow of the document, and even it's behavior. The different position values control the behavior of the element in the page, and the top, right, bottom, and left control the location of the element. In addition to them, the z-index property can help us to create a stack of elements, meaning "behind" and "over" each other.&lt;/p&gt;

&lt;p&gt;There are 4 types of positions:&lt;br&gt;&lt;strong&gt;Static elements&lt;/strong&gt;: These are all the HTML elements by default, we can say that a static element, is an element that is not positioned.&lt;br&gt;&lt;strong&gt;Relative positioned&lt;/strong&gt;: These are elements that are positioned as &lt;em&gt;relative&lt;/em&gt;, meaning they are still part of the natural document flow, and they take up space, but they can be moved to some other place with the use of top, bottom, left, right, and z-index properties.&lt;br&gt;&lt;strong&gt;Absolute positioned&lt;/strong&gt;: These are the elements that are positioned as &lt;em&gt;absolute &lt;/em&gt;or as &lt;em&gt;fixed&lt;/em&gt;. These elements are taken out of the natural flow, which means they do not take space in the document and are positioned by the top, right, bottom, right, and the z-index properties.&lt;br&gt;&lt;strong&gt;Sticky positioned&lt;/strong&gt;: These are the elements that are positioned as &lt;em&gt;sticky. &lt;/em&gt;These elements are a combination of relative and fixed positions. At first, it gets treated as a relative element, until it gets to a certain threshold in the parent container, from that point it will behave as a fixed element and will be stuck to the screen until we move past the parent container element.&lt;/p&gt;

&lt;h4&gt;position: static&lt;/h4&gt;

&lt;p&gt;This is the default value of every HTML element, it is said that statically positioned elements are not positioned. A static element is not affected by the top, right, bottom, left, and z-index properties.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zPriJpgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-22.png%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zPriJpgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-22.png%3Fw%3D1024" alt="" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;position: relative&lt;/h4&gt;

&lt;p&gt;This property allows us to take the element and offset it with the top, bottom, left, and right properties without affecting other elements. The element is not taken out of the natural flow of the document, so it takes the space in it as if it was static.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EUAh9B8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-23.png%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EUAh9B8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-23.png%3Fw%3D1024" alt="" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;position: absolute&lt;/h4&gt;

&lt;p&gt;This property will take the element completely out of the document natural flow, so even the space that the element should have in the flow will be taken by other elements.&lt;br&gt;The final position of the element will be determined by the top, left, right, and bottom properties.&lt;br&gt;The position of the element will be relative to the closest positioned ancestor, and if not found any, it will be relative to the HTML root element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RN-5-YHj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-24.png%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RN-5-YHj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-24.png%3Fw%3D1024" alt="" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4 id="block-5739c384-674f-406c-a75c-8751098cc7db"&gt;position: sticky&lt;/h4&gt;

&lt;p&gt;This property will behave like the relative property, it means it has its own place in the natural flow in the document. To make it behave like a sticky element, we have to add also the threshold in which it will behave like it, we do is using the top and bottom properties for parent elements with a scroll in the y-axis and the left and right properties for the parent element that has a scroll in the x-axis. This property will make the element stick to that place in the screen as long as the parent element is visible, or we reached the threshold we declared.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Notes&lt;/span&gt;:&lt;br&gt;The sticky property is not supported by IE at all, and it has many other conditions that may cause it not to work, so please be aware of the limitations when using this property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dMF5RAqp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-26.png%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dMF5RAqp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-26.png%3Fw%3D1024" alt="" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;position: fixed&lt;/h4&gt;

&lt;p&gt;This property acts like the absolute, it takes the element out of the natural flow, and its space gets taken by other elements. This property lets us place an element on a fixed place on the screen, the difference between fixed and absolute is that in fixed, the element stays in the same place even if the user scrolls.&lt;br&gt;The position of the element will be relative to the container which is established by the viewport.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xnIQssMC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-27.png%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xnIQssMC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-27.png%3Fw%3D1024" alt="" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;The directional properties&lt;/h3&gt;

&lt;p&gt;The directional properties can be categories into 3 groups, horizontal properties - left and right, vertical properties - top and bottom, and the depth property - z-index.&lt;/p&gt;

&lt;h4&gt;top property&lt;/h4&gt;

&lt;p&gt;The top property lets us specify the vertical position of the positioned element, from the top perspective. It has different effects based on the position value of the element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;static&lt;/strong&gt;: The top property does not affect the element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;relative&lt;/strong&gt;: It controls how much to move the element down (away from the top) relative to the elements' original location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;absolute and fixed&lt;/strong&gt;: It controls the distance between the element's top edge and the top edge of the containing block.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sticky&lt;/strong&gt;: It sets the point for the element where it should become sticky in it's containing block.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;bottom property&lt;/h4&gt;

&lt;p&gt;The bottom property lets us specify the vertical position of the positioned element, from the bottom perspective. It has different effects based on the position value of the element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;static&lt;/strong&gt;: The bottom property does not affect the element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;relative&lt;/strong&gt;: It controls how much to move the element up (away from the bottom) relative to the elements' original location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;absolute and fixed&lt;/strong&gt;: It controls the distance between the element's bottom edge and the bottom edge of the containing block.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sticky&lt;/strong&gt;: It sets the point for the element where it should become sticky in it's containing block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;span&gt;Notes:&lt;/span&gt;&lt;br&gt;In case both top and bottom properties are used, the position property is set to absolute or fixed and the height of the element is not specified, both the top and bottom properties will be used to stretch the element vertically.&lt;br&gt;In any other case, the top property will be used to place the element and the bottom property will be ignored.&lt;/p&gt;

&lt;h4&gt;right property&lt;/h4&gt;

&lt;p&gt;The right property lets us specify the horizontal position of the positioned element, from the right perspective. It has different effects based on the position value of the element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;static&lt;/strong&gt;: The right property does not affect the element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;relative&lt;/strong&gt;: It controls how much to move the element left (away from the right) relative to the elements' original location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;absolute and fixed&lt;/strong&gt;: It controls the distance between the element's right edge and the right edge of the containing block.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sticky&lt;/strong&gt;: It sets the point for the element where it should become sticky in it's containing block.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;left property&lt;/h4&gt;

&lt;p&gt;The left property lets us specify the vertical position of the positioned element, from the top perspective. It has different effects based on the position value of the element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;static&lt;/strong&gt;: The left property has no effect on the element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;relative&lt;/strong&gt;: It controls how much to move the element right (away from the left) relative to the elements' original location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;absolute and fixed&lt;/strong&gt;: It controls the distance between the element's left edge and the left edge of the containing block.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sticky&lt;/strong&gt;: It sets the point for the element where it should become sticky in it's containing block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;span&gt;Notes:&lt;/span&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;In case both left and right properties are used, and the width of the element is not specified, both the left and right properties will be used to stretch the element horizontally.&lt;br&gt;In any other case, the left property will be used if the text direction is LtR and if the text direction is RtL the right property will be used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The values for the top, bottom, left and right properties are all the same and have the same effect.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;length&lt;/strong&gt;: Can be negative, positive, or null. Usually, the length is a number with a length unit, such as px, rem, vh, etc'&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;percentage&lt;/strong&gt;: In the case of the top and bottom properties, it represents the percentage of the containing block's height. In the case of the right and left properties, it represents the percentage of the containing block's width.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;auto&lt;/strong&gt;: This is the default value for all elements. It behaves differently between relative and absolute positioned elements.&lt;ul&gt;
&lt;li&gt;In relatively positioned elements, if the property is auto it does not affect the element, and the element is not moved at all.&lt;/li&gt;
&lt;li&gt;In absolute positioned elements, each property controls the position of the element, if one of them is set to auto, then the other will decide on the position, if both elements are set to auto, the element will not be moved in that axis.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;z-index property&lt;/h4&gt;

&lt;p&gt;The z-index property controls the z-axis position of a positioned element and its descendants. The higher the value the more in front the element will be, and will overlap elements with lower z-index values.&lt;/p&gt;

&lt;p&gt;This property affects the positioned element in two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The z-axis position in its stacking context, meaning if it will overlap other elements or be overlapped by other elements.&lt;/li&gt;
&lt;li&gt;Establishes a new stacking context inside the element for its descendant elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Values&lt;/h5&gt;

&lt;p&gt;The z-index can receive two types of values, 'auto' and an integer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;auto&lt;/strong&gt;: This is the default value for all the elements. This will give the element the z-index value of the parent element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;an integer&lt;/strong&gt;: This will create a stacking context inside the element and its stack level will be '0' compared to its descendants. It will also determine the elements stack level in its own stack context.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;This concludes my article that explains the position property, and the top, bottom, left, right ,and the z-index properties and their different values.&lt;/h4&gt;

&lt;h4&gt;Hope you like it, and stay tuned for my next article soon!&lt;/h4&gt;

</description>
      <category>css</category>
      <category>layout</category>
      <category>position</category>
    </item>
    <item>
      <title>CSS - Float and Clear</title>
      <dc:creator>Michael Sayapin</dc:creator>
      <pubDate>Tue, 25 Aug 2020 22:41:26 +0000</pubDate>
      <link>https://forem.com/michael_sayapin/css-float-and-clear-29i5</link>
      <guid>https://forem.com/michael_sayapin/css-float-and-clear-29i5</guid>
      <description>&lt;h2&gt;Float Property&lt;/h2&gt;

&lt;p&gt;The original purpose of the float was to take a block type element out of the natural flow but still related to the other elements and float it to the right or to the left of the parent container so that other inline elements or text can wrap around it.&lt;br&gt;&lt;br&gt;In time people started using float as a way to build layouts, but as today there are technologies like flexbox, grid, and etc', so the use of floats is almost gone, apart from small tweaks here and there inside other elements.&lt;/p&gt;

&lt;p&gt;The float property takes the element out of the natural flow of the page and floats it to the left or right based on the value, but it still considers the flow of other elements. Unlike the position absolute which takes the element completely out of the flow.&lt;/p&gt;

&lt;p&gt;There are a couple of values that we can use in the float property, the standard values are none, left and, right. In the Firefox browser (as of the time of writing of this article) there are two more additional values: the inline-end, and the inline-start values.&lt;/p&gt;

&lt;h5&gt;float: none&lt;/h5&gt;

&lt;p&gt;This is the default value for every element for the float property. Just as the value itself implies, the element is not under the influence of the float property and behaves as it "naturally" does.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--itqI71q0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image.png%3Fw%3D908" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--itqI71q0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image.png%3Fw%3D908" alt="" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;float: left&lt;/h5&gt;

&lt;p&gt;This will take the element and "float" it to the leftmost side of the parent container until it reaches the padding or border, if there are any other elements that also float right next to our element, they will be "floating" next to each other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VtmdoI1A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-8.png%3Fw%3D907" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VtmdoI1A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-8.png%3Fw%3D907" alt="" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;float: right&lt;/h5&gt;

&lt;p&gt;This will take the element and "float" it to the rightmost side of the parent container, and the same as the float: left, if any other element is also floated to the right it will be aligned next to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qY_eohph--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-2.png%3Fw%3D908" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qY_eohph--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-2.png%3Fw%3D908" alt="" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;float: inline-start&lt;/h5&gt;

&lt;p&gt;This will push the element to the start of the typing direction if the text in the container is written Left-to-Right, so the element will float to the left. If the text is written Right-to-Left the element will float to the right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--owchzWic--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-4.png%3Fw%3D901" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--owchzWic--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-4.png%3Fw%3D901" alt="" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3tev7zqc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-5.png%3Fw%3D905" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3tev7zqc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-5.png%3Fw%3D905" alt="" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;float: inline-end&lt;/h5&gt;

&lt;p&gt;This will push the element to the end of the typing direction if the text in the container is written Left-to-Right, so the element will float to the right. If the text is written Right-to-Left the element will float to the left.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iNvQm5kv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-6.png%3Fw%3D906" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iNvQm5kv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-6.png%3Fw%3D906" alt="" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yY4lBQnb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-7.png%3Fw%3D898" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yY4lBQnb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-7.png%3Fw%3D898" alt="" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Clear property&lt;/h3&gt;

&lt;p&gt;As we learned the float property takes the element out of the natural flow of the document, but still gives the inline elements and text wrap around it, but what happens to the other block elements around it?&lt;/p&gt;

&lt;p&gt;The block elements around a floated elements take the original place of the floated element and most likely to get "behind" the floated element, in order to deal with this we can use the clear CSS property.&lt;/p&gt;

&lt;p&gt;The clear property dictates where float elements can be around our element. The standard values that can be used are none, left, right, and both, in addition to them, in the firefox browser (as of the time of writing of this article) there are two more additional values: the inline-start, and the inline-end values.&lt;/p&gt;

&lt;h5&gt;clear: none&lt;/h5&gt;

&lt;p&gt;This is the default value, it allows float elements to be from both sides of our element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LQWtnQRx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-10.png%3Fw%3D905" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LQWtnQRx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-10.png%3Fw%3D905" alt="" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;clear: left&lt;/h5&gt;

&lt;p&gt;This will clear all the floats that are on the left side of our element, or in other words, this will push our element's top edge under the bottom edge of the lowest floated element from the left.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zGmEYQaE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-9.png%3Fw%3D917" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zGmEYQaE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-9.png%3Fw%3D917" alt="" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;clear: right&lt;/h5&gt;

&lt;p&gt;This will clear all the floats that are on the right side of our element, or in other words, this will push our element's top edge under the bottom edge of a lowest floated element from the right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dsSzsYUk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-12.png%3Fw%3D910" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dsSzsYUk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-12.png%3Fw%3D910" alt="" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;clear: both&lt;/h5&gt;

&lt;p&gt;This will not allow any float elements to be on both sides of our element, so it will push our element under the last and lowermost float in the same container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bKNMfa5e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-13.png%3Fw%3D910" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bKNMfa5e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-13.png%3Fw%3D910" alt="" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;clear: inline-start&lt;/h5&gt;

&lt;p&gt;This will not allow any float elements to the side of our element based on the text direction in the parent. If the text direction is LtR the clear will get the value "left" if the text direction is RtL the clear will get the value "right".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5dBTLQdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-15.png%3Fw%3D908" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5dBTLQdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-15.png%3Fw%3D908" alt="" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kz8_uo4A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-16.png%3Fw%3D907" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kz8_uo4A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-16.png%3Fw%3D907" alt="" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;clear: inline-end&lt;/h5&gt;

&lt;p&gt;This will not allow any float elements to the side of our element based on the text direction in the parent. If the text direction is LtR the clear will get the value "right" if the text direction is RtL the clear will get the value "left".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NdxKk8Nr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-17.png%3Fw%3D903" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NdxKk8Nr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-17.png%3Fw%3D903" alt="" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lvEm_Toa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-18.png%3Fw%3D907" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lvEm_Toa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/image-18.png%3Fw%3D907" alt="" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;This concludes my article that explains the float and clear properties and their different values.&lt;/h4&gt;

&lt;h4&gt;Hope you like it, and stay tuned for my next article soon!&lt;/h4&gt;

</description>
      <category>css</category>
      <category>float</category>
      <category>clear</category>
      <category>layout</category>
    </item>
    <item>
      <title>CSS - Basic Selectors</title>
      <dc:creator>Michael Sayapin</dc:creator>
      <pubDate>Thu, 13 Aug 2020 11:03:25 +0000</pubDate>
      <link>https://forem.com/michael_sayapin/css-basic-selectors-3a4k</link>
      <guid>https://forem.com/michael_sayapin/css-basic-selectors-3a4k</guid>
      <description>&lt;h2&gt;CSS Selectors&lt;/h2&gt;

&lt;p&gt;Before we start talking about the different types of selectors, we need to understand what they are, and why do we even need them.&lt;br&gt;CSS is a language that dictates how elements will be rendered in the browser, for us to connect between the rendering declarations (all the CSS properties) and each element in the DOM tree, we use CSS selectors.&lt;br&gt;Selectors are patterns that the browser matches against elements in the DOM tree and looks for a node element or a set of node elements matching that pattern, selects them (hence the name selectors), and defines their rendering, or in simple words, defines their appearance on the browser screen.&lt;/p&gt;

&lt;h3&gt;Selector Structure&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;Selector&lt;/strong&gt; is a pattern of elements in the DOM tree. It refers to the simple selector, compound selector, complex selector, or a selector list. When we create a selector we create a condition, then the browser is looking for an element that meets that condition and selects it.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Subject of a Selector &lt;/strong&gt;is the element that meets all the conditions of the selector, from the DOM tree.  An element matches a selector only if the Selector accurately describes that element. Two elements match a combinator when the condition of the relationship between them is met.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Simple Selector &lt;/strong&gt;is a single pattern on an element. It refers to type selector, universal selector, attribute selector, class selector, ID selector, or pseudo-selectors.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Compound Selector &lt;/strong&gt;is a set of simple selectors that are not separated by a combinator, and create a "list" of conditions to an element.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Combinator &lt;/strong&gt;is a condition, like a selector, but it checks the relationship between two elements and not the element itself. It refers to the descendant combinator ( ), the child combinator ( &amp;gt; ), the next-sibling combinator ( + ) and the subsequent-sibling combinator ( ~ ).&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Complex Selector &lt;/strong&gt;is a set of compound selectors separated by combinators. This selector creates a set of conditions on a set of elements.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Selector List &lt;/strong&gt;is a list of selectors that separated by a comma, they have no connection between each other, other than sharing the same properties.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Selector Types&lt;/h2&gt;

&lt;p&gt;In this article I will go over the simple selectors CSS has to offer, pseudo-class also considered simple selectors, but because of their importance, I will write about them in their own article and exclude them from this one.&lt;br&gt;We can divide the selectors to Elemental Selectors and Attribute Selectors.&lt;/p&gt;

&lt;h3&gt;Elemental Selectors&lt;/h3&gt;

&lt;p&gt;Elemental selectors are the type selector and the universal selector, they are looking at the element type of an element.&lt;/p&gt;

&lt;h4&gt;Type Selector&lt;/h4&gt;

&lt;p&gt;Type selectors, often called tag name or element selectors, are the most basic selector type. The selector looks for at least one instance of that element in the DOM tree.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets all &amp;lt;h3&amp;gt; HTML elements */
 h3 {
     property: value;
 }

/* Targets all &amp;lt;span&amp;gt; HTML elements */
 span {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h4&gt;Universal Selector&lt;/h4&gt;

&lt;p&gt;The universal selector, written with an asterisk ( * ) matches an element of any type. &lt;br&gt;The only elements that it can't select are the featureless elements, i.e. the ::before and ::after pseudo-elements are not affected by the universal selector.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 * {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targers all elements that are the descendants
of a &amp;lt;div&amp;gt; element */
 div * {
     property: value;
 }

/* Targers all &amp;lt;span&amp;gt; elements that are the descendants
of any element */
 * span {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Attribute Selectors&lt;/h3&gt;

&lt;p&gt;If an element has an attribute, we can use it to select the element. Using the attribute itself with the&lt;strong&gt; attribute presence and value selectors&lt;/strong&gt;, or by looking at the value with &lt;strong&gt;substring matching attribute selectors&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;Attribute Presence and Value Selectors&lt;/h4&gt;

&lt;p&gt;These selectors are matching against the attributes and the values in them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Matching the element with the specified attribute, no matter the value.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets all &amp;lt;input&amp;gt; elements that have a 
"placeholder" attribute */
 input[placeholder] {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Matching the element with the specified attribute with exactly the specified value.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute="value"] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets all &amp;lt;a&amp;gt; elements with the attribute "target" 
with exactly the value "_top" */ 
 a[target="_top"] {
     property: value;
 }
&lt;/code&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Matching the element with the specified attribute, that it values is a list of strings separated by whitespace, and the specified value is one of them.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre id="block-fe226752-f799-43b7-adaa-d1eeef22dc31"&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute~="value"] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets &amp;lt;input&amp;gt; elements with the attribute 
"class" that has the value "must" in it */
 input[class~="must"] {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Matches the element with the specified attribute, that it values is exactly the specified value or beginning with the specified value and immediately followed by ( - ).&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute|="value"] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets &amp;lt;a&amp;gt; elements with the attribute 
"hreflang" that the value is "en" or starts with "en-" */
 a[hreflang|="en"] {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h4&gt;&lt;strong&gt;Substring Matching Attribute Selectors&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;These selectors are matching a substring of the values in the attributes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Matching an element with the specified attribute, that it's value begins with the specified value. &lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute^="value"] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets all &amp;lt;a&amp;gt; elements with the "class" attribute 
with a value starting with "foo" */
 a[class^="foo"] {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Matching an element with the specified attribute, that it's value ends with the specified value.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute$="value"] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets &amp;lt;a&amp;gt; elements with the "href" attribute
with the value ending with ".com" */
 a[href$=".com"] {
     font-family: sans-serif;
 }
&lt;/code&gt;
&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Matching an element with the specified attribute, that has at least one instance of the specified value, in the attribute's value.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element[attribute$="value"] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets &amp;lt;a&amp;gt; elements with the "href" attribute
 with at least one instance of "%20" string */
 a[href*="%20"] {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Class Selector&lt;/h3&gt;

&lt;p&gt;The class selector is actually a special attribute selector. Because of its common use, it has a unique syntax.&lt;br&gt;We create a class attribute selector with the dot notation ( . ), immediately followed by the value of the class attribute in the element.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 .class_name {
     property: value;
 }

/* This syntax is equivalent to the first one */ 
 Element[class~=class_name] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets all the elements with the class "red-text"
 .red-text{
     property: value;
 } 

/* Targets only the elements that have both "left" 
and "small" classes */
 .left.small {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;ID Selector&lt;/h3&gt;

&lt;p&gt;The ID selector, like the class selector, is actually a special attribute selector and it has a unique syntax, we create an ID selector using the number sign ( # ), immediately followed by the id name.&lt;br&gt;The id selector has a special feature that it can be only once in a single document, no matter the element type, for example, we can't write the same id name to a span and an h3 element on the same document.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 #id_name {
     property: value;
 }

/* This syntax is equivalent to the first one */ 
 Element[id~=id_name] {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets the element that has "red-error-text" 
value in it's ID attribute */
 #red-error-text {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h2&gt;Combinators&lt;/h2&gt;

&lt;p&gt;As part of the Selector structure, we use combinators to build more complex Selectors and have more control over how we select elements from the DOM, by using combinators we can create selectors that match nested elements that may have no specified attribute, like an id or class attributes.&lt;/p&gt;

&lt;h3&gt;Descendant Combinator (   )&lt;/h3&gt;

&lt;p&gt;If we want to select a descendant of an element, we can use the Descendant Combinator, this combinator will help us match elements having to create them a specified id or class attribute.&lt;br&gt;The Descendant Combinator is whitespace " " that separates two compound selectors.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element_selector1 Element_selector2 {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets &amp;lt;li&amp;gt; elements that are the descendants of 
the .nav-bar element */ 
 .nav-bar li {
     property: value;
 } 

/* Targets &amp;lt;span&amp;gt; elements with the class "important"
which are the descendants of &amp;lt;p&amp;gt; elements which are 
the descendsnts of &amp;lt;div&amp;gt; elements which are the 
descendants of &amp;lt;section&amp;gt; element */
 section div p span.important {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Child Combinator ( &amp;gt; )&lt;/h3&gt;

&lt;p&gt;If we want to select the direct children without the descendants of an element we can use the Child Combinator. The Child Combinator is the "greater-than sign" ( &amp;gt; ) character that separates two compound selectors.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element_selector1 &amp;gt; Element_selector2 {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets &amp;lt;div&amp;gt; elements that are the direct children
of the &amp;lt;section&amp;gt; element */
 section &amp;gt; div {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Next-Sibling Combinator ( + )&lt;/h3&gt;

&lt;p&gt;If we want to select an element that is immediately following some other element, we can use the Next-sibling combinator.&lt;br&gt;The elements must share the same parent, and the first element in the selector has to be immediately before the second one.&lt;br&gt;The next-sibling combinator is the "plus sign" ( + ) character that separates two compound selectors.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element_selector1 + Element_selector2 {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets the &amp;lt;p&amp;gt; element that comes right after
&amp;lt;figure&amp;gt; element inside the &amp;lt;div&amp;gt; element */
 div figure + p {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Subsequent-Sibling Combinator ( ~ )&lt;/h3&gt;

&lt;p&gt;The subsequent-sibling combinator is the "Tilda" ( ~ ) character that separates two compound selectors.&lt;br&gt; The selector is represented by two sequences of simple selectors separated by the subsequent-sibling combinator, and they both share the same parent element, and unlike the next-sibling combinator, the second element doesn't have to come immediately after the first element.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 Element_selector1 + Element_selector2 {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets the &amp;lt;p&amp;gt; element that comes not necasseraly
immideatelly after &amp;lt;figure&amp;gt; element inside the 
&amp;lt;div&amp;gt; element */
 div figure ~ p {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Column Combinator ( || )&lt;/h3&gt;

&lt;p&gt;The column combinator is written by two pipes ( || ) selects the elements of a column element by looking at the relationship between it and the column it belongs to.&lt;br&gt;&lt;strong&gt;THIS COMBINATOR IS STILL ONLY AT THE EXPERIMENTAL STAGE AND MAY NOT WORK.&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;/* ---------- Selector Syntax ---------- */
 column_selector || cell_selector {
     property: value;
 }

/* ---------- Selector Examples ---------- */
/* Targets the &amp;lt;td&amp;gt; elements that belong to
&amp;lt;col&amp;gt; element with the class "blue-cell"  */
 col.blue-cell || td {
     property: value;
 }&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;This concludes my Basic Selectors article, all the pseudo-selectors will be explained in the next article.&lt;br&gt;Hope you enjoyed and leave a comment so I can improve and learn more!&lt;br&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>css</category>
    </item>
    <item>
      <title>Git - The Basics</title>
      <dc:creator>Michael Sayapin</dc:creator>
      <pubDate>Mon, 03 Aug 2020 10:00:50 +0000</pubDate>
      <link>https://forem.com/michael_sayapin/git-the-basics-4pcj</link>
      <guid>https://forem.com/michael_sayapin/git-the-basics-4pcj</guid>
      <description>&lt;h2&gt;
  
  
  What is Git?
&lt;/h2&gt;

&lt;p&gt;Git is a Version Control System (VCS). Version control is a system that keeps track of the changes we make to a file or a set of files over time so that we may recall an earlier version in the future.&lt;/p&gt;

&lt;h3&gt;
  
  
  Version Control System?
&lt;/h3&gt;

&lt;p&gt;VCS systems give us a lot of power over our projects, which sometimes can even save us from critical mistakes. Accidentally deleting files or messing up the code so much nothing works anymore, can frustrate any person, but with git, all you need to do is write some simple commands and it reverts as if nothing happened.&lt;br&gt;
Git can help us go back not only to the last version of our code but as many versions as we can only want, which can allow us even to compare changes over time and in case the same project is worked on by a team we can see who made modifications over time, who introduced an issue and much much more!&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Git Work?
&lt;/h3&gt;

&lt;p&gt;What git does is taking “snapshots” of the directory, and saves it locally. Those snapshots are saved in the git repository, and each time we make any change to the files, adding or deleting files git takes a new snapshot and saves it. Each snapshot is actually the current version of the project, in this article, we will talk about how it does it and how it affects the files in more details, so let's jump into it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Files states
&lt;/h3&gt;

&lt;p&gt;The most important thing to understand as a starting programmer in git is the three main states your files can reside in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Committed – which means that the data is safely stored in your local database.&lt;/li&gt;
&lt;li&gt;Modified – which means that you have changed the file but have not committed it to your database yet.&lt;/li&gt;
&lt;li&gt;Staged – which means that you have marked a modified file in its current version to go into your next commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This leads us to the three main sections of a git project: The git directory or the repository, the working directory, and the staging area.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jMGCv5MQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/07/untitled-1.png%3Fw%3D800" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jMGCv5MQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/07/untitled-1.png%3Fw%3D800" alt="three git sections" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The git directory is where git stores all the data of your project. The directory is the most important part of git, and it gets copied when you clone a repository to your computer.&lt;br&gt;
The working directory is your workstation, it contains one version of your project. Git pulls this version from the database (local or remote) on to your computer so you can use and modify it.&lt;br&gt;
The staging area is just a file, which is stored in your git directory, that contains information about what will go into your next commit.&lt;br&gt;
To understand better let’s look at the basic and most common git workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You modify or add files in your working tree.&lt;/li&gt;
&lt;li&gt;You select which changes you want to be part of your next commit, which adds only them to the staging area.&lt;/li&gt;
&lt;li&gt;You do a commit, which takes the files with the changes you selected from the staging area and stores them permanently to your git directory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, all left is to connect between the three file states to the three main git sections.&lt;br&gt;
If a particular version of a file is in the git directory, it is considered committed. If we make any change to that file, we added it to the staging area, and now the file is staged. And if the file was changed but has not been staged, the file is now modified.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let’s Get Our Hands Dirty
&lt;/h3&gt;

&lt;p&gt;There are two main ways to get out git repository start:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We can take a local directory that is not under version control and convert it into a Git repository.&lt;/li&gt;
&lt;li&gt;We can clone an existing Git repository from some other place.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Creating a Repository in an Existing Directory
&lt;/h4&gt;

&lt;p&gt;I will use a simple HTML file, Git bash terminal, and using Visual Studio Code IDE we can see the changes that occur at each step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hzd3ZYIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f1_starting_point-1.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hzd3ZYIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f1_starting_point-1.jpg%3Fw%3D1024" alt="Starting point" title="Starting Point" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will start by getting our terminal into the directory of our HTML file, you can see that my HTML file is in &lt;strong&gt;&lt;em&gt;/d/sandbox/git&lt;/em&gt;&lt;/strong&gt;, your directory can be in a different place than mine of course.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9pbJMWBR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f2_git_init.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9pbJMWBR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f2_git_init.jpg%3Fw%3D1024" alt="git init command" title="git init command" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next step is to type the &lt;strong&gt;&lt;em&gt;git init&lt;/em&gt;&lt;/strong&gt; command in our terminal, this creates a new subdirectory named .git that contains a git repository skeleton. At this point, nothing in our project is tracked by git.&lt;/p&gt;

&lt;h5&gt;
  
  
  VSCode note:
&lt;/h5&gt;

&lt;p&gt;A nice feature that Visual Studio Code gives, is that it paints our files in the directory (Explorer panel at the left side) and adds a ‘U’ next to the file name. The ‘U’ stands for ‘Untracked’, and in addition to all this, on the Activity Bar in the Source Control tab, it adds the number of changes our code has.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dtIBw2jO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f3_git_add-1.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dtIBw2jO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f3_git_add-1.jpg%3Fw%3D1024" alt="git add" title="git add" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We initialized git on our directory, but our repository is still empty, the next step is to add our HTML file to the next stage, the staging area. To do so we type &lt;strong&gt;&lt;em&gt;git add index.html&lt;/em&gt;&lt;/strong&gt;, but what will we do if we have more than one HTML file? In this case, we can use &lt;strong&gt;&lt;em&gt;git add *.html&lt;/em&gt;&lt;/strong&gt;, this command will add all the HTML files in our directory. Yet again we have a problem, what if we have a full directory project? With all sorts of files? For this situation, we can use &lt;strong&gt;&lt;em&gt;git add –A&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;git add ––all&lt;/em&gt;&lt;/strong&gt; which will update all our directory to the staging area.&lt;br&gt;
There is also the &lt;strong&gt;&lt;em&gt;git add .&lt;/em&gt;&lt;/strong&gt; command, which also adds all the files to the staging area, but the difference between it and &lt;strong&gt;&lt;em&gt;––all / –A&lt;/em&gt;&lt;/strong&gt; is that is doesn’t add all the content from sub-directories. &lt;/p&gt;

&lt;h5&gt;
  
  
  VSCode note:
&lt;/h5&gt;

&lt;p&gt;Now that we added our HTML file to the staging area, VSCode changed the ‘U’ to ‘A’ which stands for ‘Added’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PMwpbWgi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f4_git_commit-1.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PMwpbWgi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f4_git_commit-1.jpg%3Fw%3D1024" alt="git commit" title="git commit" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All left to do now, is to commit our files to the local git repository and create our first version of it. Typing &lt;strong&gt;&lt;em&gt;git commit -m “first commit”&lt;/em&gt;&lt;/strong&gt;  to the terminal will make git take a screenshot of all the files from the staging area, and store them in the git repository.&lt;/p&gt;

&lt;h5&gt;
  
  
  VSCode note:
&lt;/h5&gt;

&lt;p&gt;In the terminal we see a couple of lines explaining the commit we just did, I’ll explain the important parts:&lt;br&gt;
master (root-commit) – which branch we committed to.&lt;br&gt;
first commit – our message we passed to the commit -m flag.&lt;br&gt;
1 file changed – we added our HTML file to the repository.&lt;br&gt;
11 insertions (+) – the number of lines we added to the repository.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cloning an Existing Repository
&lt;/h4&gt;

&lt;p&gt;If we want to get a copy of an existing Git repository, we will use the command &lt;strong&gt;&lt;em&gt;git clone&lt;/em&gt;&lt;/strong&gt; in our terminal, and in addition to the project itself, we also receive a copy of the project’s history with all available versions of that project. To make this command work we need to add the URL from where we clone the project, so for example, we write:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;git clone https:// github.com / userName / repositoryName .git&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QERCLMF7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f5_git_clone-1.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QERCLMF7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f5_git_clone-1.jpg%3Fw%3D1024" alt="git clone" title="git clone" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This line will clone the repository stored in that URL to your directory and initialize a git repository skeleton along with it.&lt;/p&gt;

&lt;p&gt;Another option is to create a new directory using this command in our directory:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;git clone https:// github.com / userName / repositoryName .git myNewDiretoryName&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This command does the same but the target directory is called myNewDirectoryName.&lt;/p&gt;

&lt;h4&gt;
  
  
  Status of our files
&lt;/h4&gt;

&lt;p&gt;If you already have a working directory with files you created from scratch or cloned from some repository, each file in your working directory, can be one of two states: &lt;em&gt;tracked&lt;/em&gt; or &lt;em&gt;untracked&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Tracked files are files that were in the last commit, they can be modified, unmodified, or staged. In short, tracked files are files that git knows about.&lt;/p&gt;

&lt;p&gt;Untracked files are any other file in your working directory which weren’t in your last version of the repository. When you first clone a repository all your files will be tracked and unmodified, because git just checked them and they haven’t been modified.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0jwmxUaw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/git-status.png%3Fw%3D800" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0jwmxUaw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/git-status.png%3Fw%3D800" alt="git status" title="git status" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To know what is the status of the files in the directory we use &lt;strong&gt;&lt;em&gt;git status&lt;/em&gt;&lt;/strong&gt; command. For example, if we run this command just after cloning, we will see some messages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jvgVJzuC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f6_git_status-1.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jvgVJzuC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f6_git_status-1.jpg%3Fw%3D1024" alt="git status after clone" title="git status after clone" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;They mean you have a clean working directory, or in other words, all your tracked files are unmodified. In addition, Git doesn’t see any untracked files in your directory, or else you would have seen them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dYH5zZye--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f7_git_status_readme-2.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dYH5zZye--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f7_git_status_readme-2.jpg%3Fw%3D1024" alt="create new file" title="create new file" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s add a new file, a readme file to our directory, and then type &lt;strong&gt;&lt;em&gt;git status&lt;/em&gt;&lt;/strong&gt; again, we can see that now our new file is shown under untracked files and even shown in red, it’s asking us to use &lt;strong&gt;&lt;em&gt;git add&lt;/em&gt;&lt;/strong&gt; in the last sentence, so let’s add our new file to the staging area. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ww-_Po8Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f8_git_status_added_readme.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ww-_Po8Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f8_git_status_added_readme.jpg%3Fw%3D1024" alt="git status after new file" title="git status after new file" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now our new file is changed from untracked files to be under changes to be committed, and the file is now green.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VmASML11--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f9_git_status_modified_readme.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VmASML11--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f9_git_status_modified_readme.jpg%3Fw%3D1024" alt="git status after file modification" title="git status after file modification" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we add some text in the readme file now, it will be shown as a modified file as we can see next to the file name ‘M’, and in our terminal, we see it in both the changes to commit and in the changes not staged for commit. It happens because the creation of the file has been added to the staging area, but the changes we made didn’t. If we commit now, the changes will not be part of the commit. So to include the latest change to file all we need to do is to type the git add command one more time and then the last changes we made will be also committed. &lt;/p&gt;

&lt;h4&gt;
  
  
  Let’s talk about committing
&lt;/h4&gt;

&lt;p&gt;In the article, we already used the &lt;strong&gt;&lt;em&gt;git commit&lt;/em&gt;&lt;/strong&gt; command, but we didn’t fully understand what it does.&lt;/p&gt;

&lt;p&gt;Just a small reminder, that the only files that will get committed to our git repository, are the files you added to the staging area, other unstaged files will be left out and not be included in the next commit command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q0m3RaU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f10_git_simple_commit.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q0m3RaU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f10_git_simple_commit.jpg%3Fw%3D1024" alt="git commit" title="git commit" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, type in the most basic command &lt;strong&gt;&lt;em&gt;git commit&lt;/em&gt;&lt;/strong&gt;, doing so will open your editor with the file which gives some information about the commit. We see all the details regarding our commit, all we need to do is write a message for the commit to start, as a commit cannot be without a message.&lt;/p&gt;

&lt;p&gt;All the lines starting with # are only there to summerise the commit and are optional, deleting or not will not affect the commission. Once we typed in our message we close the file and the commit is completed.&lt;/p&gt;

&lt;p&gt;A very common and way more convenient way to commit is to use a flag to shorten the commit step ‘&lt;strong&gt;&lt;em&gt;-m&lt;/em&gt;&lt;/strong&gt;‘, all it does is letting us write the commit message right in the commit line instead of opening the editor typing the message and closing it.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;git commit -m 'Your message goes here'&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Deleting files
&lt;/h4&gt;

&lt;p&gt;So we have our project all well and good, but there is a file we forgot about that we want to delete, how do we get it removed?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--__3Vyfcc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f11_git_before_delete.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--__3Vyfcc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f11_git_before_delete.jpg%3Fw%3D1024" alt="Before deleting" title="Before deleting" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a couple of answers, the question is in what stage does the file in? Is the file staged? Has the file been committed? or still untracked?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yh3qbDWd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f12_delete_untracked.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yh3qbDWd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f12_delete_untracked.jpg%3Fw%3D1024" alt="deleting untracked file" title="deleting untracked file" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the file didn’t get committed or staged we can use &lt;strong&gt;&lt;em&gt;rm &lt;/em&gt;&lt;/strong&gt;, and in the terminal after typing &lt;strong&gt;&lt;em&gt;git status&lt;/em&gt;&lt;/strong&gt;, the untracked file will not show up at all.&lt;/p&gt;

&lt;p&gt;If the file was already added to the staging area, we can use &lt;strong&gt;&lt;em&gt;git restore ––staged &lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
to un-stage the file, and use &lt;strong&gt;&lt;em&gt;rm &lt;/em&gt;&lt;/strong&gt; to delete the file completely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ufsw4Sek--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f13_delete_committed.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ufsw4Sek--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f13_delete_committed.jpg%3Fw%3D1024" alt="deleting a committed file" title="deleting a committed file" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the file is already known by git then using &lt;strong&gt;&lt;em&gt;git rm &lt;/em&gt;&lt;/strong&gt; is the better option because if we type this command without the &lt;strong&gt;&lt;em&gt;git&lt;/em&gt;&lt;/strong&gt; keyword the file will get deleted but the change will be unstaged and we will have to manually stage the deletion to the staging area while using the git keyword it will stage the deletion automatically for the next commit.&lt;/p&gt;

&lt;p&gt;A small side note, if we try and type &lt;strong&gt;&lt;em&gt;git rm &lt;/em&gt;&lt;/strong&gt; while the file is not known by Git, it will give an error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting to Github
&lt;/h3&gt;

&lt;p&gt;After we talked about all the basics of git, how it works, and what it does, it is time to share the code we wrote with the world.&lt;br&gt;
In this article, I will use GitHub as an example, but connecting to other online repositories may be possible exactly in the same way if not only a little different.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BdqFuLdM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f14_git_remote.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BdqFuLdM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f14_git_remote.jpg%3Fw%3D1024" alt="git remote" title="git remote" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First let’s type in the command &lt;strong&gt;&lt;em&gt;git remote&lt;/em&gt;&lt;/strong&gt; to check if we already have any remote repositories connected, if the command returned with no output then there are no repositories connected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v5E7ySWR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f15_git_remote_add.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v5E7ySWR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f15_git_remote_add.jpg%3Fw%3D1024" alt="adding remote repository" title="adding remote repository" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to add a remote repository we use the command &lt;strong&gt;&lt;em&gt;git remote add&lt;/em&gt;&lt;/strong&gt; with two other parameters, first one is the name you give to your remote, second parameter is the URL of the remote.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;git remote add  &lt;/em&gt;&lt;/strong&gt;, in the example above I chose to name my remote as "myGitHub", and wrote the URL to remote repository right after. &lt;br&gt;
We can see that after adding the remote if we type &lt;strong&gt;&lt;em&gt;git remote&lt;/em&gt;&lt;/strong&gt; once more, it will return our remote with the name I gave to it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Pulling and fetching from remote
&lt;/h4&gt;

&lt;p&gt;To get data from the remote projects, we can use &lt;strong&gt;&lt;em&gt;git fetch&lt;/em&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;em&gt;git pull&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fWTmOesh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f16_git_fetch.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fWTmOesh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f16_git_fetch.jpg%3Fw%3D1024" alt="git fetch and merge" title="git fetch and merge" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s have a look at &lt;strong&gt;&lt;em&gt;git fetch &lt;/em&gt;&lt;/strong&gt; first, in my example I named my remote "myGitHub" when I added it, but if you first cloned to your directory a remote repository, then the default name is ‘origin’.&lt;/p&gt;

&lt;p&gt;What it does, is downloading any changes that happened to the remote repository since you last cloned or fetched from it. It is important to note that it doesn’t merge or modify any files on your local directory automatically, so you have to merge it manually using the &lt;strong&gt;git merge /master&lt;/strong&gt;*, which will merge your directory with the downloaded files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N2fxlAEe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f17_git_pull.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N2fxlAEe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f17_git_pull.jpg%3Fw%3D1024" alt="git pull and merge" title="git pull and merge" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now for &lt;strong&gt;&lt;em&gt;git pull  &lt;/em&gt;&lt;/strong&gt;, it does exactly as git fetch, downloading the latest changes from the remote to your local repository, the difference is that &lt;strong&gt;&lt;em&gt;git pull&lt;/em&gt;&lt;/strong&gt; tries to merge automatically the changes into the code you are currently working on.&lt;/p&gt;

&lt;h4&gt;
  
  
  Pushing Back to Your Remote
&lt;/h4&gt;

&lt;p&gt;Finally, after a long journey of git commands, creating, deleting, modifying files, and committing it all to your local git repository, it is time to publish and share your project.&lt;/p&gt;

&lt;p&gt;To push your project to your remote repository all you need to type is:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;git push  &lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m-quUAlK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f18_git_push.jpg%3Fw%3D1024" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m-quUAlK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://wingedblackcatcode.files.wordpress.com/2020/08/f18_git_push.jpg%3Fw%3D1024" alt="git push to remote" title="git push to remote" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  That is all for the Git basics, using VScode and GitHub, hope you enjoyed my article, and stay tuned for more!
&lt;/h3&gt;

</description>
      <category>git</category>
      <category>github</category>
    </item>
  </channel>
</rss>
