Quantcast
Viewing all articles
Browse latest Browse all 16267

Poor person's image scaling in Markdown

Occasionally, people are asking about image scaling in Markdown. One possibility is to (mis-)use a query string in the image URL, e.g. “width=half”:
![image alt text](https://example.com/image.gif?width=half)
and add this to your CSS:

figure :has(img[src*="width=half"]),
img[src*="width=half"]{
  width: 50%;
}

One has to use two rules, since images can occur inline (2nd rule) or in their own paragraph, in which case they’re rendered inside a figure element.

Alas, one can’t get at the value following the = sign in CSS. If that were possible, one could write generic CSS rules that simply take the width from the query string…


Viewing all articles
Browse latest Browse all 16267

Trending Articles