Topic on Project:Support desk

formatting internal vs. external wikilinks

7
Summary last edited by Nicole Sharp 14:18, 10 February 2018 6 years ago
.mw-body-content a { text-decoration: underline; }
.mw-body-content a:visited { text-decoration: underline; }

.mw-body-content a.external { text-decoration: none; }
.mw-body-content a.external:visited { text-decoration: none; }

.mw-body-content a.extiw { text-decoration: none; }
.mw-body-content a.extiw:visited { text-decoration: none; }
Nicole Sharp (talkcontribs)

Is there a way to use automatic formatting (e.g. with CSS) to differentiate between external and internal wikilinks? E.g., I would like internal wikilinks to be underlined, as opposed to external wikilinks showing as they normally do (without underlining), or to display them with different colors perhaps.

AhmadF.Cheema (talkcontribs)

You can try the following in your MediaWiki:Common.css:

.mw-body-content a {
    text-decoration: underline;
}
.mw-body-content a:visited {
    text-decoration: underline;
}

However, "internal links" apparently come up in many other places too, such as WikiEditor buttons, page revision links etc., so this way, those will also get underlined.

An easier alternative would be to leave internal links as default and underline the external links.

.mw-body-content a.external {
    text-decoration: underline;
}
.mw-body-content a.external:visited {
    text-decoration: underline;
}
Nicole Sharp (talkcontribs)

That doesn't appear to affect wikilinks ([[]]); just hyperlinks ([]). I would specifically like to be able to differentiate between a wikilink to a page on the same wiki, versus a page on another wiki (such as Wikipedia, via interwiki). And different colors might be more effective than underlining maybe, to visually differentiate the target domains of links.

Nicole Sharp (talkcontribs)

I am guessing this is something that might need a new MediaWiki extension to do perhaps. Otherwise I suppose I could manually add (e.g.) <span class="local">[[Wikipedia]]</span> in front of links to modify them based on where they are linking to, but that is a lot of extra work. It would be nice if there was a way for the software to recognize the interwiki table, and then add CSS to interwiki links, or non-interwiki links.

AhmadF.Cheema (talkcontribs)

For external interwiki links, instead of a, use a.extiw and instead of a:visited, use a.extiw:visited.

Nicole Sharp (talkcontribs)
.mw-body-content a.extiw { text-decoration: underline; color: fuchsia; }
.mw-body-content a.extiw:visited { text-decoration: underline; color: purple; }

Awesome!! Yes, that worked. Thank you very much! And I see your point that if I tried that on internal wikilinks, all of the links on the lefthand menu would be underlined, and not just the ones inside the wikipages. Is there a way to specify just the internal wikilinks inside wikipages though? Otherwise I think I will just use different colors probably.

Nicole Sharp (talkcontribs)

I got it! .mw-body-content already restricts to just within wikipages, so that menu links are not affected.

.mw-body-content a { text-decoration: underline; }
.mw-body-content a:visited { text-decoration: underline; }

.mw-body-content a.external { text-decoration: none; }
.mw-body-content a.external:visited { text-decoration: none; }

.mw-body-content a.extiw { text-decoration: none; }
.mw-body-content a.extiw:visited { text-decoration: none; }