---
title: "Style Management"
canonical_url: "https://www.compdf.com/guides/generation-sdk/dotnet-core/generation/layout-api-style-management"
md_url: "https://www.compdf.com/guides/generation-sdk/dotnet-core/generation/layout-api-style-management.md"
description: "ComPDF SDK Guides. In this developer's guide, all the details and how to use ComPDF for SDK Guides will be covered in depth."
---

# Style Management

## Creating and Using Styles

```csharp
// Create style
CStyle headingStyle = document.CreateStyle();

// Set style properties (supports method chaining)
headingStyle.SetFontSize(18);
headingStyle.SetFontWeight(CFontWeight.Bold);
headingStyle.SetMarginBottom(10);
headingStyle.SetTextAlignment(CTextAlignment.Center);

// Apply style to element
CText heading = div.CreateText("Heading text");
heading.AddStyle(headingStyle);

// Element can also have multiple styles
CStyle colorStyle = document.CreateStyle();
colorStyle.SetFontColor(CColor.Red);
heading.AddStyle(colorStyle);
```
