<?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: DanishOnGit</title>
    <description>The latest articles on DEV Community by DanishOnGit (@danishongit).</description>
    <link>https://dev.to/danishongit</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%2F518558%2F0c4650e6-fdb1-4dc3-ab62-32b914d76893.png</url>
      <title>DEV Community: DanishOnGit</title>
      <link>https://dev.to/danishongit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danishongit"/>
    <language>en</language>
    <item>
      <title>CSS Selectors &amp; Specificity: Beginner's Guide </title>
      <dc:creator>DanishOnGit</dc:creator>
      <pubDate>Sat, 05 Dec 2020 15:44:52 +0000</pubDate>
      <link>https://dev.to/danishongit/css-selectors-specificity-beginner-s-guide-38n9</link>
      <guid>https://dev.to/danishongit/css-selectors-specificity-beginner-s-guide-38n9</guid>
      <description>&lt;p&gt;While styling certain elements in HTML, we notice that certain styles don't work as per our wishes. Sometimes, there occurs an error in our syntax. But sometimes not! &lt;br&gt;
Therefore,here,some knowledge about CSS selectors and specificity might prove helpful.&lt;/p&gt;

&lt;p&gt;Keep reading.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;CSS Selectors:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A selector is used to 'find' the HTML element we wish to style.&lt;br&gt;
There are many &lt;a href="https://www.w3schools.com/css/css_selectors.asp"&gt;categories&lt;/a&gt; of selectors but we will focus our attention on the simplest of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Almost all beginners know the following list but let us revise.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Following are the simple selectors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Element selector&lt;/strong&gt;- eg: div, h1, p, a&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Class selector&lt;/strong&gt;- eg: .xyz , .anyname&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Id selector&lt;/strong&gt;- eg: #xyz, #anyname&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Element selector:&lt;/strong&gt;Here all &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements on the page will have red text colour.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p {
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;2.&lt;strong&gt;Class selector:&lt;/strong&gt;Here all elements with class &lt;code&gt;.center&lt;/code&gt; will have red text colour.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.center {
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;Id selector:&lt;/strong&gt;Here the element with Id &lt;code&gt;#center&lt;/code&gt; will have text colour red.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#center {
  color: red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now that we have revised the basics, let us try to guess the output for the following code.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML: &amp;lt;p class="para" id="para"&amp;gt;How are you?&amp;lt;/p&amp;gt;

CSS:

.para{
    color: teal;
}
#para{
    color: yellowgreen;
}
p.para#para{
    color: yellow;
}
p.para{
color: tomato;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What will be the colour of the output text?&lt;/p&gt;

&lt;p&gt;Well, the answer is; output text colour will be yellow. But how did the browser decide which rule is most relevant to the element?&lt;br&gt;
Here is where the concept of &lt;strong&gt;Specificity&lt;/strong&gt; comes into picture.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;CSS Specificity:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Specificity is the weight applied to a CSS declaration. It comes into play when there are two or more conflicting CSS rules applied to the same element (as we have seen in above problem).&lt;br&gt;
What is this weight? This weight is a number which is determined by the type of CSS selectors(the simplest of which we have seen above) used to find the particular element in HTML.&lt;/p&gt;

&lt;p&gt;Can we calculate specificity? &lt;strong&gt;Of course.&lt;/strong&gt; Let us see how.&lt;/p&gt;

&lt;p&gt;Start at 0, add 1000 for inline style attribute, add 100 for each ID selector, add 10 for each class (or pseudo-class) attribute, add 1 for each element name (or pseudo-element).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Inline style means styling which is applied directly to the element in your HTML file . Eg:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h2 style="color:red;"&amp;gt; Hello world&amp;lt;/h2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inline styles have highest specificity and hence override any other style in external sheet (unless we find any &lt;code&gt;!important&lt;/code&gt; rule.)&lt;/p&gt;

&lt;p&gt;Let us see our earlier problem again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML: &amp;lt;p class="para" id="para"&amp;gt;How are you?&amp;lt;/p&amp;gt;

CSS:

.para{
    color: teal;
}
#para{
    color: yellowgreen;
}
p.para#para{
    color: yellow;
}
p.para{
color: tomato;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.para&lt;/code&gt; declaration has specificity = 10&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#para&lt;/code&gt; declaration has specificity = 100&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;p.para#para&lt;/code&gt; declaration has specificity = 1+10+100= 111&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;p.para&lt;/code&gt; declaration has specificity = 1+10= 11&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hence, the third rule which has the &lt;strong&gt;highest specificity&lt;/strong&gt; is finally applied!&lt;/p&gt;

&lt;p&gt;So, to summarize, ascending order of specificity is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Universal selector &lt;code&gt;*&lt;/code&gt; has zero specificity&lt;/li&gt;
&lt;li&gt;Elements (&amp;amp; pseudo-elements) have specificity 1&lt;/li&gt;
&lt;li&gt;Class selector (&amp;amp; attributes &amp;amp; pseudo-classes) has specificity 10&lt;/li&gt;
&lt;li&gt;Id selector has specificity 100&lt;/li&gt;
&lt;li&gt;Inline styles have specificity 1000&lt;/li&gt;
&lt;li&gt;If two or more than two rules have equal specificity then the last rule in the CSS is applied.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, the next time a certain element doesn't get styled as per our wish, changing the specificity can come in handy!&lt;br&gt;
&lt;strong&gt;Keep Learning !&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>'.com',The King of TLDs?</title>
      <dc:creator>DanishOnGit</dc:creator>
      <pubDate>Thu, 26 Nov 2020 18:24:12 +0000</pubDate>
      <link>https://dev.to/danishongit/com-the-king-of-tlds-1kbi</link>
      <guid>https://dev.to/danishongit/com-the-king-of-tlds-1kbi</guid>
      <description>&lt;p&gt;All websites we visit have a domain name. There is one part of it  which we all are familiar with, the &lt;strong&gt;'.com'&lt;/strong&gt;. What is with '.com' that makes it so much popular? Should all websites go for a '.com'? Is not having a '.com' disadvantageous?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This article focuses on such questions around the '.com'.&lt;/strong&gt; &lt;br&gt;
Keep reading.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a TLD?
&lt;/h3&gt;

&lt;p&gt;A top-level domain (TLD) is the last segment of a domain name, i.e. the element located after the last dot. It is also known as a 'domain suffix' or 'URL extension'.&lt;br&gt;
Let us understand with an example domain name-&lt;br&gt;
&lt;strong&gt;store.mywebsite.com&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;store&lt;/strong&gt;- is the subdomain&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;mywebsite&lt;/strong&gt;- is the second-level domain&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;.com&lt;/strong&gt;-is the top-level domain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A TLD can help you identify the purpose of a website or even the geographic location. In the above example, .com shows that the site is a commercial site. &lt;/p&gt;

&lt;p&gt;You can read more about TLDs &lt;a href="https://www.hostinger.in/tutorials/what-is-tld"&gt;Here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are a numerous TLDs to choose from for your domain name, but .com remains the most popular for most users.&lt;/p&gt;

&lt;p&gt;Why?&lt;br&gt;
Let's see.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reasons for the popularity of '.com'.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1) It is important for branding and authority:&lt;/strong&gt;&lt;br&gt;
      If you can get it, then get it. The reason the giants have the .com is because it is necessary to demonstrate authority, longevity and trust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) It's one of the earliest TLDs:&lt;/strong&gt;&lt;br&gt;
      The .com domain extension has been synonymous with the internet since the “dot-com bubble” in the late 1990s. Over 45% of all registered domain names are .com domains. A lot of other TLDs are too recent to catch up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) Better click-through rate:&lt;/strong&gt;&lt;br&gt;
If you search for some information on google and you see one website with a .com and another with a .net or .biz, which one do you choose to click on? Assuming you know nothing about both websites, you are more likely to click on the website with the .com version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4) Better resale value:&lt;/strong&gt;&lt;br&gt;
Buying a .com is an investment too. Yes! You read that right. Resale value of .com is 5x-100x higher than any equivalent keyword with a different extension! Especially if it's a catchy combination of words.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5) It's a blank canvas:&lt;/strong&gt;&lt;br&gt;
Having a .com gives a business the widest range of branding options. Building on, say, .pizza or .club imposes certain limits on brand identity.&lt;/p&gt;

&lt;p&gt;Hence, the .com still remains the most popular among all TLDs though its availability is limited and can turn out to be extremely expensive in certain cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, will a non .com domain name hurt your company's business?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a very subjective question and can have three possible answers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) A non .com TLD will help customers remember your brand and serve as a unique differentiator which helps you stand out from the crowd:&lt;/strong&gt;&lt;br&gt;
      A good example here can be the .io TLD. This is pretty much in vogue these days among mostly tech-startups. However it doesn't have much mass consumer appeal.&lt;br&gt;
Similarly, you can have .pizza, .club and many more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) A non .com TLD will make your brand seem suspect and less reputable:&lt;/strong&gt;&lt;br&gt;
Seeing a non .com site automatically makes people notice it. Some may even choose to not click on it just because they don't feel good about the non .com domain name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3)Customers won’t notice your TLD or won’t care about it:&lt;/strong&gt;&lt;br&gt;
This scenario is also quite possible. A fine example is Behance. It sports a .net extension and is doing fine with it.&lt;/p&gt;

&lt;p&gt;Another concern with a non .com TLD is related to SEO. Will a non .com domain hurt my SEO ranking?&lt;br&gt;
&lt;strong&gt;Here's the answer:&lt;/strong&gt;Google's Guide on &lt;a href="https://domains.google/learn/traditional-vs-new-domain-endings/#/"&gt;Traditional vs New domain endings&lt;/a&gt; says, &lt;em&gt;"Using a new domain ending will not hurt your search presence."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In other words, .com domains do not rank higher because of their TLD. However, they may indirectly rank higher due to Google's preference for aged brands. An aged brand is a website or a company with a long track record of quality content, frequent updates and technical uptime. And most aged brands are likely to be a .com. So if you are thinking of purchasing an existing website, a .com domain name might indirectly provide more search value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing thoughts:
&lt;/h3&gt;

&lt;p&gt;A .com domain is not needed by everyone. It is desirable if you have a B2B business. In fact, having a new TLD can help your brand stand out. But what is more important is creating a brand that you believe in rather than worrying about your TLD.&lt;br&gt;
Finally, it's always possible that your TLD won't affect your brand positively or negatively.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
