concept
Responsive media — CSS reference
Responsive media avoids forcing the surrounding layout wider than its container. Preserve the intrinsic ratio when shrinking an image and supply meaningful alternative text where appropriate. This inline SVG image has a 400 by 200 intrinsic size and is constrained to a 160px container. This does not test responsive source selection or network loading.
Formal Syntax & Structure
css syntaxcss
img { max-inline-size: 100%; block-size: auto; }Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>responsive-media</title><style>body{margin:8px;font:16px/1.5 sans-serif;color:black;background:white}#a{box-sizing:border-box}#a{width:160px}img{max-inline-size:100%;block-size:auto;display:block}</style><body><div id="a"><img id="b" width="400" height="200" alt="Blue rectangle" src="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27400%27 height=%27200%27%3E%3Crect width=%27400%27 height=%27200%27 fill=%27blue%27/%3E%3C/svg%3E"></div></body></html>