Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing horizontal gap between image tags HTML/CSS [duplicate]

Tags:

html

css

I was just practicing HTML and CSS and I ran into an annoying problem. I am wondering what is that horizontal gap and how to remove it?

Thanks in advance

enter image description here

<!DOCTYPE html>
<html lang="en">
   <head>
      <title>Practice</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
      <meta content="utf-8" http-equiv="encoding" />
      <style>
         html,body
         {
         margin:0; padding:0; height:100%;
         }
      </style>
   </head>
   <body>
      <script src="./js/jQuery.js"></script>

      <img id="sample-img" src="Green-Nature-wallpaper.jpg" style="margin:0; padding:0;"></img>
      <img id="sample-img2" src="Green-Nature-wallpaper.jpg" style="margin:0; padding:0;"></img>
      <script>
         $( document ).ready(function () {
            $("#sample-img").width($(window).width());
            $("#sample-img").height(0.6*$(window).height());
            $("#sample-img2").width($(window).width());
            $("#sample-img2").height(0.6*$(window).height());
         });
         $(window).resize(function() {
            $("#sample-img").width($(window).width());
            $("#sample-img").height(0.6*$(window).height());
            $("#sample-img2").width($(window).width());
            $("#sample-img2").height(0.6*$(window).height());
         });
      </script> 
   </body>
</html>
like image 790
Node.JS Avatar asked Oct 30 '25 04:10

Node.JS


1 Answers

Have you tried setting the image margin and padding to 0?

<style>
    img {
        position:relative;
        display:block;
        margin:0;
        padding:0;
    }
</style>
like image 127
Tai Kwangi Chicken Avatar answered Oct 31 '25 17:10

Tai Kwangi Chicken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!