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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:00:59+00:00 2026-06-13T19:00:59+00:00

I am creating the SVG text by using the <text> with <tspan> for each

  • 0

I am creating the SVG text by using the <text> with <tspan> for each line.
The text has many lines and one of them is empty line, some thing like this:

this is text line 1


this is text line 3

the example above is a text with three lines, one of them is empty.

the problem is the SVG text only displays two lines instead of three lines (the first and the end line, without the middle line).

See here: http://jsfiddle.net/svincoll4/DX4Cn/

Anyone have solution about this to make it display three lines?

Note: I am using the Raphael JS to create these text.

  • 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-13T19:01:00+00:00Added an answer on June 13, 2026 at 7:01 pm

    By default whitespace is compressed in html and svg so \n\n\n becomes \n. Also if there’s no text at all then the middle line is ignored. xml:space=”preserve” stops whitespace compression in SVG and and extra space makes the middle line exist.

    var $svg = Raphael('container', 400, 400);
    var $text = "this is line 1\n \nthis is line 3";
    $svg.canvas.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space","preserve");
    $svg.text(50, 100, $text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying out some dynamic web page background generation using lines and text. Take
Has anybody experience with using svg for creating custom buttons on android? I recently
I'm creating an SVG path using the Raphael library and the following code: this.resultsBoxLine1
I'm creating an SVG rectangle using the Raphael JavaScript library, and assigning it a
I am creating visualizations using svg and it renders fine in IE9. I am
In one of my application I am creating a SVG path with the following
I'm creating a whiteboard application using SVG in HTML5, and javascript to manipulate the
I am creating some fairly complex charts in R using the Cairo library for
I Am creating an image with raphael and the SVG it generats for paper.text()
Creating a JApplet I have 2 Text Fields, a button and a Text Area.

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.