How to Add Style to Text in DOCX

Customizing text styling in Word documents is essential for creating professional and visually appealing content. IronWord offers industry-grade text styling options similar to what's available in your favorite DOCX editor, allowing you to apply formatting programmatically with ease.

In this how-to, we'll explore how to stylize text content with custom settings using IronWord's TextStyle class.

Get started with IronWord

Start using IronWord in your project today with a free trial.

First Step:
green arrow pointer


Adding Text Style Example

Applying text styles in IronWord is straightforward. Create a WordDocument object, then create a TextContent object with your text. Apply a TextStyle to it using properties such as IsBold, Color, or TextFont, and enhance the styling further with options like underline or strikethrough.

Once the text is fully styled, add it to a Paragraph, insert the paragraph into the document, and save the final result.

:path=/static-assets/word/content-code-examples/how-to/add-style-text-simple.cs
using IronWord;

// Load docx
WordDocument doc = new WordDocument("sample.docx");

// Configure text
TextContent text = new TextContent();
text.Text = "Add text using IronWord";

// Configure text style settings
text.Style = new TextStyle()
{
    TextFont = new Font()
    {
        FontFamily = "Calibri", // Text Font is "Calibri"
        FontSize = 24, // Text Size is 24
    },
    Color = Color.Red, // Set text color to red
    IsBold = true,     // Make text bold
    IsItalic = true,   // Make text italic
	Underline = new Underline(), // Have an underline
    Strike = StrikeValue.DoubleStrike, // No strike-through
};

Paragraph paragraph = new Paragraph();

// Add text to paragraph
paragraph.AddText(text);

// Add paragraph to document
doc.AddParagraph(paragraph);

// Save document
doc.SaveAs("add-text-style.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Add style to text in DOCX

The TextStyle class provides essential formatting options, including font properties, text color, bold, italic, and underline, giving you the flexibility to create professional-looking documents quickly.


Adding Specific Styles

Text Color

The Color property in TextStyle allows you to set text color using predefined colors from IronWord.Models.Color or custom hex values. This is useful for emphasizing specific content or matching brand colors in your documents.

:path=/static-assets/word/content-code-examples/how-to/add-style-text-add-text.cs
using IronWord;

// Create document
WordDocument doc = new WordDocument();

// Add colored text
TextContent text = new TextContent("This text is olive-colored!");
text.Style = new TextStyle()
{
    Color = IronWord.Models.Color.Olive // defining text to be colored olive
};

Paragraph paragraph = new Paragraph();
paragraph.AddText(text);
doc.AddParagraph(paragraph);

// Save document
doc.SaveAs("colored-text.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Add text color in DOCX

Font Family and Size

Customize text appearance with the TextFont property. Set FontFamily to any installed font name (e.g., "Arial", "Times New Roman") and FontSize in points. This allows you to match document styles or establish a clear visual hierarchy.

:path=/static-assets/word/content-code-examples/how-to/add-style-text-add-font.cs
using IronWord;

// Create document
WordDocument doc = new WordDocument();

// Add text with custom font family and size
TextContent text = new TextContent("This text uses Arial at 24pt!");
text.Style = new TextStyle()
{
    TextFont = new IronWord.Models.Font()
    {
        FontFamily = "Arial",  // Set font family
        FontSize = 24          // Set font size in points
    }
};

Paragraph paragraph = new Paragraph();
paragraph.AddText(text);
doc.AddParagraph(paragraph);

// Save document
doc.SaveAs("font-styled-text.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Add font style to text in DOCX

Bold

Use the IsBold property set to true to make text bold. Bold text is commonly used for headings, emphasis, or highlighting important information in your documents.

:path=/static-assets/word/content-code-examples/how-to/add-style-text-add-bold.cs
using IronWord;

// Create document
WordDocument doc = new WordDocument();

// Add bold text
TextContent text = new TextContent("this is bold!");
text.Style = new TextStyle()
{
    IsBold = true  // Make text bold
};

Paragraph paragraph = new Paragraph();
paragraph.AddText(text);
doc.AddParagraph(paragraph);

// Save document
doc.SaveAs("bold-text.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Add bold text in DOCX

Italic

The IsItalic property set to true applies italic styling to text. Italic text is typically used for emphasis, titles, foreign words, or technical terms.

:path=/static-assets/word/content-code-examples/how-to/add-style-text-add-italic.cs
using IronWord;

// Create document
WordDocument doc = new WordDocument();

// Add italic text
TextContent text = new TextContent("this is italic.");
text.Style = new TextStyle()
{
    IsItalic = true  // Make text italic
};

Paragraph paragraph = new Paragraph();
paragraph.AddText(text);
doc.AddParagraph(paragraph);

// Save document
doc.SaveAs("italic-text.docx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Add italic text in DOCX

Styling Properties

Expore more styling options in the below table.

Styling Method Description Example
TextFont Customizes text appearance with a Font object, setting font family and size in points. text.Style.TextFont = new Font() { FontFamily = "Calibri", FontSize = 24 };
Color Sets text color using predefined colors from IronWord.Models.Color or custom hex values. text.Style.Color = IronWord.Models.Color.Red;
IsBold Makes text bold when set to true, commonly used for headings or emphasis. text.Style.IsBold = true;
IsItalic Applies italic styling to text when set to true, typically used for emphasis or titles. text.Style.IsItalic = true;
Underline Adds an underline to text using an Underline object with various underline styles. text.Style.Underline = new Underline();
Strike Applies strikethrough to text using StrikeValue enum (Strike or DoubleStrike). text.Style.Strike = StrikeValue.Strike;
Caps Applies capitalization effects to text, converting all characters to uppercase display. text.Style.Caps = true;
CharacterScale Adjusts the proportional width of characters as a percentage of their normal size. text.Style.CharacterScale = 150;
Emboss Applies an embossed effect to text, creating a raised appearance. text.Style.Emboss = true;
Emphasis Adds emphasis marks to styled text using EmphasisMarkValues enum values. text.Style.Emphasis = EmphasisMarkValues.Dot;
LineSpacing Controls spacing between lines of text for improved readability using a LineSpacing object. text.Style.LineSpacing = new LineSpacing() { Value = 1.5 };
Outline Renders text with an outline effect, displaying only the character borders. text.Style.Outline = true;
Shading Applies background color or shading to text using a Shading object. text.Style.Shading = new Shading() { Color = Color.Yellow };
SmallCaps Converts lowercase letters to small capital letters while maintaining case distinction. text.Style.SmallCaps = true;
VerticalPosition Adjusts vertical placement of text relative to its baseline, measured in points. text.Style.VerticalPosition = 5.0;
VerticalTextAlignment Positions text vertically within its container using VerticalPositionValues enum. text.Style.VerticalTextAlignment = VerticalPositionValues.Superscript;

Frequently Asked Questions

What is IronWord?

IronWord is a .NET library that allows developers to create, edit, and manipulate Word documents programmatically. It offers comprehensive features for text styling and formatting.

How can I change the text color in a DOCX file using IronWord?

IronWord provides methods to modify text styles, including changing text color. You can specify the desired color code to apply to the selected text in your Word document.

Can IronWord make text bold in a Word document?

Yes, IronWord supports standard text formatting options, including making text bold. You can apply bold styling to specific text elements within your DOCX files.

Is it possible to apply multiple styles to text using IronWord?

Absolutely, IronWord allows you to apply multiple styling options to text. You can combine different styles like bold, italic, and underline to customize your Word document fully.

What types of text styling can be applied using IronWord?

IronWord supports a range of text styling options including font size, font color, bold, italic, underline, and more, enabling you to customize the appearance of your DOCX document.

Does IronWord support custom font styles?

Yes, IronWord allows you to utilize custom font styles in your Word documents. You can specify fonts that are installed on your system to enhance the document's appearance.

Can I automate the creation of styled Word documents using IronWord?

IronWord is designed to facilitate the automation of Word document creation and styling. You can programmatically apply and modify text styles to generate documents efficiently.

How does IronWord handle text alignment in DOCX files?

IronWord offers functionality to adjust text alignment in your Word documents. You can set text to align left, right, center, or justify according to your layout requirements.

What are the benefits of using IronWord for styling DOCX text?

Using IronWord for styling DOCX text provides benefits like ease of integration into .NET applications, flexibility in applying various text styles, and the ability to automate document processing tasks.

Is IronWord compatible with different versions of Microsoft Word?

IronWord is designed to work with DOCX files, which are compatible with various versions of Microsoft Word. It provides robust support for creating and editing these files across different Word versions.

Ahmad Sohail
Full Stack Developer

Ahmad is a full-stack developer with a strong foundation in C#, Python, and web technologies. He has a deep interest in building scalable software solutions and enjoys exploring how design and functionality meet in real-world applications.

Before joining the Iron Software team, Ahmad worked on automation projects ...

Read More
Ready to Get Started?
Nuget Downloads 25,693 | Version: 2025.11 just released