Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

36125 add text emphasis position auto #36331

Merged
Merged
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
23699af
added syntax and value
dletorey Oct 9, 2024
68628cb
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 14, 2024
a1bd1fc
added a explanation of ruby and added an extra example
dletorey Oct 14, 2024
9798710
updated the directions to make the preffered make more sense
dletorey Oct 14, 2024
b42f66b
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 14, 2024
4eabee1
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
5d5d71e
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
47d0f1a
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
a8db613
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
213a392
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
dcb718d
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
83ffbbe
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
dfd9587
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
f293d17
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
a39c559
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 16, 2024
b681ce7
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 16, 2024
68a97b1
added comments explaining the text
dletorey Oct 16, 2024
4e39664
Merge branch '36125-add-text-emphasis-position-auto' of github.com:Co…
dletorey Oct 16, 2024
2b1213f
added extra values to syntax and added supports at rule to example
dletorey Oct 16, 2024
e8b120f
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 17, 2024
373408d
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 17, 2024
fc2118e
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 17, 2024
26daf0c
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 17, 2024
63cb72e
fixed the values list
dletorey Oct 17, 2024
04fcf9c
Merge branch '36125-add-text-emphasis-position-auto' of github.com:Co…
dletorey Oct 17, 2024
1536ab6
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 18, 2024
4c3b87c
Update files/en-us/web/css/text-emphasis-position/index.md
dletorey Oct 28, 2024
46bc697
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 28, 2024
aefba5d
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 28, 2024
3dc9890
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 28, 2024
de2bdb6
added examples heading
dletorey Oct 28, 2024
c215272
Merge branch 'main' into 36125-add-text-emphasis-position-auto
dletorey Oct 29, 2024
8f5cd5d
fixed the values section
dletorey Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 105 additions & 4 deletions files/en-us/web/css/text-emphasis-position/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ browser-compat: css.properties.text-emphasis-position

{{CSSRef}}

The **`text-emphasis-position`** [CSS](/en-US/docs/Web/CSS) property sets where emphasis marks are drawn. Like ruby text, if there isn't enough room for emphasis marks, the line height is increased.
The **`text-emphasis-position`** [CSS](/en-US/docs/Web/CSS) property sets where emphasis marks are drawn. Similar to the text rendered by the [`<ruby>`](/en-US/docs/Web/HTML/Element/ruby) HTML element, if there isn't enough room for emphasis marks, the line height is increased.

{{EmbedInteractiveExample("pages/css/text-emphasis-position.html")}}

## Syntax

```css
/* Initial value */
text-emphasis-position: over right;
text-emphasis-position: auto;

/* Keyword values */
text-emphasis-position: over;
text-emphasis-position: under;

/* Keywords value */
text-emphasis-position: over right;
text-emphasis-position: over left;
text-emphasis-position: under right;
text-emphasis-position: under left;

text-emphasis-position: left over;
text-emphasis-position: right over;
text-emphasis-position: right under;
text-emphasis-position: left under;
dletorey marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -36,6 +41,12 @@ text-emphasis-position: unset;

### Values

dletorey marked this conversation as resolved.
Show resolved Hide resolved
The property accepts one or two values:
dletorey marked this conversation as resolved.
Show resolved Hide resolved

- If only one value is provided, it can be `auto`, `over`, or `under`. When only `over` or `under` is used, `right` is assumed as the default position.
dletorey marked this conversation as resolved.
Show resolved Hide resolved
- If two values are provided, they must include one of `over` or `under`and one of `right` or `left`. Their order does not matter.
dletorey marked this conversation as resolved.
Show resolved Hide resolved
- `auto` {{Experimental_Inline}}
- : Draws marks over the text in horizontal writing mode and to the right of the text in vertical writing mode.
dletorey marked this conversation as resolved.
Show resolved Hide resolved
- `over`
- : Draws marks over the text in horizontal writing mode.
- `under`
Expand Down Expand Up @@ -116,7 +127,97 @@ The preferred position of emphasis marks depends on the language. In Japanese fo

{{csssyntax}}

## Examples
dletorey marked this conversation as resolved.
Show resolved Hide resolved
### Adding emphasis mark positions

### Emphasis mark positions
dletorey marked this conversation as resolved.
Show resolved Hide resolved
dletorey marked this conversation as resolved.
Show resolved Hide resolved

Use the drop down menu to change the position of the emphasis marks. This will change the class on the `<section>` element, which in turn, updates the position of the emphasis marks on the text.
dletorey marked this conversation as resolved.
Show resolved Hide resolved

#### HTML

```html hidden
<p class="unsupported">The <code>auto</code> value is not supported in your browser.</p>
<label for="position">Emphasis position:</position>
<select id="position">
<option value="auto">auto</option>
<option value="over-right">over right</option>
<option value="over-left">over left</option>
<option value="under-right">under right</option>
<option value="under-left">under left</option>
<option value="preferred">preferred</option>
</select>
```

```html
<section id="setting" class="auto">
<p class="horizontal" lang="zh">你好世界</p>
<!-- Hello World in Chinese -->
<p class="vertical" lang="ja">世界、こんにちは。</p>
<!-- Hello World in Japanese -->
</section>
```

#### CSS
dletorey marked this conversation as resolved.
Show resolved Hide resolved

```css hidden
.unsupported {
color: red;
}
@supports (text-emphasis-position: auto) {
.unsupported {
display: none;
}
}
.horizontal {
writing-mode: horizontal-tb;
}
.vertical {
writing-mode: vertical-rl;
}
section {
display: flex;
justify-content: space-around;
}
```

```css
section p {
text-emphasis: filled circle tomato;
text-emphasis-position: auto;
}
.over-right p,
.preferred p [lang="ja"] {
text-emphasis-position: over right;
}
.over-left p {
text-emphasis-position: over left;
}
.under-right p,
.preferred p [lang="zh"] {
text-emphasis-position: under right;
}
.under-left p {
text-emphasis-position: under left;
}
.preferred p [lang="ja"] {
}
```

```js hidden
const position = document.querySelector("#position");
const setting = document.querySelector("#setting");
const updateClass = () => {
const currentClass = setting.classList;
setting.classList.replace(currentClass, position.value);
};
position.addEventListener("change", updateClass);
```

#### Result

Use the "Emphasis position" drop down to choose the location of the emphasis marks. The `preferred` option in the drop down uses the preferred positions, as explained in the [Description](#description) section.

{{EmbedLiveSample("Emphasis_mark_positions", 450, 170)}}
dletorey marked this conversation as resolved.
Show resolved Hide resolved

### Preferring ruby over emphasis marks

Expand Down