I have text in a tag:
Hello world... and goodbye mind A B!
How do I increase the area in which the te
One approach is to increase the line-height
of the element. On a mobile device, you can better select a text fragment, because of the larger spacing between the lines. If you define the values in
em
, the spacing is always relative to the font-size
.
A second approach is to increase the word-spacing
of the text element to a level which is still acceptable. I would recommend a maximal value of of 0.2em
.
HTML:
Extended Selection
CSS:
p.extendedSelection {
line-height: 2em;
word-spacing: 0.2em;
}
JSFiddle here
If those two approaches are not good enough, you could of course create an absolute positioned element for each word, which overlays the text element, but has an opacity of 0. The text inside of this element should be equal to the text behind but with a larger font-size. This approach has several drawbacks: You need to calculate the positions of every word and duplicate the text content. It is a rather large calculation for just a little effect.