Class CssToken
Represents a CSS token with its type and value
Inheritance
Namespace: IronPdf
Assembly: IronPdf.dll
Syntax
public class CssToken : Object
Parsing and inspecting CSS at a granular level becomes straightforward when each piece of a stylesheet is represented as a CssToken, a record pairing a classification with its raw text. Each token carries a Type property of kind CssTokenType that identifies the role the token plays (selector, property name, value, delimiter, and so on) alongside a Value string that holds the exact text extracted from the source. Together these two properties let downstream code branch on token kind and act on the literal content without re-parsing the stylesheet.
Construct a token directly with CssToken(CssTokenType type, string value) when building a token stream by hand, for example when writing a CSS pre-processor or injecting synthetic rules before IronPDF renders a document. Both Type and Value expose public setters, so a token can be mutated in place as a pipeline transforms it, rather than requiring a new allocation for every edit.
CssToken sits at the low level of IronPDF's CSS handling. Higher-level rendering options such as custom stylesheets and media-type overrides are configured through the main rendering API, but CssToken gives precise access to the token stream for tooling that needs to inspect or rewrite CSS before it reaches the renderer.
using IronPdf;
var token = new CssToken(CssTokenType.Value, "14px");
if (token.Type == CssTokenType.Value)
token.Value = "16px"; // scale up base font size before renderingSee the IronPDF documentation hub for an overview of the rendering pipeline, and the custom CSS how-to for practical examples of injecting styles into a PDF render job.
Constructors
CssToken(CssTokenType, String)
Creates a new CSS token
Declaration
public CssToken(CssTokenType type, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| CssTokenType | type | Token type |
| System.String | value | Token value |
Properties
Type
Type of the CSS token (declaration, comment, delimiter, etc.)
Declaration
public CssTokenType Type { get; set; }
Property Value
| Type | Description |
|---|---|
| CssTokenType |
Value
The actual string value of the token
Declaration
public string Value { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |