In css, you can clear it by setting the "p {padding:0;margin: 0;-webkit-margin-before: 0;-webkit-margin-after: 0;}" style to the p tag The spacing of the p tag itself.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In HTML, each tag has a default style. For example, the p tag itself has spacing:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> p { border: 1px solid red; } </style> </head> <body> <p>hello</p> <p>hello</p> </body> </html>
So how to remove the spacing of the p tag itself?
We can use the margin and padding attributes and set their values to 0:
p { padding:0; margin: 0; }
In this way, the p tag's own spacing can be cleared:
But in some browsers, even so, there are still top and bottom margins, because
here-webkit-margin-after
and -webkit-margin-before
both have 1rem, so it is best to set both of them to 0
-webkit-margin-before: 0; -webkit-margin-after: 0;
(Learning video sharing: css video tutorial)
The above is the detailed content of How to clear the p tag's own spacing in css. For more information, please follow other related articles on the PHP Chinese website!