Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Can not link to "id" in shortcuts

by Lady_Aleena (Priest)
on Jun 01, 2017 at 07:37 UTC ( [id://1191797]=note: print w/replies, xml ) Need Help??


in reply to Re: Can not link to "id" in shortcuts
in thread Can not link to "id" in shortcuts

Using the name attribute on most elements is not the standard. The name attribute is to be used on button, fieldset, form, iframe, input, keygen, map, meta, object, output, param, select, and textarea. Using the name attribute on anything else will lead to poor HTML. The id attribute should be used, and is also what I am most used to using to create links to parts of an HTML document. You can look at the W3C list of attributes to double check me. I do not remember when it was good html to use name instead of id.

Sorry for the impromptu lesson on HTML.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re^3: Can not link to "id" in shortcuts
by kcott (Archbishop) on Jun 01, 2017 at 08:53 UTC

    The markup on PerlMonks is not strict HTML; for instance, <code> tags are non-standard and square brackets are handled specially.

    For markup here, you'll need to use name attributes to create fragment identifiers to link to.

    I think the majority of browsers will accept name attribute values as fragment identifiers — I just successfully tested that with Firefox, Opera and Safari — so if you need to create links to sections here, from another site, you can do so like this:

    <a href="http://www.perlmonks.org/?node_id=43037#general">...</a>

    Important: Please do not use markup like that here! See "All Links Within PerlMonks Should Be Relative" for details.

    — Ken

Re^3: Can not link to "id" in shortcuts (updated)
by haukex (Archbishop) on Jun 01, 2017 at 08:35 UTC

    You've linked to the HTML 5 spec, which says that using the name attribute is a fallback when there is no such id in the document. PerlMonks is definitely not HTML 5 compliant, if you look at the source you'll see <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> (and even so it fails validation badly), so have a look at the HTML 4.01 spec. Plus, the Markup in the Monastery isn't even "real" HTML (<readmore>, <spoiler>, etc.). <a name="..."></a> has been the standard way to create an anchor as far back as HTML 2.0 HTML 1.0, so don't expect browsers to remove support for it anytime soon.

    Sorry for the impromptu lesson on HTML ;-P

    Update: I didn't see shmem's post before I posted.

    Update 2: <a name="..."> is additionally discussed in the HTML 5 spec in the section "Obsolete but conforming features".

Re^3: Can not link to "id" in shortcuts
by shmem (Chancellor) on Jun 01, 2017 at 08:30 UTC
    The name attribute is to be used on button, fieldset, form, iframe, input, keygen, map, meta, object, output, param , select, and textarea. Using the name attribute on anything else will lead to poor HTML.

    You forgot a which is the most common tag for which the name attribute is valid. <a></a> is anchor and it is used as <a href="$url">link text</a> and <a name="anchor_name">anchor in text</a> to mark an anchor in a page whose href would then be <a href="$url#anchor_name">target text</a>.

    So, For Lady_Aleena ([href://?node_id=535366#Lady_Aleena|For Lady_Aleena]) links to the copy of this node marked as <a name="Lady_Aleena">For Lady Aleena</a> on my scratchpad. This is described on What shortcuts can I use for linking to other information?.

    You cannot link to a id or to any tag for which the name attribute is valid and set, only to an anchor (<a name="foo">foo</a>).

    Sorry for the impromptu lesson on HTML and PerlMonks markup. :-D

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^3: Can not link to "id" in shortcuts
by soonix (Canon) on Jun 01, 2017 at 09:04 UTC
    D'oh! Me too, didn't know <a name=… is deprecated.

    Looks like the difference between HTML (up to 4) and HTML 5 is similiar to that between Perl and Perl 6 ;-P

      Looks like the difference between HTML (up to 4) and HTML 5 is similiar to that between Perl and Perl 6 ;-P

      Not really, I believe HTML 5 is, except for some deprecations, a superset of HTML 4.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1191797]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found