-1

I want to make a image at the top of a html file fit across the whole screen with no gaps how can I do this?

<!DOCTYPE html>
<html>
<head>
    <title>Coding site!</title>
    <link rel="stylesheet" type="text/css" href="style.css">
     <script src="myscripts.js"></script> 
</head>
<body>
    <img src="coding.jpg" style="width:42px;height:42px;">
</body>
</html> 

3 Answers3

1

The "gap" is present because in most major browsers, the default margin on the body element is 8px on all sides. To remove it, add the following CSS styling:

body {
  margin: 0;
  padding: 0;
}
<!DOCTYPE html>
<html>
<head>
    <title>Coding site!</title>
    <link rel="stylesheet" type="text/css" href="style.css">
     <script src="myscripts.js"></script> 
</head>
<body>
    <img src="https://source.unsplash.com/random" style="width:42px;height:42px;">
</body>
</html> 
AnsonH
  • 1,525
  • 2
  • 12
  • 25
1

Make its width 100% and margin 0px.

Dharman
  • 26,923
  • 21
  • 73
  • 125
1

To suit the image to the frame set the width to 100%,and set the body padding: 0; and margin: 0; in the internal CSS file.

Raymart
  • 26
  • 4