In HTML image element can be created without dimensions specified. It will have intrinsic width and height:
<img src="me.jpg" alt="">
However, in SVG image without dimension attributes will have 0×0 size, to prevent this width
and height
must be specified (as in this example):
<image xlink:href="me.jpg" width="64" height="64" />
Can SVG image be forced to take it's original width and height (without adding corresponding attributes, of course)? I'm curios about inline SVG inside HTML, if it matters.
The SVG 1.1 specification requires the
width
andheight
attributes for the <image> element. Most browsers today implement that, so the answer is not yet. Leaving the attributes off means a default value of0
is used, which has the effect of making the image invisible.However, autosizing of images is being added to SVG2, see https://svgwg.org/svg2-draft/embedded.html#ImageElement.
This hopefully means that you'll be able to do what you want in a not too distant future.