In an SVG image that is embedded into HTML I want to add an outline with a gradient to some text. When I open the HTML file with Firefox the gradient of the outline changes its position depending on the position of the image within the rendered HTML document. In Chrome and Opera the rendering of the SVG is ok, but not so in Firefox. Here you find the HTML file for everyone to check. It contains the same SVG twice, so you can see the difference in display.
Is that a Firefox bug or do I have an error in my SVG? Thank you!
Gradient on stroke is not rendered correctly in Firefox
Re: Gradient on stroke is not rendered correctly in Firefox
Welcome to InkscapeForum!
I can't explain it, but I can confirm the same behavior. I used the code you provided and created a new HTML doc. It does look like expected in IE, and not in Firefox. Whether it's a bug in Ff, I couldn't say. I don't have near the technical knowledge needed. But it does seem strange to me.
I wonder if having the file actually uploaded to the internet would make any difference? I mean, I don't see why it would. But when I look at the HTML file I created, I'm not looking at it on the internet, only on my computer. So I was thinking maybe there's somthing about having it on the internet, that would change something?
But certainly, someone with a lot more technical expertise than me, will need to handle this
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Re: Gradient on stroke is not rendered correctly in Firefox
Thank you for your reply. At least now I know that I am not the only one where the code doesn't work properly. Although I don't think any browser cares much whether the source code is hosted locally or remotely I have uploaded the script so it's easier to view the document:
http://www.zentralplan.de/temp/svg-stro ... t-text.htm
Since I cannot guarantee that the file will be there forever, here is the source:
I made another test case with a rectangle added to the text to see if it behaves differently, and so it does although it shares the same fill and stroke properties with the text:
http://www.zentralplan.de/temp/svg-stro ... t-rect.htm
The third test case I made shows the effect when you don't embed two SVG scripts within the HTML, but two texts (and two rects) within a single SVG within the HTML. Here the gradients are correct, so I conclude that the problem is truly related to the position of the SVG in the rendered HTML document and occurs only with stroke on text but not with stroke on rects:
http://www.zentralplan.de/temp/svg-stro ... -rect2.htm
(All scripts are valid markup according to http://validator.w3.org/)
http://www.zentralplan.de/temp/svg-stro ... t-text.htm
Since I cannot guarantee that the file will be there forever, here is the source:
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>stroke</title>
</head>
<body>
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='700px' height='200px'>
<defs>
<linearGradient id='grad1' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#66aaff' />
<stop offset='100%' stop-color='#001144' />
</linearGradient>
<linearGradient id='grad2' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#ffdd7f' />
<stop offset='100%' stop-color='#332c00' />
</linearGradient>
</defs>
<rect x='0' y='0' width='700' height='200' fill='black' />
<text style='font-size:100px;' stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='100'>loremipsum</text>
</svg><br />
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='700px' height='200px'>
<defs>
<linearGradient id='grad3' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#66aaff' />
<stop offset='100%' stop-color='#001144' />
</linearGradient>
<linearGradient id='grad4' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#ffdd7f' />
<stop offset='100%' stop-color='#332c00' />
</linearGradient>
</defs>
<rect x='0' y='0' width='700' height='200' fill='black' />
<text style='font-size:100px;' stroke-width='4' fill='url(#grad3)' stroke='url(#grad4)' x='10' y='100'>loremipsum</text>
</svg>
</body>
</html>
I made another test case with a rectangle added to the text to see if it behaves differently, and so it does although it shares the same fill and stroke properties with the text:
http://www.zentralplan.de/temp/svg-stro ... t-rect.htm
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>stroke</title>
</head>
<body>
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='700px' height='200px'>
<defs>
<linearGradient id='grad1' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#66aaff' />
<stop offset='100%' stop-color='#001144' />
</linearGradient>
<linearGradient id='grad2' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#ffdd7f' />
<stop offset='100%' stop-color='#332c00' />
</linearGradient>
</defs>
<rect x='0' y='0' width='700' height='200' fill='black' />
<rect stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='30' width='600' height='70' />
<text stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='100' style='font-size:100px;' >loremipsum</text>
</svg><br />
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='700px' height='200px'>
<defs>
<linearGradient id='grad3' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#66aaff' />
<stop offset='100%' stop-color='#001144' />
</linearGradient>
<linearGradient id='grad4' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#ffdd7f' />
<stop offset='100%' stop-color='#332c00' />
</linearGradient>
</defs>
<rect x='0' y='0' width='700' height='200' fill='black' />
<rect stroke-width='4' fill='url(#grad3)' stroke='url(#grad4)' x='10' y='30' width='600' height='70' />
<text stroke-width='4' fill='url(#grad3)' stroke='url(#grad4)' x='10' y='100' style='font-size:100px;' >loremipsum</text>
</svg>
</body>
</html>
The third test case I made shows the effect when you don't embed two SVG scripts within the HTML, but two texts (and two rects) within a single SVG within the HTML. Here the gradients are correct, so I conclude that the problem is truly related to the position of the SVG in the rendered HTML document and occurs only with stroke on text but not with stroke on rects:
http://www.zentralplan.de/temp/svg-stro ... -rect2.htm
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>stroke</title>
</head>
<body>
<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='700px' height='404px'>
<defs>
<linearGradient id='grad1' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#66aaff' />
<stop offset='100%' stop-color='#001144' />
</linearGradient>
<linearGradient id='grad2' x1='50%' y1='0%' x2='50%' y2='100%'>
<stop offset='0%' stop-color='#ffdd7f' />
<stop offset='100%' stop-color='#332c00' />
</linearGradient>
</defs>
<rect x='0' y='0' width='700' height='200' fill='black' />
<rect stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='30' width='600' height='70' />
<text stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='100' style='font-size:100px;' >loremipsum</text>
<rect x='0' y='204' width='700' height='200' fill='black' />
<rect stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='234' width='600' height='70' />
<text stroke-width='4' fill='url(#grad1)' stroke='url(#grad2)' x='10' y='304' style='font-size:100px;' >loremipsum</text>
</svg>
</body>
</html>
(All scripts are valid markup according to http://validator.w3.org/)