<?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: Aanshik Sharma</title>
    <description>The latest articles on DEV Community by Aanshik Sharma (@aanshik_sharma_26dd97ab33).</description>
    <link>https://dev.to/aanshik_sharma_26dd97ab33</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3977606%2Fffa7648a-dc26-46d3-87ba-70ede577bf59.jpg</url>
      <title>DEV Community: Aanshik Sharma</title>
      <link>https://dev.to/aanshik_sharma_26dd97ab33</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aanshik_sharma_26dd97ab33"/>
    <language>en</language>
    <item>
      <title>The CSS Media Query That Changed How I Approach Responsive Design</title>
      <dc:creator>Aanshik Sharma</dc:creator>
      <pubDate>Wed, 17 Jun 2026 17:30:00 +0000</pubDate>
      <link>https://dev.to/aanshik_sharma_26dd97ab33/the-css-media-query-that-changed-how-i-approach-responsive-desig-c1a</link>
      <guid>https://dev.to/aanshik_sharma_26dd97ab33/the-css-media-query-that-changed-how-i-approach-responsive-desig-c1a</guid>
      <description>&lt;p&gt;I was working on the responsiveness of my portfolio website when I discovered a CSS media query that changed how I think about responsive design.&lt;/p&gt;

&lt;p&gt;I initially thought I needed a way to detect whether the website was being viewed on a mobile device or tablet.&lt;/p&gt;

&lt;p&gt;I did that by checking if the height of the document body was greater than its width hoping it would be a reliable solution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isVertical&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientHeight&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientWidth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I realized that I was checking the device’s portrait orientation instead of checking for the device type.&lt;/p&gt;

&lt;p&gt;While researching the issue, I encountered this CSS media query that checks if the user’s &lt;strong&gt;primary input device can conveniently hover over DOM elements.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* styles for devices that support hover */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tailwind also supports this through arbitrary variants&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Card&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"[@media(hover:hover)]:bg-teal-800"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Devices that match&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Desktops with mouse&lt;/li&gt;
&lt;li&gt;Laptops with trackpad&lt;/li&gt;
&lt;li&gt;Most devices with a mouse pointer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Devices that do not match&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Touch-only phones&lt;/li&gt;
&lt;li&gt;Touch-only tablets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, devices with an attached mouse or trackpad may behave differently&lt;/p&gt;

&lt;p&gt;For example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.button&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;.button&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nc"&gt;.card&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="nc"&gt;.button&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On mobile devices,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The button is always visible&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:hover&lt;/code&gt; rules are ignored&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On a laptop,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The button starts hidden&lt;/li&gt;
&lt;li&gt;Appears when the card is hovered&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This can also be used the other way around to explicitly check if the device is &lt;strong&gt;unable to hover&lt;/strong&gt; over DOM elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* styles for devices that do not support hover */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or in tailwind as &lt;code&gt;[@media(hover:none)]:bg-teal-800&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Another useful media feature is &lt;code&gt;@media (pointer: fine)&lt;/code&gt;, which checks pointer precision of the primary pointing device. A table below describes how both the queries respond with primary input devices.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Device&lt;/th&gt;
&lt;th&gt;Hover&lt;/th&gt;
&lt;th&gt;Pointer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mouse&lt;/td&gt;
&lt;td&gt;hover&lt;/td&gt;
&lt;td&gt;fine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trackpad&lt;/td&gt;
&lt;td&gt;hover&lt;/td&gt;
&lt;td&gt;fine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Finger touch&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;coarse&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stylus&lt;/td&gt;
&lt;td&gt;usually hover; could be none depending on the device&lt;/td&gt;
&lt;td&gt;fine&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Pointer characteristics are implementation-dependent and may vary across browsers and operating systems.&lt;/p&gt;

&lt;p&gt;Since we have already discussed &lt;code&gt;hover&lt;/code&gt; and &lt;code&gt;pointer&lt;/code&gt; there are two important properties that I believe must be mentioned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;any-hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hover&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* styles */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;any-pointer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;/* styles */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These differ from&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;hover&lt;/span&gt;
&lt;span class="nt"&gt;pointer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;because they consider &lt;strong&gt;all available inputs&lt;/strong&gt; rather than just the primary one.&lt;/p&gt;

&lt;p&gt;For example,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tablet + mouse attached&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;might report&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;hover&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;none&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;any-hover&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;hover&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This was a small discovery, but it changed the way I approach responsive design. If you're building interactions that depend on hover or pointer precision, these media queries are worth keeping in mind.&lt;/p&gt;

</description>
      <category>css</category>
      <category>design</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to fix your last commit without creating a new one...</title>
      <dc:creator>Aanshik Sharma</dc:creator>
      <pubDate>Wed, 10 Jun 2026 14:30:00 +0000</pubDate>
      <link>https://dev.to/aanshik_sharma_26dd97ab33/how-to-fix-your-last-commit-without-creating-a-new-one-5232</link>
      <guid>https://dev.to/aanshik_sharma_26dd97ab33/how-to-fix-your-last-commit-without-creating-a-new-one-5232</guid>
      <description>&lt;p&gt;One habit quietly polluted my Git history for months. Sometimes when we make a commit and realize that a feature has been left uncommitted, we just create a new commit with a commit message close to “Project feature update final final v2”.&lt;/p&gt;

&lt;p&gt;There is actually nothing wrong with it except the fact that it really builds up the commit history with utter nonsense commit messages. This, feeds ambiguity and ambiguity kills systems.&lt;/p&gt;

&lt;p&gt;However, this can be fixed by a simple command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--amend&lt;/code&gt; flag replaces the previous commit with a new version of that commit. To you it looks like the old commit was edited, but Git actually rewrites that part of history.&lt;/p&gt;

&lt;p&gt;It can be thought of as replacing the previous commit with a new one; all the changes from the previous commit persist while the new changes also appear in the HEAD node, without clogging up the commit history.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Edit the last commit message&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Opens your default editor to modify the message.&lt;br&gt;
Or you can do it directly without opening an editor:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Commit Message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Change Author or Commit Date&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--author&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Jane Doe &amp;lt;janedoe@gmail.com&amp;gt;"&lt;/span&gt;
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--date&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"2026-06-10T12:00:00"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Amend a commit without changing the commit message&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add forgotten-file.js
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--no-edit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the commit has not been pushed yet, the above commands are usually all you need. But if the commit was pushed, two cases emerge:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You are working alone or on a private branch&lt;/p&gt;

&lt;p&gt;In this case, you can just push the amended commit using&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt; origin &amp;lt;branch-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This safely overwrites the remote branch only if no one else has pushed changes since your last fetch.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Always use &lt;code&gt;--force-with-lease&lt;/code&gt; instead of &lt;code&gt;--force&lt;/code&gt; to prevent accidentally deleting a teammate’s work if they pushed while you were amending.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are working on a shared branch with your teammates&lt;/p&gt;

&lt;p&gt;If the commit has already been pushed to a shared branch, avoid amending it unless everyone collaborating on the branch understands that history is being rewritten. In most team environments, creating a follow-up commit is usually safer than force-pushing rewritten history.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Hello World</title>
      <dc:creator>Aanshik Sharma</dc:creator>
      <pubDate>Wed, 10 Jun 2026 13:34:06 +0000</pubDate>
      <link>https://dev.to/aanshik_sharma_26dd97ab33/hello-world-1008</link>
      <guid>https://dev.to/aanshik_sharma_26dd97ab33/hello-world-1008</guid>
      <description>&lt;p&gt;Hi, I'm Aanshik.&lt;/p&gt;

&lt;p&gt;I've always found myself chasing questions.&lt;/p&gt;

&lt;p&gt;Sometimes those questions are related to software. Sometimes they're about how computers work under the hood. Sometimes they're completely unrelated to anything I need for a project, an exam, or a career.&lt;/p&gt;

&lt;p&gt;I simply enjoy understanding things.&lt;/p&gt;

&lt;p&gt;Over the years, I've learned a lot of interesting concepts, solved a lot of frustrating problems, and discovered plenty of things that made me stop and think, "I wish I had known this earlier."&lt;/p&gt;

&lt;p&gt;The problem is that these lessons tend to disappear. We learn something, use it once, and move on to the next challenge.&lt;/p&gt;

&lt;p&gt;This blog is my attempt to change that.&lt;/p&gt;

&lt;p&gt;Rather than letting ideas fade away, I want to document them. Some posts may be technical. Others may be observations, experiments, lessons, mistakes, or rabbit holes I happened to fall into while trying to understand something.&lt;/p&gt;

&lt;p&gt;I don't know exactly what this blog will become, and that's part of the reason I'm excited to start it.&lt;/p&gt;

&lt;p&gt;What I do know is that I'm curious, and curiosity has led me to some interesting places so far.&lt;/p&gt;

&lt;p&gt;This blog is simply a record of that journey.&lt;/p&gt;

&lt;p&gt;Let's see where it goes.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>devjournal</category>
      <category>learning</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
