< Template:Link attributes

m (Kenny2scratch moved page Template:Link style/doc to Template:Link attributes/doc: more general title for more features)
(added feature to documentation)
Line 2: Line 2:
 
{{note}}This template only styles intra-wiki links.
 
{{note}}This template only styles intra-wiki links.
 
==Usage==
 
==Usage==
{{t|link style}} applies [[Help:CSS|CSS]] style to an intra-wiki link. It accepts four parameters:
+
{{t|link style}} applies [[Help:CSS|CSS]] style to an intra-wiki link. It accepts five parameters:
 
*1 - the page being linked
 
*1 - the page being linked
 
*2 - the style of the link
 
*2 - the style of the link
 
*3 - the style of the link if the page being linked does not exist - optional
 
*3 - the style of the link if the page being linked does not exist - optional
 
*text - link text to show - optional
 
*text - link text to show - optional
 +
*attribs - extra HTML attributes to add
 
===Link style===
 
===Link style===
 
To change the style of a link:
 
To change the style of a link:
Line 32: Line 33:
 
[[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, all 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.<noinclude>[[Category:Template Documentations]]</noinclude>
+
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===
 +
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>
 +
 
 +
[[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.
 +
===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:
 +
<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>
 +
 
 +
[[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!"}}
 +
 
 +
Here, all five parameters are put into use. The first parameter is the page, the second is the style, the third is the style for a redlink, <code>text</code> is the alternate text, and <code>attribs</code> is the extra HTML attributes for the link.
 +
<noinclude>[[Category:Template Documentations]]</noinclude>

Revision as of 08:07, 13 July 2017

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.

Note Note: This template only styles intra-wiki links.

Usage

{{link style}} applies CSS style to an intra-wiki link. It accepts five 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
  • text - link text to show - optional
  • attribs - extra HTML attributes to add

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.

Red link style

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

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 title attribute

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

Here, all five parameters are put into use. The first parameter is the page, the second is the style, the third is the style for a redlink, text is the alternate text, 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.