Home  >  Article  >  Web Front-end  >  How to Fix Inconsistent Text Stroke Appearance in Different Browsers?

How to Fix Inconsistent Text Stroke Appearance in Different Browsers?

Susan Sarandon
Susan SarandonOriginal
2024-10-24 06:02:02358browse

How to Fix Inconsistent Text Stroke Appearance in Different Browsers?

Text Stroke (-webkit-text-stroke) CSS Problem

When using the -webkit-text-stroke CSS property, some users may encounter issues with the stroke's appearance on browsers other than Chrome. This problem, particularly prevalent in browsers that do not fully support variable fonts, can result in the stroke appearing inconsistent with the desired behavior.

Quick Fix/Update 2024: Paint-order for HTML Text

As suggested by HyoukJoon Lee, applying the SVG paint-order property to HTML text elements can effectively resolve this issue. Counterintuitively, the paint-order property, which determines the order in which elements are painted, can be applied to HTML text, as evidenced by support in all major rendering engines.

By leveraging paint-order, the stroke can be rendered behind the text-fill color, similar to the desired behavior in Chrome. Implementing this fix requires altering the CSS as follows:

.outline {<br>  -webkit-text-stroke: 0.04em black;<br>  paint-order: stroke fill;<br>}

The above is the detailed content of How to Fix Inconsistent Text Stroke Appearance in Different Browsers?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn