diff --git a/core/src/html/text_format.rs b/core/src/html/text_format.rs
index 4596fe65031e..f7f761739c4b 100644
--- a/core/src/html/text_format.rs
+++ b/core/src/html/text_format.rs
@@ -1000,6 +1000,11 @@ impl FormatSpans {
pub fn set_default_format(&mut self, tf: TextFormat) {
self.default_format = tf.mix_with(self.default_format.clone());
+
+ // Empty text always gets the default format.
+ if self.text.is_empty() {
+ self.spans = vec![TextSpan::with_length_and_format(0, &self.default_format)];
+ }
}
pub fn hide_text(&mut self) {