CSS - hyphenate-character Property



CSS hyphenate-character property allows you to specify the character that should be used as the hyphenation point when text is hyphenated using the hyphens property.

When text is hyphenated, the browser will insert a hyphen character at appropriate points within words to improve the visual appearance of justified text. The hyphenate-character property allows you to customize the character used for hyphenation.

Possible Values

  • <string> − It is used as a <string> at the end of the line before a hyphenation break.

  • auto − Default value. The user-agent determines a suitable string based on the typographic conventions of the content language. Explicit setting is required to override an inherited value.

Applies To

All elements.

Syntax

hyphenate-character: <string> | auto;

It allows a specific string to replace with hyphen, and instructs the user agent to choose suitable string based on typographic conventions (default).

CSS hyphenate-character - auto Value

The following example demonstrates the hyphenate-character: auto property allowing automatic hyphenation in the content of the specified element −

<html>
<head>
<style>
   div { 
      width: 80px;
      border: 2px solid blue;
      hyphens: auto;
      hyphenate-character: auto;
   }
</style>
</head>
<body>
   <div>CSS hyphenate­character auto</div>
</body>
</html>

CSS hyphenate-character - <string> Value

The following example demonstrates the hyphenate-character property, with different hyphenation characters showing the different effects of the hyphenation behavior −

<html>
<head>
<style>
   div { 
      width: 80px;
      border: 2px solid blue;
      hyphens: auto;
   }
   .box1 {
      hyphenate-character: "=";
   }
   .box2 {
      hyphenate-character: "*";
   }
   .box3 {
      hyphenate-character: "%";
   }
</style>
</head>
<body>
   <h3>hyphenate-character: "="</h3>
   <div class="box1">CSS hyphenate­character auto</div>
   <h3>hyphenate-character: "*"</h3>
   <div class="box2">CSS hyphenate­character auto</div>
   <h3>hyphenate-character: "%"</h3>
   <div class="box3">CSS hyphenate­character auto</div>
</body>
</html>
Advertisements