Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:12:17+00:00 2026-06-05T07:12:17+00:00

SVG images linked or inlined in HTML5 documents is a practice that is relatively

  • 0

SVG images linked or inlined in HTML5 documents is a practice that is relatively young (by web standards), but I believe it’s important that it matures quickly. How should modern browsers size either type of svg image that states just their aspect ratio (as per their viewBox), and where the parent HTML document just has either (but not both) of width or height given?

To narrow the topic usefully, this question only concerns itself with <!DOCTYPE html> HTML5 documents.

I made a test page that shows this off in a few different HTML contexts, and only Firefox behaves the way I would expect (and prefer), inferring the one from the either, in all situations tested. In earlier testing, Chrome used to as well, but doesn’t any more. Opera is very close.

Context and background of this question

One of the things I love about SVG is that the format lets you make images that render to whatever size of document you have, as long as you state which parts of the image should show (and optionally how it should be cropped), and not state just how large it should be drawn.

In effect, this lets you take a pretty logo, view and resize it at will in your browser, by just resizing your browser window to whatever size you want, and it happily draws to the new bounding box, without fuss.

This is accomplished by setting a viewBox attribute on the <svg> element, but neither the width nor height attributes, so it preserves that aspect ratio, with the (default) svg positioning and cropping strategy of preserveAspectRatio="xMidYMid meet", which essentially meens what background-position: 50% 50%; background-size: contain; would mean for a CSS3 background image specification.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:12:18+00:00Added an answer on June 5, 2026 at 7:12 am

    You want to look at http://www.w3.org/TR/CSS2/visudet.html#inline-replaced-width for the behavior that is required of browsers here. What CSS calls “intrinsic” refers to information of the image.

    This behavior changed from a worse default not too long ago, so it is likely browsers still have issues in this area.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a small tutorial that can help me use svg images in
I have body { background: url(images/background.svg); } The desired effect is that this background
I'm looking for source code that converts JPG bitmap images to SVG. I will
Is there any good tool or tool-chain that allows UML images in the .svg
Are there any relatively easy ways to deal with SVG images in .NET? How
Possible that I would embed SVG images in a PdfPTable?
I'd like to make my SVG images interactive, with a zoom box that can
I have been using the svgwrite library to generate a sequence of svg images.
Examotion has a player that can display the image for svg files as a
I'm looking for the best solution to dynamically change some images extension (from .svg

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.