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 970647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:50:19+00:00 2026-05-16T02:50:19+00:00

How can I make a SVG appear reliably without scrollbars in HTML? Something that

  • 0

How can I make a SVG appear reliably without scrollbars in HTML? Something that works in both Firefox and Chrome is sufficient.

  • The most basic step is that
    the SVG appears as it’s “natural”
    width and height in the document.
    Fully expanded. Without scroll bars.
    firefox generally does this. Chrome
    generally does not (unless I use prior knowledge of the actual width and height).

  • The more advanced step is
    that I give the SVG an arbitrary
    width (say 400 pixels), and the SVG
    appears scaled appropriately, while preserving
    it’s aspect ratio. Again, no scroll
    bars.

I’d prefer not to have to know the natural dimensions of the SVG in the HTML. Changing the HTML or CSS is best, though changing the SVG (once, not for every size I want do display it) would also be fine.

Is this kind of thing possible?

Here’s some example html that embeds an svg.

<html>
    <head><title>SVG Sizing</title></head>
    <body>
        <embed type="image/svg+xml" src="test.svg">
    </body>
</html>

The <embed> tag below can be changed to <object> or something else if needed.

Here’s an example test.svg:

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1200px" height="297px" version="1.1" viewbox="0 0 1200 297" xmlns="http://www.w3.org/2000/svg" shape-rendering="crispEdges" stroke-width="1" text-rendering="geometricPrecision">
    <text x="300" y="15" textLength="8" font-family="Helvetica" font-size="12" fill="black" text-anchor="middle"> A </text>
    <text x="900" y="15" textLength="8" font-family="Helvetica" font-size="12" fill="black" text-anchor="middle"> B </text>
    <line x1="300" y1="22" x2="300" y2="47" stroke="black"/>
    <line x1="900" y1="22" x2="900" y2="47" stroke="black"/>
    <text x="587" y="37" textLength="25" font-family="Helvetica" font-size="12" fill="black"> Start </text>
    <line x1="300" y1="272" x2="300" y2="297" stroke="black"/>
    <line x1="900" y1="272" x2="900" y2="297" stroke="black"/>
    <text x="583" y="287" textLength="32" font-family="Helvetica" font-size="12" fill="black"> Finish </text>
    <line x1="150" y1="284" x2="582" y2="284" stroke="black" stroke-dasharray="2,2"/>
    <line x1="618" y1="284" x2="1050" y2="284" stroke="black" stroke-dasharray="2,2"/>
</svg>

Update:

Ok, seems the tool I am using is generating SVGs with a lowercase viewbox attribute, this is incorrect however, and the attribute name is actually camelcase viewBox as Erik writes correctly below.

This combined with the width/height removal or change to percentage allows me to achieve both parts of the question.

Thanks everyone!

  • 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-16T02:50:20+00:00Added an answer on May 16, 2026 at 2:50 am

    If you want the svg to fill the entire width/height of the screen try this in the html document:

    <style>
    html, body { margin:0; padding:0 }
    embed { width: 100%; height: 100% }
    </style>
    

    If you wanted to fill a smaller region of the document, then try removing the width and height attributes on the referenced svg root element, and make sure that there is a viewBox attribute. Then the size of the container (embed) should decide the size properly, and there should be no scollbars.

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

Sidebar

Ask A Question

Stats

  • Questions 479k
  • Answers 479k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I solved the problem.. It seems Nhibernate was looking for… May 16, 2026 at 5:42 am
  • Editorial Team
    Editorial Team added an answer The answer is C++/CLI. You can use managed code test… May 16, 2026 at 5:42 am
  • Editorial Team
    Editorial Team added an answer You cannot get the state directly, see the open enhancement… May 16, 2026 at 5:42 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.