Home > Article > Web Front-end > How to remove spaces in html
How to remove spaces in html: First open the corresponding HTML code file; then set the "font-size:0;" style on the parent element to remove the spaces caused by line breaks between html code tags.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
How to remove the spaces caused by line breaks between HTML code tags
Recommended method: Set
font-size on the parent element: 0;
Example:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> body { margin: 0; padding: 0; } p { height: 41px; border-top: 4px solid red; border-bottom: 1px solid gray; } a { display: inline-block; height: 41px; text-align: center; line-height: 41px; text-decoration: none; padding: 0px 5px; background-color: red; font-size: 14px; font-family: 楷体; } .shouye { margin-left: 200px; } .shouye:hover { background-color: gray; } </style></head><body> <p> <a class="shouye" href="#">设为首页</a> <a href="#">手机新浪网</a> <a href="#">移动客户端</a> </p></body></html>
Effect preview:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> body { margin: 0; padding: 0; } p { font-size: 0;/*关键代码*/ height: 41px; border-top: 4px solid red; border-bottom: 1px solid gray; } a { display: inline-block; height: 41px; text-align: center; line-height: 41px; text-decoration: none; padding: 0px 5px; background-color: red; font-size: 14px; font-family: 楷体; } .shouye { margin-left: 200px; } .shouye:hover { background-color: gray; } </style></head><body> <p> <a class="shouye" href="#">设为首页</a> <a href="#">手机新浪网</a> <a href="#">移动客户端</a> </p></body></html>Effect preview:
HTML video tutorial】
The above is the detailed content of How to remove spaces in html. For more information, please follow other related articles on the PHP Chinese website!