Link to home
Start Free TrialLog in
Avatar of csehz
csehzFlag for Hungary

asked on

CSS - Absolute 0 margin for texts

Dear Experts,

Could you please have a look on the below attached picture, applying this CSS code so having both margin 0 and padding 0 for the text, there can be seen a small place above of it in the browser.

<!doctype html>
<html>
<head>
<style>
body { margin: 0px; background: #eee; }
#box { width:150px; height: 150px; background:#aaa; }
p { margin: 0; padding: 0; } 
</style>
</head>
<body>
	<div id="box">
		<p>Test text</p>
	</div>
</body>
</html>

Open in new window


User generated image
Could you advise is that normal like that or something is needed for the "absolute 0 margin"?

thanks,
ASKER CERTIFIED SOLUTION
Avatar of Kyle Hamilton
Kyle Hamilton
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csehz

ASKER

Thanks so in general terms the answer is for that small space that it is the line-height, which can be decreased but that has effect on the second line as will be closer to the first one
yes. line height is the space between lines. If you don't want to decrease the line height, and you really want to raise the text all the way to the top, you could also try giving the box or the p element a negative margin-top. I'm not sure if any of that is worth it though.