This is a distinction worth knowing about. They look pretty similar. They can do some of the same things. But, one is very easy to override and the other is not.
Inline styles are likely a bit more familiar:
<div style="width: 300px; height: 300px;">
Inline styles on an HTML element.
</div>
SVG can do that too:
<svg style="width: 300px;">
Inline styles on an SVG element.
</svg>
But SVG has this concept of presentational attributes as well, meaning we could do this:
<svg width="300px" height="300px">
Presentational attributes on an SVG element.
</svg>
The difference?
Presentational attributes are very easy to override in CSS
Any CSS at all will do.
/* These styles will override the presentational attributes */
svg {
width: 250px;
height: 250px;
}
Inline styles can only be override by !important styles in CSS
The only way to override an inline style is by using !important rules:
svg {
width: 250px !important;
height: 250px !important;
}
A crude diagram to drive the point home

This does actually come up, I find, in day-to-day development. For example, Illustrator asks how you want to style exported SVG:

It also makes good sense to add presentational attributes, especially sizing ones, to SVG to avoid FOUSVG.
I believe the value of the
width
andheight
attributes should be unit-less.For example
<svg width="300" height="300">
instead of<svg width="300px" height="300px">
Hi Thierry,
For SVG width/height presentation attributes, you can either use unitless numbers (treated as px) or any valid CSS unit or percents. This is consistent with presentation attributes in SVG just being another way of setting the style property.
For HTML width/height presentation attributes on
<img>
,<object>
and so on, you can only use unitless numbers.value of the
width
andheight
attributes with units or without units (px) both working..like–<svg width="300" height="300">
and<svg width="300px" height="300px">
are give the same result.Thanks AmeliaBR!
It is valid either way. Without units it’s only static values but with units you can use percentage widths too.
Hi AmeliaBR,
in
<img>
tag unit or unitless numbers forwidth
andheight
both are working fine..Hi Pranab,
It “works” because browsers know how to “recover” from this type of error.
<image>
works too but it does not mean that’s what we should be using. Actually, it is because authors make this type of mistakes that browsers have to support such markup.