summaryrefslogtreecommitdiff
path: root/devdocs/html/element%2Fsub.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/html/element%2Fsub.html
new repository
Diffstat (limited to 'devdocs/html/element%2Fsub.html')
-rw-r--r--devdocs/html/element%2Fsub.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/devdocs/html/element%2Fsub.html b/devdocs/html/element%2Fsub.html
new file mode 100644
index 00000000..09dc74f1
--- /dev/null
+++ b/devdocs/html/element%2Fsub.html
@@ -0,0 +1,112 @@
+<header><h1>&lt;sub&gt;: The Subscript element</h1></header><div class="section-content"><p>The <code>&lt;sub&gt;</code> <a href="../index">HTML</a> element specifies inline text which should be displayed as subscript for solely typographical reasons. Subscripts are typically rendered with a lowered baseline using smaller text.</p></div>
+<h2 id="try_it">Try it</h2>
+<div class="section-content"><iframe class="interactive is-tabbed-shorter-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/sub.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe></div>
+<h2 id="attributes">Attributes</h2>
+<div class="section-content"><p>This element only includes the <a href="../global_attributes">global attributes</a>.</p></div>
+<h2 id="usage_notes">Usage notes</h2>
+<div class="section-content">
+<p>The <code>&lt;sub&gt;</code> element should be used only for typographical reasons—that is, to change the position of the text to comply with typographical conventions or standards, rather than solely for presentation or appearance purposes.</p> <p>For example, using <code>&lt;sub&gt;</code> to style the name of a company which uses altered baselines in their <a href="https://en.wikipedia.org/wiki/Wordmark" target="_blank">wordmark</a> would not be appropriate; instead, CSS should be used. For example, you could use the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align"><code>vertical-align</code></a> property with a declaration like <code>vertical-align: sub</code> or, to more precisely control the baseline shift, <code>vertical-align: -25%</code>.</p> <p>Appropriate use cases for <code>&lt;sub&gt;</code> include (but aren't necessarily limited to):</p> <ul> <li>Marking up footnote numbers. See <a href="#footnote_numbers">Footnote numbers</a> for an example.</li> <li>Marking up the subscript in mathematical variable numbers (although you may also consider using a <a href="https://developer.mozilla.org/en-US/docs/Web/MathML">MathML</a> formula for this). See <a href="#variable_subscripts">Variable subscripts</a>.</li> <li> Denoting the number of atoms of a given element within a chemical formula (such as every developer's best friend, C <sub>8</sub> H <sub>10</sub> N <sub>4</sub> O <sub>2</sub> , otherwise known as "caffeine"). See <a href="#chemical_formulas">Chemical formulas</a>. </li> </ul>
+</div>
+<h2 id="examples">Examples</h2>
+
+<h3 id="footnote_numbers">Footnote numbers</h3>
+<div class="section-content">
+<p>Traditional footnotes are denoted using numbers which are rendered in subscript. This is a common use case for <code>&lt;sub&gt;</code>:</p> <div class="code-example">
+<p class="example-header"><span class="language-name">html</span></p>
+<pre data-signature="mTljQa7lvApf0eis59NcyCtwMHPX/Cs6vWDX7xo89p0=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>
+ According to the computations by Nakamura, Johnson, and Mason<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span> this
+ will result in the complete annihilation of both particles.
+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+</pre>
+</div> <h4 id="result">Result</h4>
+<div class="code-example" id="sect1">
+
+<iframe class="sample-code-frame" title="Footnote numbers sample" id="frame_footnote_numbers" width="650" height="80" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/sub/runner.html?id=footnote_numbers" loading="lazy"></iframe>
+</div>
+</div>
+<h3 id="variable_subscripts">Variable subscripts</h3>
+<div class="section-content">
+<p>In mathematics, families of variables related to the same concept (such as distances along the same axis) are represented using the same variable name with a subscript following. For example:</p> <div class="code-example">
+<p class="example-header"><span class="language-name">html</span></p>
+<pre data-signature="9v18rU9x1ggtVHpn2xw8R6e83DxPWD85oGxBAWVvaFA=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>
+ The horizontal coordinates' positions along the X-axis are represented as
+ <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>var</span><span class="token punctuation">&gt;</span></span>x<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>var</span><span class="token punctuation">&gt;</span></span> … <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>var</span><span class="token punctuation">&gt;</span></span>x<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>n<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>var</span><span class="token punctuation">&gt;</span></span>.
+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+</pre>
+</div> <h4 id="result_2">Result</h4>
+<div class="code-example" id="sect2">
+
+<iframe class="sample-code-frame" title="Variable subscripts sample" id="frame_variable_subscripts" width="650" height="80" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/sub/runner.html?id=variable_subscripts" loading="lazy"></iframe>
+</div>
+</div>
+<h3 id="chemical_formulas">Chemical formulas</h3>
+<div class="section-content">
+<p>When writing a chemical formula, such as H<sub>2</sub>0, the number of atoms of a given element within the described molecule is represented using a subscripted number; in the case of water, the subscripted "2" indicates that there are two atoms of hydrogen in the molecule.</p> <p>Another example:</p> <div class="code-example">
+<p class="example-header"><span class="language-name">html</span></p>
+<pre data-signature="x1TvICWeU/i582STE7h/wzqPLNpRkNxupsR3dUQlTlI=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">&gt;</span></span>
+ Almost every developer's favorite molecule is
+ C<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span>H<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>10<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span>N<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span>O<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sub</span><span class="token punctuation">&gt;</span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>sub</span><span class="token punctuation">&gt;</span></span>, which is commonly known
+ as "caffeine."
+<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">&gt;</span></span>
+</pre>
+</div> <h4 id="result_3">Result</h4>
+<div class="code-example" id="sect3">
+
+<iframe class="sample-code-frame" title="Chemical formulas sample" id="frame_chemical_formulas" width="650" height="120" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/sub/runner.html?id=chemical_formulas" loading="lazy"></iframe>
+</div>
+</div>
+<h2 id="technical_summary">Technical summary</h2>
+<div class="section-content"><figure class="table-container"><div class="_table"><table class="properties"> <tbody> <tr> <th scope="row"><a href="../content_categories">Content categories</a></th> <td> <a href="../content_categories#flow_content">Flow content</a>, <a href="../content_categories#phrasing_content">phrasing content</a>, palpable content. </td> </tr> <tr> <th scope="row">Permitted content</th> <td>
+<a href="../content_categories#phrasing_content">Phrasing content</a>.</td> </tr> <tr> <th scope="row">Tag omission</th> <td>None, both the starting and ending tag are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Any element that accepts <a href="../content_categories#phrasing_content">phrasing content</a>. </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td><code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/structural_roles#structural_roles_with_html_equivalents">subscript</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>Any</td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement"><code>HTMLElement</code></a></td> </tr> </tbody> </table></div></figure></div>
+<h2 id="specifications">Specifications</h2>
+<div class="_table"><table class="standard-table">
+<thead><tr><th scope="col">Specification</th></tr></thead>
+<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-sub-and-sup-elements">HTML Standard <br><small># the-sub-and-sup-elements</small></a></td></tr></tbody>
+</table></div>
+<h2 id="browser_compatibility">Browser compatibility</h2>
+<div class="_table"><table>
+<thead>
+<tr id="bct-browser-type">
+<th></th>
+<th colspan="6">Desktop</th>
+<th colspan="6">Mobile</th>
+</tr>
+<tr id="bct-browsers">
+<th></th>
+<th>Chrome</th>
+<th>Edge</th>
+<th>Firefox</th>
+<th>Internet Explorer</th>
+<th>Opera</th>
+<th>Safari</th>
+<th>WebView Android</th>
+<th>Chrome Android</th>
+<th>Firefox for Android</th>
+<th>Opera Android</th>
+<th>Safari on IOS</th>
+<th>Samsung Internet</th>
+</tr>
+</thead>
+<tbody><tr>
+<th><code>sub</code></th>
+<td class="bc-supports-yes">1</td>
+<td class="bc-supports-yes">12</td>
+<td class="bc-supports-yes">1</td>
+<td class="bc-supports-yes">Yes</td>
+<td class="bc-supports-yes">15</td>
+<td class="bc-supports-yes">≤4</td>
+<td class="bc-supports-yes">4.4</td>
+<td class="bc-supports-yes">18</td>
+<td class="bc-supports-yes">4</td>
+<td class="bc-supports-yes">14</td>
+<td class="bc-supports-yes">≤3.2</td>
+<td class="bc-supports-yes">1.0</td>
+</tr></tbody>
+</table></div>
+<h2 id="see_also">See also</h2>
+<div class="section-content"><ul> <li>The <a href="sup"><code>&lt;sup&gt;</code></a> HTML element that produces superscript. Note that you cannot use <code>sup</code> and <code>sub</code> both at the same time: you need to use <a href="https://developer.mozilla.org/en-US/docs/Web/MathML">MathML</a> to produce both a superscript directly above a subscript next to the chemical symbol of an element, representing its atomic number and its nuclear number.</li> <li>The <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub"><code>&lt;msub&gt;</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup"><code>&lt;msup&gt;</code></a>, and <a href="https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msubsup"><code>&lt;msubsup&gt;</code></a> MathML elements.</li> <li>The CSS <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align"><code>vertical-align</code></a> property.</li> </ul></div><div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2005&ndash;2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
+ <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub</a>
+ </p>
+</div>