Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the handle in JQuery UI slider is <a> tag?

I was reading the code in the official demo page for slider: http://jqueryui.com/demos/slider/ and I was wondering why an <a> tag is used for handle? Why not a <div>?

<div class="demo">

<div id="slider" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all">
    <a class="ui-slider-handle ui-state-default ui-corner-all ui-state-hover" href="#" style="left: 19%; ">
    </a>
</div>

</div>
like image 425
AlexStack Avatar asked Apr 04 '12 12:04

AlexStack


2 Answers

I think they used an anchor because in HTML links are what separate HTML from other markup languages because they provide interaction. Taken from w3c

HTML offers many of the conventional publishing idioms for rich text and structured documents, but what separates it from most other markup languages is its features for hypertext and interactive documents. This section introduces the link (or hyperlink, or Web link), the basic hypertext construct. A link is a connection from one Web resource to another. Although a simple concept, the link has been one of the primary forces driving the success of the Web.

And the handle is also something you click, so maybe they thought that semantically made more sense using an <a> instead of a <span>.

To make it clear, my thought is that they could have used anything technically but they choose an anchor for semantic reasons

like image 165
Nicola Peluchetti Avatar answered Sep 30 '22 11:09

Nicola Peluchetti


I was wondering the same ... so here I am ... with a theory!

The handles need to be able to have the focus
(when they do, you can use the arrows, Home- and End-keys to manipulate the handles)

Not sure if spans or divs can have the focus (in all browsers..) ?

Maybe <button> could be used instead ? (somebody, please try)
- that would make more sense. And not clutter up the status-line : (
(Could we get into trouble, if there's a surrounding form without a proper submit-button ?)

like image 26
T4NK3R Avatar answered Sep 30 '22 10:09

T4NK3R