-4

I'd like to make a dropdown menu for my website, but not sure what language is best to use, since both js and css have the hover option.

George Irimiciuc
  • 4,573
  • 8
  • 44
  • 88
  • 1
    Check out js, and particularly a library called jQueryUI. http://jqueryui.com/menu/ – Jonathan M Jun 25 '14 at 22:16
  • JQuery's animations are probably the best, in my opinion. If you want just simple dropdowns, use CSS. – djbhindi Jun 25 '14 at 22:16
  • I was thinking what happens if JS is not enabled on the client. What happens if I make it in JS and that happens? – George Irimiciuc Jun 25 '14 at 22:17
  • @GeorgeIrimiciuc, you can check if js in enabled and take appropriate action: http://stackoverflow.com/questions/121203/how-to-detect-if-javascript-is-disabled – Jonathan M Jun 25 '14 at 22:19
  • You can do it in pure css. Take a look : http://line25.com/tutorials/how-to-create-a-pure-css-dropdown-menu – s0h3ck Jun 25 '14 at 22:26
  • @GeorgeIrimiciuc, you're going to develop a menu-driven page that doesn't use javascript anywhere else on the page? C'mon man. You're going to be using js somewhere on the page. – Jonathan M Jun 25 '14 at 22:54

1 Answers1

2

The benefits of css over javascript are

  • Will work if people have js turned off (not many these days, I know)
  • Less likely to break if other scripts on the page are invalid
  • Less code (especially if you intend to use a library like jquery for that single purpose)
  • Tidier code - generally a javascript would be a mix of css and js - css would be in one place.

Javascript can add pretty animations (as can modern css tbh), but if it is not also adding a usability benefit, then I'd go with pure css whenever possible.

RichardB
  • 2,615
  • 1
  • 11
  • 14
  • An exception can be made, however, if a nice library exists or you want to have more control over the list and its functions. Ultimately, it depends on what you're trying to do, but I'd take CSS over JS usually for said reasons. – tomysshadow Jun 25 '14 at 23:11