- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS text-emphasis-position Guide & Examples
Enhance your text emphasis with above, below, right, and left positioning.
Introduction
The text-emphasis-position
CSS property lets you specify where emphasis marks, like dots or lines, are drawn relative to the text. This is particularly useful for languages like Japanese, Chinese, and Mongolian. If there isn’t enough space for these marks, the line height of the text will increase to make room for them.
Specification
The text-emphasis-position
property is defined in the CSS Text Decoration Module Level 3. This module extends the capabilities of CSS to handle text decorations, including emphasis marks. For more detailed information, you can refer to the official specification:
Syntax
The text-emphasis-position
property can be set using various keywords to specify the position of emphasis marks relative to the text.
Keywords
over
: Positions the emphasis marks above the text in horizontal writing mode.under
: Positions the emphasis marks below the text in horizontal writing mode.right
: Positions the emphasis marks to the right of the text in vertical writing mode.left
: Positions the emphasis marks to the left of the text in vertical writing mode.
Examples
Values
The text-emphasis-position
property accepts several keyword values that determine where the emphasis marks will be drawn relative to the text.
Keywords
over
: Positions the emphasis marks above the text in horizontal writing mode.under
: Positions the emphasis marks below the text in horizontal writing mode.right
: Positions the emphasis marks to the right of the text in vertical writing mode.left
: Positions the emphasis marks to the left of the text in vertical writing mode.
Combined Values
You can also combine these values to specify the position of emphasis marks for both horizontal and vertical writing modes simultaneously.
over right
: Positions the emphasis marks above the text in horizontal writing mode and to the right of the text in vertical writing mode.over left
: Positions the emphasis marks above the text in horizontal writing mode and to the left of the text in vertical writing mode.under right
: Positions the emphasis marks below the text in horizontal writing mode and to the right of the text in vertical writing mode.under left
: Positions the emphasis marks below the text in horizontal writing mode and to the left of the text in vertical writing mode.left over
: Positions the emphasis marks to the left of the text in vertical writing mode and above the text in horizontal writing mode.right under
: Positions the emphasis marks to the right of the text in vertical writing mode and below the text in horizontal writing mode.left under
: Positions the emphasis marks to the left of the text in vertical writing mode and below the text in horizontal writing mode.
Global Values
inherit
: Inherits the value from the parent element.initial
: Sets the property to its initial value (over right
).revert
: Reverts the property to the value specified by the user-agent stylesheet.revert-layer
: Reverts the property to the value specified by the user-agent stylesheet for the cascade layer.unset
: Resets the property to its inherited value if it inherits, or to its initial value if not.
Description
The text-emphasis-position
property is a powerful CSS feature that allows you to specify the position of emphasis marks relative to the text. These marks are commonly used to highlight or draw attention to specific parts of the text, particularly in languages like Japanese, Chinese, and Mongolian. The positioning of these marks can vary depending on the language and writing mode (horizontal or vertical).
Preferred Positions by Language
The preferred position of emphasis marks can differ based on the language:
- Japanese: In Japanese, the preferred position is
over right
. This means that emphasis marks are drawn above the text in horizontal writing mode and to the right of the text in vertical writing mode. - Chinese: In Chinese, the preferred position is
under right
. This means that emphasis marks are drawn below the text in horizontal writing mode and to the right of the text in vertical writing mode. - Mongolian: Similar to Japanese, the preferred position in Mongolian is
over right
.
Table Summary
Language | Preferred Position (Horizontal) | Preferred Position (Vertical) |
---|---|---|
Japanese | over | right |
Korean | over | right |
Mongolian | over | right |
Chinese | under | right |
Important Note
It’s important to note that the text-emphasis-position
property cannot be set or reset using the text-emphasis
shorthand property. This means you need to specify the text-emphasis-position
property separately to control the position of emphasis marks.
Formal Definition
The text-emphasis-position
property in CSS defines the position of emphasis marks relative to the text. This property is particularly useful for languages that use emphasis marks, such as Japanese, Chinese, and Mongolian.
Initial Value
- Initial Value:
over right
Applies To
- Applies To: All elements
Inherited
- Inherited: Yes
Computed Value
- Computed Value: As specified
Animation Type
- Animation Type: Discrete
Formal Syntax
The formal syntax of the text-emphasis-position
property defines the structure and valid values for specifying the position of emphasis marks.
Explanation
[ over | under ]
: This part of the syntax specifies the horizontal position of the emphasis marks. You can choose betweenover
(above the text) andunder
(below the text).&&
: This operator indicates that both horizontal and vertical positions must be specified.[ right | left ]
: This part of the syntax specifies the vertical position of the emphasis marks. You can choose betweenright
(to the right of the text) andleft
(to the left of the text).?
: This operator indicates that the vertical position is optional but can be combined with the horizontal position.
Examples
Examples
Example 1: Horizontal Text with Over and Under Emphasis
HTML:
Example 2: Vertical Text with Left and Right Emphasis
HTML:
Preferring Ruby Over Emphasis Marks or Vice Versa
Some editors prefer to hide emphasis marks when they conflict with ruby text. In HTML, this can be achieved using the following CSS:
On the other hand, some editors prefer to hide ruby text when it conflicts with emphasis marks. This can be done with the following CSS:
Browser Compatibility
The text-emphasis-position
property is supported by the following browsers:
- Chrome 99 and above
- Edge 99 and above
- Firefox 46 and above
- Opera 15 and above
- Safari 7 and above
See Also
For further exploration and related properties, you might want to check out the following CSS properties:
- [
text-emphasis-style
]WebsiteUrl: Defines the style of the emphasis marks. - [
text-emphasis-color
]WebsiteUrl: Sets the color of the emphasis marks. - [
text-emphasis
]WebsiteUrl: A shorthand property that combinestext-emphasis-style
andtext-emphasis-color
.
These properties work together with text-emphasis-position
to provide comprehensive control over text emphasis, allowing you to create visually appealing and culturally appropriate text emphasis in your web projects.
Talk with CEO
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.