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

  • Home
  • SEARCH
  • 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 7615475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:39:09+00:00 2026-05-31T02:39:09+00:00

I would like to embed some SVG in an HTML page in a way

  • 0

I would like to embed some SVG in an HTML page in a way such that is is automatically resized (using SVG, CSS, or JS) when the page is resized, while still preserving the original aspect ratio.

For example, using an example from W3Schools:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <circle cx="100" cy="50" r="40" stroke="black"
  stroke-width="2" fill="red"/>
</svg>

Is it possible to set the SVG width = 5% of the window width, and have the height scaled proportionately?

I’ve tried a couple things including preserveAspectRatio="xMinYMin meet" and setting the dimensions to 100% within a <div> container, but haven’t gotten it working yet.

Any suggestions?

  • 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-05-31T02:39:10+00:00Added an answer on May 31, 2026 at 2:39 am

    You need a viewBox-attribute on your SVG root element, which will define the overall size of the SVG-image:

    <svg version="1.1" viewBox="0 0 300 185">
    

    Now you can set the width OR height of the image via CSS and it will scale perfectly.

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

Sidebar

Related Questions

I want to embed some HTML on my website... I would like that: SEO
We would like to embed some code in each ASP.NET page that queries its
I would like to embed some C# .Net code that does some simple Encryption/Decryption
Hey guys, I have developed a small site that i would like to embed
I have a ViewController that has its own NIB. I would like to embed
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to embed some Lua script in my C application.....specifically for LOGGING.
I am currently using zoom.js to zoom-in on some SVG shapes that I have
I would like to implement/embed a notes area where people can write some notes
I would like to embed mozilla firefox into my application WITHOUT using any activex

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.