CSS Properties
CSS hyphenate-character Property
Photo Credit to CodeToFun
🙋 Introduction
The hyphenate-character
property in CSS is used to specify the string that will be used to represent hyphens when words are split at the end of a line.
This property allows you to customize the appearance of hyphenation in text, providing more control over typography and ensuring consistency with your design aesthetics.
💡 Syntax
The syntax for the hyphenate-character
property is straightforward. You can specify a string, such as a single character or a sequence of characters, to be used as the hyphenation character.
element {
hyphenate-character: string;
}
Here, string can be a single character (like "-") or a sequence of characters (like "—" or "...").
🎛️ Default Value
The default value of the hyphenate-character
property is the commonly used hyphen character ("-").
🏠 Property Values
- string: A string that specifies the character or characters to be used for hyphenation. This can include:
- A single hyphen ("-")
- A longer dash ("—")
- Multiple characters ("...")
📄 Example
In this example, we'll change the hyphenate character to an em dash ("—") for a paragraph.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS hyphenate-character Example</title>
<style>
p {
hyphenate-character: "—";
hyphens: auto;
}
</style>
</head>
<body>
<h1>Paragraph with Custom Hyphenate Character</h1>
<p>
This is an example paragraph that demonstrates the use of a custom hyphenate character. When the text is split at the end of a line, it will use an em dash instead of the default hyphen character.
</p>
</body>
</html>
🖥️ Browser Compatibility
The hyphenate-character
property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.
🎉 Conclusion
The hyphenate-character
property provides web developers with a valuable tool for controlling the appearance of hyphenation in text.
By customizing the character used for hyphenation, you can ensure that your text looks polished and professional, maintaining consistency with your overall design. Experiment with different characters to see how this property can enhance the readability and visual appeal of your web content.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (CSS hyphenate-character Property), please comment here. I will help you immediately.