Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Topics

CSS hyphenate-character Property

Posted in CSS Tutorial
Updated on Oct 03, 2024
By Mari Selvan
👁️ 17 - Views
⏳ 4 mins
💬 1 Comment
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.

Syntax
Copied
Copy To Clipboard
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.

index.html
Copied
Copy To Clipboard
<!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:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

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

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy