Question: Element with :first-letter can't be selected

Question

Element with :first-letter can't be selected

Answers 1
Added at 2016-12-29 10:12
Tags
Question

In Chrome (Version 55.0.2883.87 m) (win 8.1) text in element with :first-letter can't be selected (in full) with mouse selection.

Does this have a workaround without javascript?

div:first-letter{
  text-transform: capitalize;
}
<div>
unselectable
</div>

Answers
nr: #1 dodano: 2016-12-29 10:12

This has been a known bug in Chrome for a while now, dating back since 2009.

https://bugs.chromium.org/p/chromium/issues/detail?id=17528

A 'hacky fix' can be applied by using a HTML comment before the text, you still can't select the U (but you can select the n). But copy-pasting the selection will actually give you all the content in the div.

div:first-letter{
  text-transform: capitalize;
}
<div>
<!-- -->unselectable
</div>

Source Show
◀ Wstecz