What is your take on the a href='#' in web applications?
It used to be and may still be very well be today the 'good practice' to always have a # at least in the HREF. Empty or no HREF could cause issues with some browsers I was told.
Today it raises other problems. Those # litter web applications making link sharing duplicates in news site (ie. .com/# is different than .com/ but shouldn't), it also makes statistics skewed in some stats services.
I personally hate to see those empty domain.com/#
Note I have nothing against anchors actually being used as anchors, ie domain.com/#somesection. That's not what I'm referring to.
It also annoys me off to have those littering # in my browser history (ie. when you type in the url bar).
Is there an alternative? Using <button> everywhere can also cause issues in some browsers I read, with some browser using the content of the button tag as labels while some others use the value attribute.
Is using A with no href still SIN today?
And don't tell me about HTML5. If it's not everywhere it's not on my cards.
Thanks.
The standard is to use # in anchor tags that don't link anywhere that get hijacked with javascript and typically using jquery use e.preventDefault() which will stop the # from going into the address bar. You can also use return false. But e.preventDefault() is best practice. You need the # in the href because without it older browsers will not act like its a link which will prevent :hover from working. The # signs you are seeing all over the web are probably people who are not implementing preventDefault or return false. You could also be seeing them for sites that attempt to use something like jquery address for ajax navigation. If you are attempting to copy and share one of these links and it is not working then the developer didn't set up the ajax state management correctly for the particular app you are using. On a side note, you should probably leave these types of programming specific questions for stack overflow. I wouldn't consider this appropriate for hacker news in my opinion. Also you will probably get a larger response for this type of question on stack overflow. Heck, it has probably already been asked and answered multiple times on there.