Jump to content

Help talk:HTML in wikitext

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Andrybak (talk | contribs) at 22:27, 21 July 2024 (wbr: mark unsigned Special:Diff/569939254 (using Unsigned helper)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Merge from WP:Span tags

Seems there was consensus at Wikipedia:Miscellany for deletion/Wikipedia:Span tags to merge that content into here if someone wants to take up the task. -- œ 12:21, 22 March 2010 (UTC)[reply]

wbr

<wbr> will be allowed with MediaWiki 1.22/wmf13.[1] --  Gadget850 talk 05:47, 17 August 2013 (UTC)[reply]


<wbr> is a word break opportunity; that is, it specifies where it would be OK to add a line-break where a word is too long, or it is perceived that the browser will break a line at the wrong place.

Markup Renders as
Now is the time to become a power editor, by learning HyperText Markup Language

Now is the time to become a power editor, by learning HyperText Markup Language

Now is the time to become a power editor, by learning Hyper<wbr>Text Markup Language

Now is the time to become a power editor, by learning HyperText Markup Language

As you narrow your browser window, you will see that the second example wraps between Hyper and Text. — Preceding unsigned comment added by Gadget850 (talkcontribs) 02:01, 24 August 2013 (UTC)[reply]

New markup

I just noticed that Sanitizer.php now has some additional markup whitelisted.

--  Gadget850 talk 21:05, 9 July 2014 (UTC)[reply]

I used <q>...</q> just over a week ago, don't recall where except that it was a discussion page. It definitely worked - I didn't actually realise that it wasn't supposed to. --Redrose64 (talk) 22:25, 9 July 2014 (UTC)[reply]
<q> and <bdo> were not supported when I made major updates to this help page in May/June 2013. Took a bit of digging, but found it was added in MediaWiki 1.22/wmf9 on July 11, 2013. I have not found the changes for the table markup yet. --  Gadget850 talk 01:41, 10 July 2014 (UTC)[reply]
<thead>, <tfoot> and <tbody> are either not whitelisted, or seem to be caught by something not recognizing them; they are converted to &lt;theader&gt;. The parser generates <tbody> for any wikitable, but that is also pretty useless. It should ideally generate <theader> for the top header row. -- [[User:Edokter]] {{talk}} 10:10, 10 July 2014 (UTC)[reply]
These tags also appear to be whitelisted but don't work:
  • <colgroup>
  • <col>
  • <rtc> (what is this?)
--  Gadget850 talk 10:22, 10 July 2014 (UTC)[reply]
<rtc> seems to be a deprecated Ruby tag. -- [[User:Edokter]] {{talk}} 11:22, 10 July 2014 (UTC)[reply]
Finally found it— it wasn't in my usual HTML references.[2][3]; doesn't look deprecated.  Gadget850 talk 12:16, 10 July 2014 (UTC)[reply]
HTML 5 seems to be still quite fluid (it dropped back from Candidate Recommendation to Working Draft on 17 June 2014 - less than four weeks ago). Some of the changes made at the previous revision concern the Text-level semantics subsection: the Candidate Recommendation 17 December 2012 does not have <rtc>...</rtc>, whereas the next version, the W3C Candidate Recommendation 29 April 2014 includes it at 4.5.24 The rtc element. --Redrose64 (talk) 13:30, 10 July 2014 (UTC)[reply]
Regardless, there appear to be several tags that are whitelisted, but don't parse. Anyone know the reason?
<thead>, <tfoot>, <tbody>, <colgroup> and <col> are not listed in the section starting with '$htmlpairsStatic'. But <rtc> is listed there.
 Gadget850 talk 15:19, 10 July 2014 (UTC)[reply]

table border

I don't see that border on <table> is obsolete.[4] But I do get warnings and errors with the W3C validator:

  • border="": The border attribute on the table element is presentational markup. Consider using CSS instead.
  • border="1": The border attribute on the table element is presentational markup. Consider using CSS instead.
  • border="10": The border attribute on the table element is obsolete. Use CSS instead.

But http://www.w3.org/TR/html-markup/table.html shows that border "Indicates that its table element is not being used for layout purposes."

--  Gadget850 talk 14:23, 4 August 2014 (UTC)[reply]

@Gadget850: See just after this entry, the paragraph beginning "The border attribute on the table element". --Redrose64 (talk) 15:37, 4 August 2014 (UTC)[reply]

Nowiki

What is the corresponding HTML tag for Wikipedia's "<nowiki>" Qwertyxp2000 (talk) 05:42, 5 June 2015 (UTC)[reply]

@Qwertyxp2000: I'm not sure I know what you mean. What are you trying to do? --Redrose64 (talk) 10:42, 5 June 2015 (UTC)[reply]
Okay, what I am saying is how to do Wikipedia's "nowiki" thing on an HTML document? Qwertyxp2000 (talk) 10:48, 5 June 2015 (UTC)[reply]
HTML isn't Wikitext, so the term "nowiki" is meaningless. What specifically are you trying to achieve? --Redrose64 (talk) 11:02, 5 June 2015 (UTC)[reply]
To stop HTML tag parsing in HTML documents is a little complex, and can involve the <pre> tag. See http://stackoverflow.com/questions/11673978/is-there-a-html-css-way-to-display-html-tags-without-parsing for an example. Obviously non-HTML wiki markup wouldn't be parsed in a HTML document, but might not be displayed if in the xml format (e.g. <nowiki> probably wouldn't be displayed) so you'd have to use a similar technique. --Jules (Mrjulesd) 11:21, 5 June 2015 (UTC)[reply]
The current HTML5 spec says
Use pre and code instead, and escape "<" and "&" characters as "&lt;" and "&amp;" respectively.
The <XMP>...</XMP> element was last described in the HTML 3.2 spec, but a more complete explanation of its deprecation was given in the HTML 2.0 spec, paragraph beginning "Since CDATA declared content ...". --Redrose64 (talk) 11:54, 5 June 2015 (UTC)[reply]

General anchors?

The section Help:HTML in wikitext#Unsupported elements clarifies that <a> is not supported; well and good. However, it also claims that "<a> is for making links", and refers only to the [[]] and [] features, and to Help:Wiki_markup#Links_and_URLs for more details. That claim is not the whole truth.

In HTML, the <a name="..."> may be employed for creating anchors. I'd like to be able to refer and link directly to theorems in mathematical texts (e.g. in wikibooks); but I have found no way to create an anchor unrelated to a (sub)section head in the wiki markup. Is there any supported way to do this, either by wiki or HTML features? JoergenB (talk) 20:23, 23 August 2015 (UTC)[reply]

@JoergenB: Since HTML 4.0, every element that is permissible in the body of a HTML document is allowed to have an id= attribute. This may be used as the anchor for a link, see HTML 4.10 section 7.5.2 and HTML 5 section 3.2.5.1. Essentially, where in HTML 3.2 (and earlier) you would write <a name="Foobar">Some text</a>, in HTML 4 (and later) the construct <span id="Foobar">Some text</span> may be used for the same purpose. See also the {{anchor}} template. --Redrose64 (talk) 20:33, 23 August 2015 (UTC)[reply]
Thanks! JoergenB (talk) 21:19, 23 August 2015 (UTC)[reply]

Extended Tags:Graph

Not sure how to fix it, but it is linked to the wrong page. It should go here https://www.mediawiki.org/wiki/Extension:Graph 199.34.4.20 (talk) 01:44, 24 October 2015 (UTC)[reply]

It's in Template:Xtag/doc. But since Help:Graph already has a link to mw:Extension:Graph, why is it wrong? --Redrose64 (talk) 07:13, 24 October 2015 (UTC)[reply]

Cite tag does not render italics

On my browser at least, the cite tag does not behave as described in the documentation. This page says "contains the title of a work and by default is formatted in italics", but the example given just below does not render italics. Does something need to be fixed? – Jonesey95 (talk) 17:26, 1 December 2016 (UTC)[reply]

No italics for me either (Chrome 54.0.2840.99 m on Windows 10 Home). EEng 19:35, 1 December 2016 (UTC)[reply]
I looked at the source code using Chrome's "inspect" function, and it appears that a style rule in the vector skin applies font-style: inherit; to the cite tag. I wonder why... — Eru·tuon 20:47, 1 December 2016 (UTC)[reply]
The actual rule is
cite, dfn {
    font-style: inherit;
}
and it's the very first one in MediaWiki:Common.css, so it's not specific to Vector skin or to any particular browser. It's been present in that form since this edit by Edokter (talk · contribs) at 09:52, 12 September 2015. The relevant discussion is MediaWiki talk:Common.css/Archive 17#The cite element needs to not auto-italicize any longer. --Redrose64 (talk) 22:06, 1 December 2016 (UTC)[reply]
In which case, it looks as if the documentation needs fixing. --David Biddulph (talk) 22:14, 1 December 2016 (UTC)[reply]
That is helpful. I have removed the bit about italics. The documentation still doesn't really explain what the cite tag is for or why one would want to use it. That would be an improvement. I read the linked discussion, which was confusing (to me). – Jonesey95 (talk) 22:31, 1 December 2016 (UTC)[reply]
Yes, why is <cite> even being documented here? Shouldn't this page be restricted to stuff there's at least some reason for editors to use? EEng 23:35, 1 December 2016 (UTC)[reply]
It is used at least 1,700 times in article space. I've never seen a good explanation of what it is for. It is apparently sometimes used in the same way that {{anchor}} is used; see this VPT discussion. – Jonesey95 (talk) 00:42, 2 December 2016 (UTC)[reply]
That's because there was a page - can't remember which - that actually recommended the use of an empty <cite>...</cite> to create anchors. Whatever page that was, it was amended around 2010 (2-3 years either way) so that the recommendation isn't there any more, but there are still a lot of bad uses out there. It may have been inspired by the {{wikicite}} template, which was devised for enclosing non-templated refs and giving them anchors, but which was altered in October 2009. --Redrose64 (talk) 10:00, 2 December 2016 (UTC)[reply]
The <cite> tag is documented here because the page is intended to describe all HTML tags which are whitelisted, whether they are useful or not. The purpose of the tag has changed with the evolution of HTML; skipping the early definitions, HTML 4.01 recommended that it contain "a citation or a reference to other sources"; HTML5 specifies that it "represents a reference to a creative work. It must include the title of the work or the name of the author ... or an URL reference". In between those there was a draft version of HTML which permitted its use only for the title of the referenced work. --Redrose64 (talk) 10:00, 2 December 2016 (UTC)[reply]
HTML5 suggests that browsers should apply the font-style: italic; declaration to <cite>...</cite> elements, so we can assume that that is what many browsers will do to these elements where the styling is not overridden locally (as it is here). References generated by the various Citation Style 1 and Citation Style 2 templates nowadays enclose the whole ref (except for the COinS metadata) in a <cite>...</cite> element, which is why we've overridden the italicisation by default: we don't want the whole ref to be italicised, just the title of the work or the name of the periodical. --Redrose64 (talk) 10:00, 2 December 2016 (UTC)[reply]

<br> vs. <br /> vs. </br>. (One concept inserted in the middle of another doesn't help.)

These sentences must confuse many readers.
"<br> or <br /> inserts a line break. Both versions of the break are supported by HTML5. </br> is invalid. Using <br> without the / breaks syntax highlighting, so should be avoided."

The last sentence should follow the first two. This will be more easily understood.
"<br> or <br /> inserts a line break. Both versions of the break are supported by HTML5. Using <br> without the / breaks syntax highlighting, so should be avoided. Use <br>. </br> is invalid. Do not use it." ... PeterEasthope (talk) 15:17, 4 April 2020 (UTC)[reply]

Good call. Changed. – Jonesey95 (talk) 17:05, 4 April 2020 (UTC)[reply]
Shouldn't that be "Use <br />" and not "Use <br>"? The second contradicts the preceding sentence. --Redrose64 🌹 (talk) 22:09, 4 April 2020 (UTC)[reply]
Sorry, I should have linked to a diff. I implemented the proposed change "The last sentence should follow the first two", not the proposed text, which was redundant and internally inconsistent. – Jonesey95 (talk) 03:55, 5 April 2020 (UTC)[reply]

Small tag

The reason not to use <small>...</small> is not because it renders differently in browsers (that's true of a lot of tags) but because it has a semantic meaning. See also MOS:SMALL. ―Justin (koavf)TCM 18:56, 29 June 2020 (UTC)[reply]

How to stop wikitext from interfering with HTML

I'm attempting to make a live clock with HTML here, but MediaWiki's wikitext keeps messing up the code by using {{}} etc. How can I stop this? (tbh if someone could also help me with the clock it would be much appreciated). — Yours, Berrely • TalkContribs 17:08, 4 July 2020 (UTC)[reply]

Berrely, you can't have full HTML pages in MediaWiki (both for security and WP:NOTWEBHOST reasons) - to achieve what you're trying to do, you can make a user script (where you add all the code between the <script> tags) then on the Wiki page just set it to <span id="txt"></span> Ed6767 talk! 23:22, 4 July 2020 (UTC)[reply]
Ed6767 I actually do know how to make a user script with the time, but what I want to do is put a clock on my user talk so people know what time it is for me, and I'm pretty sure you can't do that without constantly purging the page, and no such thing as an automatic purger exists. 86.18.238.106 (talk) 07:46, 5 July 2020 (UTC)[reply]
Berrely, you can try some userboxes that do the same thing? Ed6767 talk! 13:19, 5 July 2020 (UTC)[reply]
Also you can add a top right-sided clock by going to Special:Preferences#mw-prefsection-gadgets and clicking on "Add a clock to the personal toolbar that displays the current time in UTC and provides a link to purge the current page (documentation)". --Jules (Mrjulesd) 13:58, 5 July 2020 (UTC)[reply]
I am aware of that, but what I want to do is put a live clock on my user page, without having to repeatedly purge it. — Yours, Berrely • TalkContribs 15:47, 5 July 2020 (UTC)[reply]
All existing methods require a purge, other than the gadget mentioned by Mrjulesd. For performance reasons, Wikipedia pages are not updated dynamically. --Redrose64 🌹 (talk) 08:41, 6 July 2020 (UTC)[reply]

Template:Tooltip, Template:Hover_title, and Template:Abbr

 – Pointer to relevant discussion elsewhere.

Please see: Wikipedia:Templates for discussion/Log/2020 December 3#Template:Hover title and Template:Tooltip

Summary:

  • {{Abbr}} (a wrapper for <abbr>...</abbr>) has long been abused for non-abbreviation markup (against the HTML specs).
  • We had a template, {{Tooltip}}, with <span>...</span> for non-abbreviation use, but it was "merged" (not really) and redirected to {{Abbr}}.
  • The redir was then deprecated (for the reason mentioned above), but the community ignored the deprecation.
  • In the interim, {{Hover title}} was created to do the same thing, but with backwards parameters (and some additional features).
  • Both the {{Tooltip}} then-redirect and {{Hover title}} template have been transcluded in tens of thousands of articles, mainly via infoboxes and other templates.
  • I created a new {{Tooltip}} template, with all the features of {{Hover title}} but preserving the {{Abbr}} parameter order (to not break deployed translcusions).
  • The TfM linked above would merge away {{Hover title}}, but it's going to require flipping the |1= and |2= parameters of its extant instances.
  • Oh, and the documentation would need updating after merger, of course.

 — SMcCandlish ¢ 😼  00:25, 4 December 2020 (UTC)[reply]

<bdi> tag

In viewing §§ bdi, it does not appear to do anything in the example given. The text describes <bdi> in that it isolates the content from the surrounding text-direction settings, but there are no text-direction settings shown for the example to demonstrate. — CJDOS, Sheridan, OR (talk) 22:46, 14 August 2021 (UTC)[reply]

Line breaks. br variants

Help:HTML in wikitext#Basic has a section on <br> and variants.

Please see Help talk:Line-break handling#Let us ignore syntax highlighters that do not accept <br>

It is a detailed discussion with participation from editors, developers, admins, etc.. Most people in that thread want <br> used, not <br />.

See also: KISS principle.

See also MOS:MARKUP: "Other things being equal, keep markup simple. This makes wikitext easier to understand and edit, and the results seen by the reader more predictable. Use HTML and CSS markup sparingly." --Timeshifter (talk) 08:49, 11 February 2023 (UTC)[reply]

HTML

</button>

Does this create a button according to HTML? Lindo Kabini (talk) 10:32, 7 January 2024 (UTC)[reply]

@Lindo Kabini: No, because it's an end tag, and those do nothing apart from terminating an open element. --Redrose64 🌹 (talk) 17:43, 7 January 2024 (UTC)[reply]
@Redrose64 as for a kid who just learned a little of Python and moved to C++ to learn. All is just confusing 🤯
Is it like this?
<button>message</button> Lindo Kabini (talk) 07:11, 8 January 2024 (UTC)[reply]
@Lindo Kabini: Looks correct. You can learn and test HTML and other things at w3schools, as well as other websites. Try HTML <button> Tag. Jroberson108 (talk) 12:26, 8 January 2024 (UTC)[reply]
is w3schools here on Wikipedia? But you know what, am still learning C++ and HTML is not the ideal language for me Lindo Kabini (talk) 12:30, 8 January 2024 (UTC)[reply]
@Jroberson108 Lindo Kabini (talk) 12:31, 8 January 2024 (UTC)[reply]
@Lindo Kabini: It isn't Wikipedia, just a nice site to learn HTML, if that is what you want to learn. Jroberson108 (talk) 12:39, 8 January 2024 (UTC)[reply]
@Lindo Kabini: It covers C++ too. Like I said, "and other things". Jroberson108 (talk) 12:42, 8 January 2024 (UTC)[reply]
I already learn it at a certain site at YouTube and also here on Wikibooks so do not stress Lindo Kabini (talk) 12:46, 8 January 2024 (UTC)[reply]
@Jroberson108 Lindo Kabini (talk) 12:46, 8 January 2024 (UTC)[reply]
@Lindo Kabini: Please note that this is the talk page for discussing improvements to the page Help:HTML in wikitext, it is not a help desk for how to write HTML. In particular, HTML forms (including the button element) may not be used in Wikipedia, which is why it is not mentioned at Help:HTML in wikitext. --Redrose64 🌹 (talk) 19:47, 8 January 2024 (UTC)[reply]
oh, okay no problem honestly I enjoy using this. ☺️☺️ Lindo Kabini (talk) 06:02, 9 January 2024 (UTC)[reply]