style attribute overrides CSS
Hello,
I don't understand the behaviour of inkscape when using it on a svg with css file written by hand:
When using with inkscape a file like this: <?xml version="1.0" encoding="utf-8" standalone="no"?> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="21cm" height="29.7cm" version="1.1"> <title>CSS</title>
<defs> <style type="text/css"><![CDATA[ .foo { fill:red; stroke:blue; } .bar { fill:blue; stroke:red; } ]]></style> </defs>
<path id="a_path" class="foo" d="M 0 0 L 200 200"/> </svg>
If I do something with #a_path (translate it or other), inkscape create automagically a style attribute which contain a full set of styling properties, including what I provide with .foo. But If I want to change the class in .bar, inkscape do this but keep its style attribute, overriding my CSS. I must delete the style attribute (which is, of course, prompty re-create) to obtain the style I want.
I know CSS integration is plan in the future, but waiting for it why not create a work-around ? For instance, I the user make some change in XML-editor, like add, change or remove an attribute, or move an element in the XML-tree, style attr of this element is automatically reconstruct.
Regards, Aurèle
The use of the style= attribute in this way was a (poor, in my opinion) decision made a long time ago. However, at this point it's not clear to me how we could easily change the behavior -- now, if Inkscape switched to exclusively setting the presentation attributes instead, existing style= attributes (e.g. from earlier versions) of Inkscape would override them.
-mental
A step in the proposed direction is to keep Inkscape from attaching style values to objects that are identical to the default values. This would also reduce the size of Inkscape created SVG files. For example, if one creates a text object with v0.44+svn, 11 style attributes are automatically created, 9 of which match the SVG specified defaults (only font-size and font-family differ).
This step would be consistent with how "Unset" fill and "Unset" stroke work. Perhaps there should be the option to "Unset" all style attributes.
Tav
On 9/12/06, tavmjong@...8... <tavmjong@...8...> wrote:
A step in the proposed direction is to keep Inkscape from attaching style values to objects that are identical to the default values.
It already does that, sort of. It compares the style of the object to that of its parent and writes only the difference.
Quoting bulia byak <buliabyak@...400...>:
On 9/12/06, tavmjong@...8... <tavmjong@...8...> wrote:
A step in the proposed direction is to keep Inkscape from attaching style
values
to objects that are identical to the default values.
It already does that, sort of. It compares the style of the object to that of its parent and writes only the difference.
The SVG files are less verbose than I remembered but there are still many attributes being set unnecessarily. I checked with 0.44+SVN. Here are the attributes that are set even when they correspond to the SVG specified defaults or are not used (e.g. fill-rule for Freehand and Bezier tools). The objects' parent was "layer1" which had no attributes set.
Rectangle tool: stroke, stroke-opacity. (Stroke set to 'none'. Unsetting stroke removes attribute.) Ellipse tool: stroke, stroke-opacity. Star tool: stroke, stroke-opacity. Spiral tool: fill-rule, stroke-width, stroke-linecap, stroke-linejoin, stroke-opacity. Freehand tool: fill-rule, stroke-width, stroke-linecap, stroke-linejoin, stroke-opacity. Bezier tool: fill-rule, stroke-width, stroke-linecap, stroke-linejoin, stroke-opacity. Calligraphy tool: stroke-opacity. Text tool: font-style, font-weight, fill, fill-opacity, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-opacity.
participants (4)
-
unknown@example.com
-
Aurèle Duda
-
bulia byak
-
MenTaLguY