<?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: FrontEndLord</title>
    <description>The latest articles on DEV Community by FrontEndLord (@frontendlord).</description>
    <link>https://dev.to/frontendlord</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%2F1046759%2F34b0b14b-4163-4b0e-bb95-ca717f3b32a5.png</url>
      <title>DEV Community: FrontEndLord</title>
      <link>https://dev.to/frontendlord</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frontendlord"/>
    <language>en</language>
    <item>
      <title>[attribute="value"] vs [attribute*="value"]! Know the difference</title>
      <dc:creator>FrontEndLord</dc:creator>
      <pubDate>Thu, 29 Jun 2023 16:28:41 +0000</pubDate>
      <link>https://dev.to/frontendlord/attributevalue-vs-attributevalue-know-the-difference-2hoe</link>
      <guid>https://dev.to/frontendlord/attributevalue-vs-attributevalue-know-the-difference-2hoe</guid>
      <description>&lt;p&gt;When working with CSS, you often need to select and style elements based on their attributes. Two common selectors for attribute selection that we all use are &lt;strong&gt;[attribute="value"] **and **attribute.value&lt;/strong&gt;. While they may seem similar at first, they have distinct differences in functionality and use cases. In this article, I will explore these differences and help you understand when to use each selector. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;'[attribute="value"]'&lt;/strong&gt; Selector&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;This attribute selector is the specific of the pair. It only allows you to target elements with a specific attribute value. It is so specific that matches elements where the attribute's value is an exact match to the specified value. &lt;/p&gt;

&lt;p&gt;Let me show you what I mean by this:&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;input type="text" name="name" placeholder="Enter your Full names"&amp;gt;
&amp;lt;input type="email" name="email" placeholder="Enter your email"&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input[type="text"] {
  /* Styles will only be applied to input elements with type="text" */
/* type="email" will not be affected by this selection */
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, the CSS selector &lt;strong&gt;input[type="text"]&lt;/strong&gt; only selects the &lt;strong&gt;&lt;/strong&gt; element with &lt;strong&gt;type="text"&lt;/strong&gt; only. This selector is precise and targets only elements with the exact attribute value of "text". It provides a way to apply specific styles to elements based on their attribute values.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;'[attribute*="value"]'&lt;/strong&gt; Selector&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Think of this selector like the laid back parent between the two, it is the mom - or the dad if your mom is an African mom. It is so laid back that it targets elements based on the presence of a specified attribute, regardless of its value.&lt;/p&gt;

&lt;p&gt;It does not consider the attribute value but focuses on the attribute's existence itself. Let me show you what I mean:&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;input id="registration 1" type="text" name="name" placeholder="Enter your Full names"&amp;gt;
&amp;lt;input id="registration 2" type="email" name="email" placeholder="Enter your email"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[id*=1]{
/* Although they both have the same id of registration, .2 will not be selected*/
/*If any styles will be applied, .2 will be left untouched*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you for reading, I am open to criticism.&lt;/p&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
