Home > Article > Web Front-end > How can we use tag for variable formatting in HTML?
We use the tag to define variables in programming or mathematical expressions. It is also used to format text in documents. Content within this tag is usually shown in italics.
<var>Variable…</var>
The following is an example of performing variable formatting using the tag in HTML -
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <p> <var>a</var> = float(input('Enter a value: ')) <br> <var>b </var>= float(input('Enter b value: ')) <br> <var>c </var>= float(input('Enter c value: ')) <br> # calculate the semi-perimeter <br> <var>s </var>= (<var>a</var> +<var> b</var> +<var> c</var>) / 2 <br> # calculate the area <br> area = (<var>s</var>*(<var>s</var>-<var>a</var>)*(<var>s</var>-<var>b</var>)*(<var>s</var>-<var>c</var>)) ** 0.5 <br> print('The area of the triangle is %0.2<var>f</var>' %area) </p> </body> </html>The Chinese translation of
You can try running the following code to use the tag in HTML for variable formatting -
<!DOCTYPE html> <html> <head> <title>HTML var Tag</title> </head> <body> <p>The equations: <var>2x</var> - <var>3z </var> = <var>5y</var> + 2 and <var>2x</var> + <var>5z</var> = <var>2y</var> + 7 </p> </body> </html>
We can override font styles using style sheets. The sample code is as follows:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> var{ font-family: cursive; } </style> </head> <body> <p> <var>a</var> = float(input('Enter a value: ')) <br> <var>b </var>= float(input('Enter b value: ')) <br> <var>c </var>= float(input('Enter c value: ')) <br> # calculate the semi-perimeter <br> <var>s </var>= (<var>a</var> +<var> b</var> +<var> c</var>) / 2 <br> # calculate the area <br> area = (<var>s</var>*(<var>s</var>-<var>a</var>)*(<var>s</var>-<var>b</var>)*(<var>s</var>-<var>c</var>)) ** 0.5 <br> print('The area of the triangle is %0.2<var>f</var>' %area) </p> </body> </html>
The above is the detailed content of How can we use tag for variable formatting in HTML?. For more information, please follow other related articles on the PHP Chinese website!