From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/html/element%2Fvar.html | 115 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 devdocs/html/element%2Fvar.html (limited to 'devdocs/html/element%2Fvar.html') diff --git a/devdocs/html/element%2Fvar.html b/devdocs/html/element%2Fvar.html new file mode 100644 index 00000000..c1c01bbd --- /dev/null +++ b/devdocs/html/element%2Fvar.html @@ -0,0 +1,115 @@ +

<var>: The Variable element

The <var> HTML element represents the name of a variable in a mathematical expression or a programming context. It's typically presented using an italicized version of the current typeface, although that behavior is browser-dependent.

+

Try it

+
+

Attributes

+

This element only includes the global attributes.

+

Usage notes

+ + +
+

Other elements that are used in contexts in which <var> is commonly used include:

If you encounter code that is mistakenly using <var> for style purposes rather than semantic purposes, you should either use a <span> with appropriate CSS or, an appropriate semantic element among the following:

+
+

Default style

+
+

Most browsers apply font-style to "italic" when rendering <var>. This can be overridden in CSS, like this:

+

css

+
var {
+  font-style: normal;
+}
+
+
+
+

Examples

+ +

Basic example

+
+

Here's a simple example, using <var> to denote variable names in a mathematical equation.

+

html

+
<p>A simple equation: <var>x</var> = <var>y</var> + 2</p>
+
+

Result

+
+ + +
+
+

Overriding the default style

+
+

Using CSS, you can override the default style for the <var> element. In this example, variable names are rendered using bold Courier if it's available, otherwise it falls back to the default monospace font.

CSS

+

css

+
var {
+  font:
+    bold 15px "Courier",
+    "Courier New",
+    monospace;
+}
+
+

HTML

+

html

+
<p>
+  The variables <var>minSpeed</var> and <var>maxSpeed</var> control the minimum
+  and maximum speed of the apparatus in revolutions per minute (RPM).
+</p>
+
+

This HTML uses <var> to enclose the names of two variables.

Result

+
+ + +
+
+

Technical summary

+
Content categories Flow content, phrasing content, palpable content.
Permitted content +Phrasing content.
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts phrasing content.
Implicit ARIA role No corresponding role
Permitted ARIA roles Any
DOM interface HTMLElement
+

Specifications

+
+ + +
Specification
HTML Standard
# the-var-element
+

Browser compatibility

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariWebView AndroidChrome AndroidFirefox for AndroidOpera AndroidSafari on IOSSamsung Internet
var1121Yes15≤44.418414≤3.21.0
+

+ © 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
+ https://developer.mozilla.org/en-US/docs/Web/HTML/Element/var +

+
-- cgit v1.2.3