[GH-ISSUE #1236] MD045 shown when image has alt text in the optional title #643

Closed
opened 2026-03-03 01:28:43 +03:00 by kerem · 3 comments
Owner

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:

![][ref]
...
[ref]: image.jpg "Alternate text"

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: test inline
Reference: xxx

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)](../blob/v0.34.0/doc/md045.md) is shown when the optional title in the reference syntax is used but the Alternate Text is empty. Example: ``` ![][ref] ... [ref]: image.jpg "Alternate text" ``` 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**: ![test inline](https://github.com/DavidAnson/markdownlint/assets/2388430/7f548680-c36c-4d0d-ad42-e3794d47d984) **Reference**: ![xxx][ref] [ref]: https://github.com/DavidAnson/markdownlint/assets/2388430/7f548680-c36c-4d0d-ad42-e3794d47d984 "test reference"
kerem 2026-03-03 01:28:43 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner
<!-- gh-comment-id:2141232098 --> @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
Author
Owner

@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.

<!-- gh-comment-id:2142320914 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:2142565152 --> @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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#643
No description provided.