Inkscape.org
Beginners' Questions How can I set the class of an objectd?
  1. #1
    Edaqa Mortoray Edaqa Mortoray @mortoray

    Is there a way to set the class of the object? I'd like to set it for the purpose of CSS styling.

  2. #2
    Tyler Durden Tyler Durden @TylerDurden

    There is a new hidden toolset in v 1.0. (Use at your own risk.)

    https://wiki.inkscape.org/wiki/index.php/Release_notes/1.0#Selectors_and_CSS_.5BExperimental.2C_hidden.5D

  3. #3
    Xav Xav @Xav👹

    TD, I don't think that's what the OP needs in this case. It looks to me like that dialog is for managing CSS selectors (including class selectors) and properties, not for setting the class(es) on an object itself.

    For setting a class (or classes) you need to use the XML editor (Edit > XML Editor). This works slightly differently between 0.92 and 1.0:

    • 0.92: With the object selected you should see its attributes listed in the XML editor. At the bottom of the pane are a couple of unlabelled blank fields and a "Set" button. The first field is for the attribute name ("class") and the second is for the value (space separated list of class names). Once you've entered both, click the "Set" button and it should appear in the list above, with all the other attributes.
    • 1.0: make sure the attributes are visible (there's a toggle in the dialog). At the top of the attribute list is a button to add a new attribute. Click that and enter the name ("class") and value (space separated list of class names) directly in the fields. They are applied immediately.

    It would be nice if "Class" was in the object properties dialog, but it's not. Perhaps once the new CSS dialog reaches maturity it would make more sense to add it.

  4. #4
    Edaqa Mortoray Edaqa Mortoray @mortoray

    Thank you. Yes, it's the XML editor which I need to set the class name. I downloaded version 1.0 to ensure I had the newest features.

    Applied immediately, that implies they'll use any linked stylesheets. This might save me lots of work.

    The CSS selectors should also come in handy, so thanks for them as well.

  5. #5
    Edaqa Mortoray Edaqa Mortoray @mortoray

    Good, the XML Editor solves my next problem as well: how to get the ID of a layer. Though it'd be nice if this were in the layer's dialog.

  6. #6
    Xav Xav @Xav👹

    To clarify, when I said "applied immediately" I meant that there's no save button in the dialog (compared with the Set button from 0.92). Whether adding a class will have an immediate effect within Inkscape, or use any linked stylesheets, I don't know.

Inkscape Inkscape.org Inkscape Forum Beginners' Questions How can I set the class of an objectd?