HTML | DOM Emphasized Object

The DOM Emphasized Object is used to represent the HTML <em> element. The Emphasized element is accessed by getElementById().
Syntax:

document.getElementById("ID");

Where “id” is the ID assigned to the “em” tag.

Example-1:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Emphasized Object</title>
</head>
  
<body>
    <center>
        <h2>DOM Emphasized Object</h2>
        
        <!--Text in Italics-->
        <p>Hello GeeksforGeeks</p>
        
        <!--Text in Emphasize-->
        <p><em id="GFG">Hello GeeksforGeeks</em></p>
        
        <button onclick="mygeeks()">
          Submit
        </button>
        
            <script>
                function mygeeks() {
                    var gfg = document.getElementById("GFG");
                    gfg.style.color = "red";
                    gfg.style.fontSize = "29px";
                }
            </script>
  </center>
</body>
  
</html>

chevron_right


Output:

Before Clicking On Button :

After Clicking On Button:

Example-2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Emphasized Object</title>
</head>
  
<body>
    <h2>DOM Variable Object</h2>
    
    <!--Text in Paragraph-->
    <p>Hello GeeksforGeeks</p>
    
    <button onclick="mygeeks()">
      Submit
    </button>
    
        <script>
            function mygeeks() {
                var gfg = document.createElement("em");
                var text = 
                document.createTextNode("Hello GeeksForGeeks");
                gfg.appendChild(text);
  
                document.body.appendChild(gfg);
            }
        </script>
</body>
  
</html>

chevron_right


Output:

Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by DOM Emphasized Object are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.