CSS mouse cursor over text in div

17.6k views Asked by At

I want to change the mouse cursor over the text in a certain div. If I use:

.divchange { cursor: pointer;}

the cursor will change over the whole div and not just over the text.

2

There are 2 answers

0
Anmol Sandal On

You can place a text in span or you can add hover to the certain text.

Using Hover

.text p:hover {cursor: pointer;}
<div class="text">
  <p>Hello</p>
</div>

Or just adding style to that element where you want cursor to be a pointer

.text p{cursor: pointer;}
<div class="text">
  <p>Hello</p>
</div>

0
kyun On

.divchange { 
  display: inline-block;
  cursor: pointer;

}
<div style="background:gray">
  <div class="divchange">text only</div>
</div>

The point is display:inline-block.