Search Results for

    Show / Hide Table of Contents

    Class CssDeclaration

    Represents a parsed CSS declaration with its components

    Inheritance
    System.Object
    CssDeclaration
    Namespace: IronPdf
    Assembly: IronPdf.dll
    Syntax
    public class CssDeclaration : Object

    Parsed CSS declarations become inspectable, editable records through CssDeclaration, giving you direct access to the property name, value, and importance flag that make up a single CSS rule component. When IronPDF parses a stylesheet, each declaration is surfaced as a CssDeclaration instance so that code can read or rewrite styles before rendering a PDF.

    Three properties carry the declaration's data. Property holds the CSS property name as a string, for example "font-size" or "color". Value holds the corresponding value string, such as "14pt" or "#333333". IsImportant is a bool that reflects whether the declaration carries the !important annotation, letting you detect or enforce priority rules programmatically. The default constructor CssDeclaration() creates a blank record that you can populate before passing it into a rendering pipeline.

    A typical use is inspecting or patching declarations that a CSS parser has already produced. You read Property to identify the rule, check IsImportant to decide whether to override it, and write a new string to Value to apply the change before the PDF renderer consumes the stylesheet.

    var decl = new CssDeclaration
    {
        Property = "font-size",
        Value    = "12pt",
        IsImportant = false
    };

    For broader context on controlling PDF appearance through stylesheets, see the IronPDF HTML-to-PDF how-to and the CSS styling examples.

    Constructors

    CssDeclaration()

    Declaration
    public CssDeclaration()

    Properties

    IsImportant

    Whether the declaration has the !important flag

    Declaration
    public bool IsImportant { get; set; }
    Property Value
    Type Description
    System.Boolean

    Property

    The CSS property name

    Declaration
    public string Property { get; set; }
    Property Value
    Type Description
    System.String

    Value

    The CSS property value

    Declaration
    public string Value { get; set; }
    Property Value
    Type Description
    System.String
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget