mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #1236] MD045 shown when image has alt text in the optional title #643
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#643
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Licantrop0 on GitHub (May 31, 2024).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1236
MD045 - Images should have alternate text (alt text) is shown when the optional title in the reference syntax is used but the Alternate Text is empty.
Example:
The title text in the reference should be enough for not being flagged as violation, as the Assistive Technologies can read the title instead of the empty alt text, as you can see from this sample:
In-line:

Reference:
@DavidAnson commented on GitHub (May 31, 2024):
Per mdn, "The title attribute is not an acceptable substitute for the alt attribute.":
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#the_title_attribute
Your example renders a blank "alt" attribute, so the rule is correct to report a violation:
https://markdown-it.github.io/#md3=%7B%22source%22%3A%22!%5B%5D%5Bref%5D%5Cn%5Cn%5Bref%5D%3A%20image.jpg%20%5C%22Alternate%20text%5C%22%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22src%22%7D%7D
@Licantrop0 commented on GitHub (May 31, 2024):
ah, that's a pity... Thanks for the explanation, I'll close this issue.
I wish there were a way to specify the alt-text in reference rather than in the individual tags, especially when you have to refer to the same image multiple times.
@DavidAnson commented on GitHub (May 31, 2024):
If you have control over the Markdown renderer, I think it would be a very reasonable modification to have it substitute title for alternate text. Maybe some renderers already do that? But it's not part of the standard, so this rule does not assume that is being done.