Manipulating HTML Elements
Welcome to the "Manipulating HTML Elements" Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
Already have an account? Sign In »
Welcome to the Manipulating HTML Elements Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
The following exam objective is covered in this lab:
4.4 Complete and debug code that locates, modifies, and adds HTML elements and attributes
It will take approximately 15 minutes to complete this lab.
Exercise 1 - Creating HTML Elements Using DOM Methods
In a web application, you may come across many situations where you find the need to create your own page elements. The customized elements can be paragraphs, headers, list items, etc. Generally, a new customized element includes an element node and a text node. For example, a new paragraph element will have a supporting text node associated with it.
You can create the element and text nodes using the HTML DOM methods. The procedure you need to follow to create new elements is as follows:
Create the new element node using the method document.createElement(element). Create the new text node using the method document.createTextNode(text). Append the text node to the element node using the method node.appendChild(node). Once the element is created, you can set its attributes using the method element.setAttribute(attribute, value).
In this exercise, you will develop a To Do List page and learn to create new elements and set its attributes. The first task will be to create a new folder named ToDoList on PLABWIN10 desktop, add the folder to Visual Studio Code workspace, and save the workspace with the name ToDoList. You will create a new HTML page named ToDoList.html in the ToDoList workspace.
After completing this exercise, you will be able to:
- Create HTML elements using the DOM methods
IT & Cybersecurity certification hands on practice labs and practice exams for certifications and skill development.
See the full benefits of our immersive learning experience with interactive courses and guided career paths.