< Template:Link attributes

(Updated doc)
m (updated and fixed, I wrote this a long time ago when S:STYLE didn't exist; also improved inaccuracies)
Line 1: Line 1:
 
{{documentation}}
 
{{documentation}}
 +
 
==Usage==
 
==Usage==
 
{{t|link style}} applies [[Help:CSS|CSS]] style to a link. It accepts six parameters:
 
{{t|link style}} applies [[Help:CSS|CSS]] style to a link. It accepts six parameters:
*1 - the page being linked
+
# the page being linked
*2 - the style of the link
+
# the style of the link
*3 - the style of the link if the page being linked does not exist - optional - only for intra-wiki links
+
# the style of the link if the page being linked does not exist - optional - only for intra-wiki links
*text - link text to show - optional
+
* <code>text</code> - link text to show - optional
*attribs - extra HTML attributes to add
+
* <code>attribs</code> - extra HTML attributes to add
*ext - specify if it is an extenal link
+
* <code>ext</code> - if present, the link is external
 +
 
 
===Link style===
 
===Link style===
 
To change the style of a link:
 
To change the style of a link:
<nowiki>[[Scratch Wiki]] vs. {{link style|Scratch Wiki|color:gray}}</nowiki>
+
<pre>[[Scratch Wiki]] vs. {{link style|Scratch Wiki|color:gray}}</pre>
  
 
[[Scratch Wiki]] vs. {{link style|Scratch Wiki|color:gray}}
 
[[Scratch Wiki]] vs. {{link style|Scratch Wiki|color:gray}}
 +
 
===Alternate link text style===
 
===Alternate link text style===
 
To change the style of a link with custom link text:
 
To change the style of a link with custom link text:
<nowiki>[[Scratch Wiki|the Wiki]] vs. {{link style|Scratch Wiki|color:gray|text=the Wiki}}</nowiki>
+
<pre>[[Scratch Wiki|the Wiki]] vs. {{link style|Scratch Wiki|color:gray|text=the Wiki}}</pre>
  
 
[[Scratch Wiki|the Wiki]] vs. {{link style|Scratch Wiki|color:gray|text=the Wiki}}
 
[[Scratch Wiki|the Wiki]] vs. {{link style|Scratch Wiki|color:gray|text=the Wiki}}
  
 
Note that you ''must'' specify <code>text=</code> to have alternate link text.
 
Note that you ''must'' specify <code>text=</code> to have alternate link text.
 +
 
===Using an external link===
 
===Using an external link===
 
To change whether it is an internal link or an external link:
 
To change whether it is an internal link or an external link:
<nowiki>[https://scratch.mit.edu/ Scratch] vs. {{link style|https://scratch.mit.edu/|color:gray|text=Scratch|ext=t}}</nowiki>
+
<pre>[https://scratch.mit.edu/ Scratch] vs. {{link style|https://scratch.mit.edu/|color:gray|text=Scratch|ext=t}}</pre>
  
 
[https://scratch.mit.edu/ Scratch] vs. {{link style|https://scratch.mit.edu/|color:gray|text=Scratch|ext=t}}
 
[https://scratch.mit.edu/ Scratch] vs. {{link style|https://scratch.mit.edu/|color:gray|text=Scratch|ext=t}}
  
Note that you ''must'' specify <code>ext=t</code> to have an external link.
+
Note that you ''must'' specify <code>ext=something</code> to have an external link. (The value need not be "t" or "something", as long as it's not empty)
 +
 
 
===Red link style===
 
===Red link style===
{{note}} This syntax only styles nonexistent intra-wiki links.
+
{{note|This syntax only styles nonexistent intra-wiki links.}}
 
To change the style of a link to a nonexistent page:
 
To change the style of a link to a nonexistent page:
<nowiki>[[No page here]] vs. {{link style|No page here|color:gray|color:magenta}}</nowiki>
+
<pre>[[No page here]] vs. {{link style|No page here|color:gray|color:magenta}}</pre>
  
 
[[No page here]] vs. {{link style|No page here|color:gray|color:magenta}}
 
[[No page here]] vs. {{link style|No page here|color:gray|color:magenta}}
  
 
Note that the style in the '''third''' parameter is applied, since the page does not exist.
 
Note that the style in the '''third''' parameter is applied, since the page does not exist.
 +
 
===Alternate red link text style===
 
===Alternate red link text style===
{{note}} This syntax only styles nonexistent intra-wiki links.
+
{{note|This syntax only styles nonexistent intra-wiki links.}}
 
To change the style of a link to a nonexistent page with custom link text:
 
To change the style of a link to a nonexistent page with custom link text:
<nowiki>[[No page here|Nope]] vs. {{link style|No page here|color:gray|color:magenta|text=Nope}}</nowiki>
+
<pre>[[No page here|Nope]] vs. {{link style|No page here|color:gray|color:magenta|text=Nope}}</pre>
  
 
[[No page here|Nope]] vs. {{link style|No page here|color:gray|color:magenta|text=Nope}}
 
[[No page here|Nope]] vs. {{link style|No page here|color:gray|color:magenta|text=Nope}}
  
 
Here, four parameters are put into use. The first parameter is the page itself, the second is the style for the link, the third is the style if the page doesn't exist, and <code>text</code> is the alternate text for the link.
 
Here, four parameters are put into use. The first parameter is the page itself, the second is the style for the link, the third is the style if the page doesn't exist, and <code>text</code> is the alternate text for the link.
===Extra HTML <code>title</code> attribute===
+
 
 +
===Extra HTML attributes===
 
To add a <code>title</code> attribute to a link:
 
To add a <code>title</code> attribute to a link:
<nowiki>[[Scratch Wiki]] vs. {{link attributes|Scratch Wiki|attribs=title="Hi, this is a demonstration of the HTML title attribute!"}} (hover)</nowiki>
+
<pre>[[Scratch Wiki]] vs. {{link attributes|Scratch Wiki|attribs=title="Hi, this is a demonstration of the HTML title attribute!"}} (hover)</pre>
  
 
[[Scratch Wiki]] vs. {{link attributes|Scratch Wiki|attribs=title="Hi, this is a demonstration of the HTML title attribute!"}} (hover)
 
[[Scratch Wiki]] vs. {{link attributes|Scratch Wiki|attribs=title="Hi, this is a demonstration of the HTML title attribute!"}} (hover)
  
 
Here, the optional attribute <code>title</code> is applied to the text.
 
Here, the optional attribute <code>title</code> is applied to the text.
 +
 
===All together now===
 
===All together now===
 
To add a <code>title</code> attribute and change the style of a link to a nonexistent page with custom link text:
 
To add a <code>title</code> attribute and change the style of a link to a nonexistent page with custom link text:
<nowiki>[[No page here|Nope]] vs. {{link attributes|No page here|color:gray|color:magenta|text=Nope|attribs=title="You're not finding a page here!"}}</nowiki>
+
<pre>[[No page here|Nope]] vs. {{link attributes|No page here|color:gray|color:magenta|text=Nope|attribs=title="You're not finding a page here!"}}</pre>
  
 
[[No page here|Nope]] vs. {{link attributes|No page here|color:gray|color:magenta|text=Nope|attribs=title="You're not finding a page here!"}}
 
[[No page here|Nope]] vs. {{link attributes|No page here|color:gray|color:magenta|text=Nope|attribs=title="You're not finding a page here!"}}
  
 
And now to link to an external page:
 
And now to link to an external page:
<nowiki>[https://scratch.mit.edu/ Scratch] vs. {{link attributes|No page here|color:gray|color:magenta|text=Nope|attribs=title="You're not finding a page here!"}}</nowiki>
+
<pre>[https://scratch.mit.edu/ Scratch] vs. {{link attributes|https://scratch.mit.edu/|color:gray|text=Scratch|attribs=title="hehe cool"|ext=t}}</pre>
 +
 
 +
[https://scratch.mit.edu/ Scratch] vs. {{link attributes|https://scratch.mit.edu/|color:gray|text=Scratch|attribs=title="hehe cool"|ext=t}}
  
[[No page here|Nope]] vs. {{link style|https://scratch.mit.edu/|color:gray|text=Scratch|ext=t|attribs=title="hehe cool"}}
 
  
 +
Here, in these two examples five parameters are put into use. The first parameter is the link target, the second is the style, <code>text</code> is the link text, <code>ext</code> is to specify it as an external link, and <code>attribs</code> is the extra HTML attributes for the link.
  
Here, in these two examples all six  parameters are put into use. The first parameter is always the page, the second is always the style, the third is the style only for a intra-wiki redlink, <code>text</code> is the alternate text, <code>ext</code> is always to specify it as an external link, and <code>ext</code> must allway be true.(<code>ext=t</code>) Finally <code>attribs</code> is the extra HTML attributes for the link.
 
 
<noinclude>[[Category:Template Documentations]]</noinclude>
 
<noinclude>[[Category:Template Documentations]]</noinclude>

Revision as of 04:17, 12 December 2018

Documentation This is a documentation subpage for Template:Link attributes (see that page for the template itself).
It contains usage information, categories and other content that is not part of the original template page.

Usage

{{link style}} applies CSS style to a link. It accepts six parameters:

  1. the page being linked
  2. the style of the link
  3. the style of the link if the page being linked does not exist - optional - only for intra-wiki links
  • text - link text to show - optional
  • attribs - extra HTML attributes to add
  • ext - if present, the link is external

Link style

To change the style of a link:

[[Scratch Wiki]] vs. {{link style|Scratch Wiki|color:gray}}

Scratch Wiki vs. Scratch Wiki

Alternate link text style

To change the style of a link with custom link text:

[[Scratch Wiki|the Wiki]] vs. {{link style|Scratch Wiki|color:gray|text=the Wiki}}

the Wiki vs. the Wiki

Note that you must specify text= to have alternate link text.

Using an external link

To change whether it is an internal link or an external link:

[https://scratch.mit.edu/ Scratch] vs. {{link style|https://scratch.mit.edu/|color:gray|text=Scratch|ext=t}}

Scratch vs. Scratch

Note that you must specify ext=something to have an external link. (The value need not be "t" or "something", as long as it's not empty)

Red link style

Note Note: This syntax only styles nonexistent intra-wiki links.

To change the style of a link to a nonexistent page:

[[No page here]] vs. {{link style|No page here|color:gray|color:magenta}}

No page here vs. No page here

Note that the style in the third parameter is applied, since the page does not exist.

Alternate red link text style

Note Note: This syntax only styles nonexistent intra-wiki links.

To change the style of a link to a nonexistent page with custom link text:

[[No page here|Nope]] vs. {{link style|No page here|color:gray|color:magenta|text=Nope}}

Nope vs. Nope

Here, four parameters are put into use. The first parameter is the page itself, the second is the style for the link, the third is the style if the page doesn't exist, and text is the alternate text for the link.

Extra HTML attributes

To add a title attribute to a link:

[[Scratch Wiki]] vs. {{link attributes|Scratch Wiki|attribs=title="Hi, this is a demonstration of the HTML title attribute!"}} (hover)

Scratch Wiki vs. Scratch Wiki (hover)

Here, the optional attribute title is applied to the text.

All together now

To add a title attribute and change the style of a link to a nonexistent page with custom link text:

[[No page here|Nope]] vs. {{link attributes|No page here|color:gray|color:magenta|text=Nope|attribs=title="You're not finding a page here!"}}

Nope vs. Nope

And now to link to an external page:

[https://scratch.mit.edu/ Scratch] vs. {{link attributes|https://scratch.mit.edu/|color:gray|text=Scratch|attribs=title="hehe cool"|ext=t}}

Scratch vs. Scratch


Here, in these two examples five parameters are put into use. The first parameter is the link target, the second is the style, text is the link text, ext is to specify it as an external link, and attribs is the extra HTML attributes for the link.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.