Declare variable var in HTML CSS

The <var> element in HTML defines a text as a variable and can be used to define variables of a mathematical expression or variables of a piece of code. The text enclosed in the <var> element is typically displayed in italics. 


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. Nov 1, 2022

Tag omission: None, both the starting and end...

Permitted parents: Any element that accepts p...

Content categories: Flow content, phrasing co...

Acceptable content: Phrasing content.


Note: The <var> element Html supports all global attributes and event attributes.


Example

Define some text as variables in a document:


<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where <var>b</var> is the base, and <var>h</var> is the vertical height.</p>



Output:

The var element

The area of a triangle is: 1/2 x b x h, where b is the base, and h is the vertical height.



Default var CSS Settings

Most browsers will display the <var> element with the following default values:

Example

var {
  font-style: italic;
}

Comments :

Post a Comment