In CSS, you can use the "font-size" attribute to remove the default spacing of the img element. This attribute is used to set the font size within the element. When the value of the img parent element attribute is "0" , the default spacing of the img element within the element will be removed, and the syntax is "img parent element {font-size:0;}".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
How to remove the default spacing of img in css
In css, the img element will have a default spacing. An example is as follows:
To solve the problem of default spacing in the middle, we can use the font-size attribute to eliminate the default spacing in the middle. First we need to place the img image in In the same div element, and then add the "font-size:0" style to the div element, you can eliminate the default spacing of the img element in the div element.
The example is as follows:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> div{ font-size:0; } </style> </head> <body> <div> <img src="1118.How to remove img default interval in css" alt=""> <img src="1118.How to remove img default interval in css" alt=""> </div> </body> </html>
Output result:
##(Learning video sharing:css video tutorial)
The above is the detailed content of How to remove img default interval in css. For more information, please follow other related articles on the PHP Chinese website!