alt
alt

Reputation: 13947

Is there a better way to change the cursor? Am I doing it right?

I was just using some javascript the other day, and previously, the only way I knew how to get it to display the cursor was to do this:

1:

<a href="javascript:" onClick="myfunction()"></a>

But I decided to find some other ways to do it. Not wanting to have my css messy and all over the place, I added this to my stylesheet:

2:

a{
    cursor:pointer
}

I'm not styling non-link anchors anywhere else. Is it okay to style non-link anchors?

3:

Or is there a way I should being doing it with javascript that's better then the two ways listed above.

Upvotes: 0

Views: 197

Answers (3)

Saad Imran.
Saad Imran.

Reputation: 4530

Hey some browsers call the cursor a pointer, others call it a hand (forgot which ones which). So what you have to do is

.pointable
{
    cursor: pointer;
    cursor: hand;
}

Edit:

I like to make a css style called pointable and applying it to whatever elements I want pointable.

<div class="box pointable rounded">dggf</div>
<a class="pointable">sdds</a>

Upvotes: 1

yakatz
yakatz

Reputation: 2282

All <a> tags should have an href attribute even if it is blank or says javascript:;.
So I recommend option 1.

Upvotes: 0

Hogan
Hogan

Reputation: 70528

As long as this does not get in the way of how you style the <a> tag anywhere else on your page this is the best way to do it.

Upvotes: 1

Related Questions