Fix weird layout bug with images in links#3142
Open
GuillaumeGomez wants to merge 1 commit into
Open
Conversation
ehuss
reviewed
Jun 23, 2026
| .content a { text-decoration: none; } | ||
| .content a:hover { text-decoration: underline; } | ||
| .content img, .content video { max-width: 100%; } | ||
| .content img { display: block; } |
Contributor
There was a problem hiding this comment.
This doesn't quite seem like the correct fix to me because it will cause all images to be block displayed instead of inline. This might change the rendering when it is intended for the image to be inline. As a basic example, look at the badges in this repo's README file, and how they are rendered side-by-side. This would force them to be stacked.
How about instead we change the a to have inline-block display instead, like:
Suggested change
| .content img { display: block; } | |
| /* When an image is inside an anchor, ensure the focus ring covers the entire | |
| image instead of the anchor's line box. */ | |
| .content a:has(img) { display: inline-block; } |
Member
Author
There was a problem hiding this comment.
Ah interesting, didn't think about that. I'll add a GUI test as well.
d54869e to
0cbf0dd
Compare
Member
Author
|
Added the GUI test to ensure the links containing images have the expected size and also that they work correctly side by side. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on #3127, I uncovered this bug when pressing tab around:
What you see is the link being focused (an image cannot be focused unless we add
tabindexto it, which we don't want) when you have an image inside a link (an<img>inside a<a>). To fix, we simply need to make<img>display: block. Once done, we have the expected result:(still not the
<img>focused, it's the<a>, but with the correct layout)