Skip to content Skip to sidebar Skip to footer

Iframe Body Remove Space

My iframe a style of style='width:100%', and it almost covers the page width. But it leaves a small margin on the left and right side. So I added body { margin:0px; } to remove the

Solution 1:

You should do some like:

body{margin:0} // remove body margin

iframe{margin:0;width:100%}//remove iframe margin

p,div{margin:10px} //append margin to p and other tags

Demo for your case:

<!DOCTYPE html>
<html>
<head>
<style>
    body{margin:0}
    iframe{margin:0;width:100%}
    p{margin:10px}
</style>
</head>
<body>
    <p> hello </p>
    <iframe src="http://www.weather.com" style="width:100%; height:95%; margin:0px"></iframe>
</body>
</html>

Solution 2:

As you can see, you can use body{margin:0 0 0 0px;} for top, right, bottom, left. You will be able to remove all spaces from browser.

<!DOCTYPE html>
<html>
<style type="text/css">
body {
    margin:0 0 0 0px;
}
</style>
<body>
<iframe src="http://www.weather.com" style="width:100%; height:95%; margin:0px"></iframe>
</body>
</html>

Solution 3:

what's wrong with:

iframe {
  margin: 0;
}

in your iframe containg page


Post a Comment for "Iframe Body Remove Space"