diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php index 055e1b5eb1..79d34e3ad9 100644 --- a/src/PhpWord/Writer/HTML/Part/Head.php +++ b/src/PhpWord/Writer/HTML/Part/Head.php @@ -98,7 +98,9 @@ private function writeStyles() // Default styles $defaultStyles = array( - '*' => array( + // 'html' is used instead of '*' to ensure nested elements inherit from their parents. + // `h1 > span` should have the same font size as the `h1` parent. + 'html' => array( 'font-family' => Settings::getDefaultFontName(), 'font-size' => Settings::getDefaultFontSize()->toInt('pt') . 'pt', ), diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index 700fc79b53..54b99d9d2e 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -49,7 +49,7 @@ public function testRoundTripHeadings() PHPWord