You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -284,6 +284,20 @@ Lang is a [built-in global attribute](https://developer.mozilla.org/en-US/docs/W
284
284
285
285
Adding the `no-title` attribute will remove the `title` attribute from the `<relative-time>` element. The `title` attribute is inaccessible to screen reader and keyboard users, so not adding a title attribute allows a user to create a custom, accessible tooltip if one is desired.
286
286
287
+
## Styling
288
+
289
+
The element renders its text inside a Shadow DOM `<span>` with a [`part="root"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part) attribute. This allows you to style the element inside the Shadow DOM from outside using the `::part()` CSS pseudo-element:
290
+
291
+
```css
292
+
relative-time::part(root) {
293
+
color: rebeccapurple;
294
+
font-weight: bold;
295
+
}
296
+
relative-time::part(root)::selection {
297
+
background: lightgreen;
298
+
}
299
+
```
300
+
287
301
## Browser Support
288
302
289
303
Browsers without native [custom element support][support] require a [polyfill][ce-polyfill].
0 commit comments