w3resource

HTML5: How to define a variable?

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html><!-- Define document type as HTML -->
<html><!-- Begin HTML document -->
<head><!-- Start of document header -->
<meta charset="utf-8"><!-- Define character encoding -->
<title>How to define a variable</title><!-- Title of the HTML page -->
</head><!-- End of document header -->
<body><!-- Start of document body -->
<p>This is an example of <var>HTML var tag.</var></p><!-- Paragraph containing a variable definition -->
</body><!-- End of document body -->
</html><!-- End of HTML document -->

Explanation:

  • The HTML code defines a paragraph (<p>) element containing text.
  • Within the paragraph, the <var> tag is used to indicate a variable or placeholder.
  • The text "HTML var tag." is enclosed within the <var> tags, indicating that it represents a variable or placeholder in the context of the sentence.

Live Demo:

See the Pen var-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes Yes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.