HTML | DOM Cite Object

The DOM Cite Object is used to represent HTML <Cite> element. The Cite element is accessed by getElementById().

Syntax

document.getElementById("id");

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

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM cite Object</title>
    <style>
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
              /wp-content/uploads/geeksforgeeks-25.png" 
         alt="gfg">
  
    <!-- cite id-->
    <p><cite id="GFG">GeeksforGeeks Image</cite></p>
  
    <button onclick="Geeks()">Submit</button>
  
    <script>
        function Geeks() {
            var w = document.getElementById("GFG");
            w.style.color = "coral";
            w.style.fontWeight = "bold";
        }
    </script>
</body>
  
</html>             

chevron_right


Output:

Before Clicking on Button:

After Clicking On Button:

Example-2: Cite Object can be created by using the document.createElement method.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>DOM cite Object</title>
    <style>
        body {
            text-align: center;
        }
    </style>
</head>
  
<body>
    <h2>DOM Cite Object</h2>
    
    <button onclick="Geeks()">
      Submit
    </button>
    
              /wp-content/uploads/geeksforgeeks-25.png" 
         alt="gfg">
    
    <script>
        function Geeks() {
            var cite = document.createElement("CITE");
            
            var text = 
            document.createTextNode("GeeksforGeeks Image");
            
            cite.appendChild(text);
            document.body.appendChild(cite);
        }
    </script>
</body>
  
</html>                    

chevron_right


Output
Before Clicking on Button:

Afte Clicking on Button:

Supported Browsers: The browser supported by DOM Cite 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.