Skip to content
Related Articles

Related Articles

Improve Article

HTML DOM Aside Object

  • Last Updated : 14 Jan, 2019

The DOM Aside Object is used to represent the HTML <Aside> element. The Aside element is accessed by getElementById().The aside Element is new in html 5.
Syntax:

document.getElementById("ID");

where “id” is the ID assigned to the aside tag.
Example-1:




<!DOCTYPE html>
<html>
  
<head>
    <title>aside tag</title>
    <style>
        .gfg {
            font-size: 30px;
        }
          
        aside {
            font-size: 40px;
            color: #090;
            font-weight: bold;
        }
          
        p {
            font-size: 20px;
            margin: 20px 0;
        }
    </style>
</head>
  
<body>
    //Assign ID to the aside tag.
    <aside id="GFG">
        <h1>GeeksforGeeks</h1>
        <p>A computer science portal for geeks</p>
    </aside>
      
    <h2 style="font-size:35px;">DOM Aside object</h2>
    <button onclick="myGeeks()">Submit</buttom>
        <script>
            function myGeeks() {
                var w = document.getElementById("GFG");
                w.style.color = "red";
            }
        </script>
</body>
  
</html>                

Output:
Before Clicking on Button:

After Clicking on Button:

Example-2: Aside Object can be created by using the document.createElement Method.




<!DOCTYPE html>
<html>
  
<head>
    <title>aside tag</title>
    <style>
        .gfg {
            font-size: 30px;
        }
          
        p {
            font-size: 20px;
            margin: 20px 0;
        }
    </style>
</head>
  
<body>
    <center>
        <h2 style = "font-size:35px;">DOM Aside object</h2>
        <button onclick="myGeeks()">Submit</buttom>
            <script>
                function myGeeks() {
                    var w = document.createElement("ASIDE");
                    w.setAttribute("id", "GFG");
                    document.body.appendChild(w);
  
                    var heading = document.createElement("H3");
                    var text1 = 
                    document.createTextNode("GeeksForGeeks");
  
                    heading.appendChild(text1);
                    document.getElementById("GFG"
                    ).appendChild(heading);
  
                    var para = document.createElement("P");
                    var text2 = document.createTextNode(
                    "A Computer Science Portal for Geeks.");
                    
                    para.appendChild(text2);
                    document.getElementById("GFG"
                    ).appendChild(para);
                }
            </script>
</body>
  
</html>  

Output:
Before Clicking on Button:

After Clicking on Button:

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

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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :