Forum


Replies: 3   Views: 203
Replacevariable to link
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 11-03-2026 - 14:10

Hello,

All versions of phpdocx, including the oldest ones, apply the following default inline styles to links:

color: 0000ff
underline: single

These styles (blue color and single underline) match the default styles used by MS Word when a hyperlink is added.

Please note that inline styles can't be overridden using a custom character style (rPr styles have a higher priority). You can set a custom color and underline style with the available options (https://www.phpdocx.com/api-documentation/word-content/insert-link-Word-document-with-PHP) as a link added as regular content:

$docx->addLink('A link', ['url' => 'https://www.phpdocx.com', 'color' => '000000', 'underline' => 'none']);

or in a WordFragment:

$linkFragment = new WordFragment($docx);
$linkFragment->addLink('A link', ['url' => 'https://www.phpdocx.com', 'color' => '000000', 'underline' => 'none']);

Premium licenses also include the stylesReplacementType option in replaceVariableByWordFragment and replaceVariableByHTML methods, which allows placeholder styles to be automatically used and mixed during replacements. We recommend upgrading to Premium to use this option.

Regards.