473,595 Members | 2,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

proper ways for empty link

if i want to have a empty link, which way is more proper?

<a href="">
<a href="#">
<a href="javascrip t:void(0);">

Xah
xa*@xahlee.org
http://xahlee.org/

Nov 23 '05 #1
17 30619
Els
Xah Lee wrote:
if i want to have a empty link, which way is more proper?

<a href="">
<a href="#">
<a href="javascrip t:void(0);">


How about <a> ?
It's not a link really, but then again, I have no idea why one would
need an empty link...
Can you elaborate on what you are actually trying to achieve?

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Nov 23 '05 #2
"Xah Lee" <xa*@xahlee.org > wrote:
if i want to have a empty link, which way is more proper?
Why would you want to have an empty link?
<a href="">
This is a reference to the document itself.
<a href="#">
This is a reference to the start of the current document.
<a href="javascrip t:void(0);">


This is undefined; javascript: URLs are unregistered.

You could create a self-referencing link, too:
<a name="foo42" href="#foo42">

I suppose you want to have an "empty" link so that you can make something
clickable, triggering some scripted events, without making it a link.
The simple answer is: don't.

Make it a link that points to an address that contains a useful replacement
for the functionality, if it is relevant.

<a href="#nojs" onclick="foo(); return false">
.. . .
<h2 id="nojs">Somet hing</h2>
<p>Put here something useful.</p>

If your piece of HTML code has been _generated_ with JavaScript, so that the
element does not appear if JavaScript is off, use href="#" but make sure your
event handler returns false, so that the href will never be used (it could be
harmful if it caused a movement to the start of the document).

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Nov 23 '05 #3
VK

Xah Lee wrote:
if i want to have a empty link, which way is more proper?

<a href="">
<a href="#">
<a href="javascrip t:void(0);">
You may want to read this extensive (and rather intensive) discussion
on this very question here:
<http://groups.google.c om/group/comp.lang.javas cript/browse_frm/thread/4d2e99b2a8bdbbd 2/b595a7a81b0a62a 3>
From the *listed* options I personally would stay with:

<a href="javascrip t:void(myFuncti on())">

<a href=""> and <a href="#"> will lead to page shift/scroll if the page
is long enough on older browsers.

Nov 23 '05 #4
VK wrote:
From the *listed* options I personally would stay with:

<a href="javascrip t:void(myFuncti on())">


Of the listed options, this is the _worst_.

There is no reason to use this as opposed to:
<a href="javascrip t_required.html " onClick="myFunc tion(); return
false;">link</a>

See "Using onClick in <A> tags" in
http://www.JavascriptToolbox.com/bestpracties/

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 23 '05 #5
Xah Lee a écrit :
if i want to have a empty link, which way is more proper?

<a href="">
<a href="#">
<a href="javascrip t:void(0);">

Xah
xa*@xahlee.org
http://xahlee.org/


Your question is as logical, coherent as asking
- how to have a table without any table cells
- how to have a paragraph without any content
- how to have some kind of structure without any content or without any
functionality or without any purpose

A link should always be a link otherwise you're misusing such HTML element.

Gérard
--
remove blah to email me
Nov 23 '05 #6
In our last episode,
<11************ *********@g44g2 000cwa.googlegr oups.com>,
the lovely and talented Xah Lee
broadcast on comp.infosystem s.www.authoring.html:
if i want to have a empty link, which way is more proper? <a href="">
<a href="#">
<a href="javascrip t:void(0);">


This question makes no sense. Tell us what it is you are
really trying to do.
--
Lars Eighner us****@larseigh ner.com http://www.larseighner.com/
"Shhh! Be vewwy, vewwy quiet! I'm hunting Muswims!"
- President Elmer Bush
Nov 23 '05 #7
Grard Talbot wrote:
Xah Lee a crit :
if i want to have a empty link, which way is more proper?
- - Your question is as logical, coherent as asking
- how to have a table without any table cells
- how to have a paragraph without any content
- how to have some kind of structure without any content or without any
functionality or without any purpose


Well, logically, it's not quite the same. The question apparently meant
"functional ly empty", i.e. a link that does not work as a link, as
opposite to an element with no content. A link that is empty in the
latter sense, <a href="something "></a>, is syntactically correct but
usually nonsensical - though it might be used to fool search engines,
and there is no law against browsers letting users to follow such a link.

A table without any table cells, on the other hand, is syntactically
incorrect (invalid), since a <table> element must contain at least one
<tr> element, which in turn must contain at least one <th> or <td>
element. The cell could be empty, though (<td></td>).

A paragraph without any content, <p></p>, is syntactically correct,
though the HTML spec explicitly says that it should not be used.
Actually, the common formatting trick is not <p></p> but <p>&nbsp;</p>,
which has content syntactically, but not semantically.

Followups trimmed to ciwah.
Nov 23 '05 #8
Jukka K. Korpela wrote:
"Xah Lee" <xa*@xahlee.org > wrote:
<a href="">
This is a reference to the document itself.


As specified in RFC3986, subsection 4.4.
<a href="#">


This is a reference to the start of the current document.


Actually, this known user agents' behavior is not a specified one.
<a href="javascrip t:void(0);">


This is undefined;


It is not, at least by use. `javascript:' URIS are designed to return
(HTML) documents from script code and no known HTML user agent capable
of client-side JS returns a document when the `undefined' value is used.
javascript: URLs are unregistered.


However, they exist. Not to be used for this purpose, though.

BTW: I would call them URIs. We have an unspecified URI scheme here.
AFAIK there is no general registry of URI schemes; there are definitions,
maybe (attempts at) specifications (such as RFCs).

The closest thing to a reference I could find is
<http://www.w3.org/TR/WCAG20-SCRIPT-TECHS/#js-uri>
PointedEars
Nov 23 '05 #9
Thomas 'PointedEars' Lahn wrote:
javascript: URLs are unregistered.
However, they exist. Not to be used for this purpose, though.

BTW: I would call them URIs.


<javascript:som e(); js_code(2 * 23 / 35);> is certainly not an URI, and I
have never seen JS code properly encoded (and I doubt that there is broad
browser support for this).
We have an unspecified URI scheme here.
AFAIK there is no general registry of URI schemes; there are definitions,
maybe (attempts at) specifications (such as RFCs).


<http://www.iana.org/assignments/uri-schemes>
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
5902
by: stanio | last post by:
As part of a thread on netscape.public.dev.css a guy (Gus Richter) tries to convince me <a><span></span></a> is not an empty anchor: > Of course the <p></p> is empty and in the following; > <div><a href="#"><span id="header"></span></a></div> > The div has an anchor as content. > *The anchor has span as content*. (Your erroneous contention is that > <a><span></span></a> is an empty anchor.) > The span, on the other hand, is empty,...
14
5551
by: Xah Lee | last post by:
if i want to have a empty link, which way is more proper? <a href=""> <a href="#"> <a href="javascript:void(0);"> Xah xah@xahlee.org ∑ http://xahlee.org/
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.