Why not allow images without alt?

I think it’s ridiculous to design a syntax that users would be explicitly warned against using.

the relative cost to the user of typing ![](image.png) vs !(image.png) is not worth the relative cost to the implementers to try to support and standardize a feature that we don’t actually want them to use to begin with.

My vote is to axe this extension. The premise of

Usually, nobody adds alt text to images in ordinary posts.

is flawed as it’s a failing of the author, not of the syntax.

Some content management systems might let the user fill in the HTML alt, width, and height attributes in another part of the system. So the author would still be adding the alt tag, just not using Markdown.

If the system is going to automatically generate the alt text, then the following would make sense:

Explicitly empty [alt]: system provides alt text

![]({image-id})

renders as

<img src="/path/to/img.png" alt="image alt text"/>

Provided [alt]: overrides system alt text

![custom alt text]({image-id})

renders as

<img src="/path/to/img.png" alt="custom alt text"/>

In neither case is the removal of [] necessary.

I basically agree with the method you described for adding the alt text from another source. The main reason for making [] optional is that !(file.png) looks cleaner than ![](file.png). So while the removal of [] is unnecessary, from an aesthetic perspective it might be beneficial. Maybe as an extension?

Probably not necessary to make it an extension if we use generic directive syntax. Since !(file.png)is just shorthand for !default[](file.png){} function. Which in javascript would be defaultExtention("","file.png","");.

Basically order of [] & () & {} is not important, and if any is missing, it is automatically added in as an empty bracket.

Sorry to continue this old conversation, but here’s my 2 cents.

I completely agree that alt should be optional. Alt attribute is misunderstood for the most part. Yes, it is required. But for many, if not most images on the web, it serves no value to say specifically what the image is. Rather than that, it should just describe what this image is in general, like icon, logo etc.

Markdown, in any use case other than a full-packed CMS, is meant to express images just decorating the content. It feels too weird to deliver the alt text for images like memes or visualisations of what we just said. Justifications stating that “HTML5 requires it” are not explaining why users should type it. They could, and imo should be automatically generated if omitted, to either fragment of a post, just something general, or empty string.

You can use the content block syntax to create an image without an alt tag. It’s an easier to write syntax as well. So, perhaps the regular image syntax doesn’t need to be changed?

2 Likes