Home >Web Front-end >CSS Tutorial >Why Does My Image Have Unexpected White Space Below It After Switching from a Background Image?
Mystery White Space Beneath Image Tag: Troubleshooting Hidden Line Descent
The mysterious white space appearing beneath an image after switching from a background image to an tag can be attributed to a subtle technicality in HTML and CSS.
The original background image is not a text element, so it doesn't adhere to the rules of vertical alignment. In contrast, inline elements like images align to the baseline, a reference line that accommodates the descent of letters like "g" and "y."
This descent creates a subtle gap beneath the image, which is not caused by margin or padding but is simply an artifact of baseline alignment.
Resolving the White Space:
To eliminate the white space, consider the following solutions:
By addressing the underlying cause of the white space, one of these methods will successfully resolve the issue and align the image properly within its container.
The above is the detailed content of Why Does My Image Have Unexpected White Space Below It After Switching from a Background Image?. For more information, please follow other related articles on the PHP Chinese website!