CSS - text-emphasis Property



In CSS, the text-emphasis property is used to add emphasis to text, such as adding some color, string or patterns around the text.

It is a shorthand property for the following properties:

  • text-emphasis-color: Sets the color of the emphasis marks around a text (color name, rgb value, hex code, rgba, etc.).

  • text-emphasis-style: Sets the style or appearance of the emphasis marks around a text (none, open, dot, circle, double-circle, sesame, etc.).

  • text-emphasis-position: Sets the position of the emphasis marks around a text.

Text Emphasis Color

The property text-emphasis-color is used to set the color of the emphasis marks around a text. If no color is specified, the currentcolor value is set as default value.

Possible Values

  • color name: Name of a color. Example = red, blue, etc.

  • RGB: An RGB value. Example = rgb(255,200,120)

  • RGBA: An RGBA value. Example = rgba(255,200,120,0.4).

  • HEX code: A hexadecimal code. Example = #ff00ff.

Applies to

All the HTML elements.

DOM Syntax

object.style.textEmphasisColor = "#ff00ff";

CSS text-emphasis - With Color

<html>
<head>
</head>
<body>
   <h2>Text Emphasis</h2>
      <p style="text-emphasis-color: red; text-emphasis-style: '*';">Text Emphasis name.</p>
      <p style="text-emphasis-color: #00ffff; text-emphasis-style: dot;">Text Emphasis HEX code.</p>
      <p style="text-emphasis-color: rgb(235,120,90); text-emphasis-style: circle;">Text Emphasis RGB.</p>
      <p style="text-emphasis-color: rgba(2, 47, 24, 0.8); text-emphasis-style: triangle;">Text Emphasis RGBA.</p>
</body>
</html> 

CSS text-emphasis-style

The property text-emphasis-style is used to add style to the emphasis marks around a text.

Possible Values

  • none: Sets no emphasis mark.

  • filled: Fills the element with solid color. Default value.

  • open: Sets the shape as hollow.

  • dot: Marks displayed as small circles, either open or filled dot.

  • circle: Marks displayed as large circles, either open or filled circle. Default shape in horizontal writing.

  • double-circle: Marks displayed as double circles, either open or filled double circle.

  • triangle: Marks displayed as triangles, either open or filled triangle.

  • sesame: Marks displayed as sesames (~), either open or filled sesame. Default shape in vertical writing.

  • <string>: Marks displayed as the passed string value.

  • <color>: Sets the color of the mark.

Applies to

All the HTML elements.

DOM Syntax

object.style.textEmphasisStyle = "circle";

CSS text-emphasis-style - Basic Example

Let us see an example:

<html>
<head>
</head>
<body>
   <h2>Text Emphasis</h2>
      <p style="text-emphasis-style: 'm'; text-emphasis-color: blue;">Text Emphasis string.</p>
      <p style="text-emphasis-style: double-circle; text-emphasis-color: black;">Text Emphasis double-circle.</p>
      <p style="text-emphasis-style: filled circle; text-emphasis-color: rgb(235,120,90);">Text Emphasis filled circle.</p>
      <p style="text-emphasis-style: triangle; text-emphasis-color: rgba(2, 47, 24, 0.8);">Text Emphasis triangle.</p>
</body>
</html> 

CSS text-emphasis - With Position

The property text-emphasis-position is used to set the position of the emphasis mark around a text.

Possible Values

  • over right

  • over left

  • under right

  • under left

  • left over

  • right under

  • left under

  • over: Marks drawn over the text in horizontal writing pattern.

  • under: Marks drawn under the text in horizontal writing pattern.

  • right: Marks drawn to the right of the text in vertical writing pattern.

  • left: Marks drawn to the left of the text in vertical writing pattern.

Positioning of emphasis marks is preferred based on the language. Like in chinese, the preferred position is under right, whereas in Japanese it is over right.

Applies to

All the HTML elements.

DOM Syntax

object.style.textEmphasisPosition = "over right";

Let us see an example:

<html>
<head>
</head>
<body>
   <h2>Text Emphasis Position</h2>
      <p style="text-emphasis-style: 'm'; text-emphasis-color: blue; text-emphasis-position: over left;">Text Emphasis position.</p>
      <p style="text-emphasis-style: double-circle; text-emphasis-color: black; text-emphasis-position: under right">Text Emphasis position.</p>
      <p style="text-emphasis-style: filled circle; text-emphasis-color: rgb(235,120,90); text-emphasis-position: left under">Text Emphasis position.</p>
      <p style="text-emphasis-style: triangle; text-emphasis-color: rgba(2, 47, 24, 0.8); text-emphasis-position: left over">Text Emphasis position.</p>
</body>
</html> 
Advertisements