HTML DOM Underline Object


The HTML DOM Underline Object in HTML represents the <u> element.

Creating a <u> element

var uObject = document.createElement(“U”)

Let us see an example of Underline element −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Underline</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
   <form>
      <fieldset>
         <legend>HTML-DOM-Underline</legend>
         <h2 ><u id="Underline">Warning: </u>This is a Demo Example</h2>
         <input type="button" value="Show" onclick="getBetterDisp()">
      </fieldset>
   </form>
<script>
   var uObject = document.getElementById("Underline");
   function getBetterDisp() {
      uObject.style.backgroundColor = '#DC3545';
      uObject.style.color = '#FFF';
   }
</script>
</body>
</html>

Output

Before clicking show button −

After clicking show button −

Updated on: 30-Oct-2019

121 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements