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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:35:01+00:00 2026-06-03T08:35:01+00:00

I am working with an SVG that is directly placed into an HTML file

  • 0

I am working with an SVG that is directly placed into an HTML file

<svg>
   Contents...
</svg>

Using javascript/jQuery I want to add an attribute to the SVG

$("svg").attr("viewBox", "0 0 166 361");

Here is the modified SVG after running the above script

<svg viewbox="0 0 166 361">
   Contents...
</svg>

notice it puts viewbox not viewBox. Since viewbox (lowercase) doesn’t do anything I need it to be viewBox (camelcase)

Any ideas?

** Update **

I ran a little test where I rendered the viewBox attribute from the server side, then I ran the script above. You can see that 1. When rendered from the server side, it is fine. 2. jQuery didn’t recognize the camelCase viewBox attribute and inserted another one in all lower case.

<svg version="1.1" id="Layer_1" x="0pt" y="0pt" width="332" 
     height="722" viewBox=" 0 0 100 100" viewbox="0 0 166 332">
...
</svg>
  • 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-03T08:35:03+00:00Added an answer on June 3, 2026 at 8:35 am

    I might depend on your encoding document type. XHTML documents must use lower case for all HTML element and attribute names. I’m not sure about HTML.

    Update 2

    The only solution I could find is to use:

    $("svg")[0].setAttribute("viewBox", "0 0 166 361");
    

    Update

    I can’t explain it for any reason, I tested on my own host because JsFiddle always uses XHTML (boo!). In all cases it was lowercase, but it was still an SVG Element in FF, Chrome and IE9 (I don’t know if they were valid because I don’t know SVG I’m afraid).

    Firefox Example
    Chrome Example
    IE Example

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

Sidebar

Related Questions

I'm working on an interactive interface using SVG and JavaScript/jQuery, and I'm trying to
I'm working in a small PHP script that transform a SVG file into PDF
I'm working on some ECMAScript/JavaScript for an SVG file and need to get the
I have created an algorithm that converts text formatted in SVG into HTML, the
I'm working on drawing an SVG grid using Javascript. I've managed to get the
I am working with svg and its dom manipulation. I want to create a
Working on a website that has Employee and Branch entities, using a database table
I have an SVG file that contains several elements (like path, circles, rectangles, etc.).
I'm working on a project that uses SVG with Raphael.js . One component is
I'm working on a project that requires an interactive map. I want to use

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.