+
+```
+
+```js
+const container = document.getElementById('container');
+const todolist = document.querySelector('.todo-list');
+
+// Create a new element
+const newToDo = document.createElement('li');
+newToDo.setAttribute("class", "todo-item")
+newToDo.textContent = 'Buy fruits.';
+
+// Append the new element as the last child
+todolist.appendChild(newToDo);
+
+// Create another new element
+const title = document.createElement('h2');
+newToDo.textContent = 'My tasks';
+
+// Insert the title before the list
+container.insertBefore(title, todolist);
+
+// Create yet another new element
+const lastElement = document.createElement('div');
+lastElement.textContent = 'Last Element';
+
+// Append yet another element as the last child
+container.append(lastElement);
+
+// Create and prepend a new element
+const firstElement = document.createElement('div');
+firstElement.textContent = 'First Element';
+
+// Prepend the new element as the first child
+container.prepend(firstElement);
+```
+
+### 2.5. Removing Elements
+
+- `removeChild()` method removes a specified child node from the parent node. The removed child node is returned.
+
+- `remove()` method removes the element from the DOM.
+
+```html
+
+
Child Element
+
Another Child Element
+
+```
+
+```js
+// Get the container element
+const container = document.getElementById('container');
+
+// Get the child element to be removed
+const childElement = document.getElementById('childElement');
+
+// Remove the child element using removeChild
+container.removeChild(childElement);
+
+// Get another child element to be removed
+const anotherChildElement = document.getElementById('anotherChildElement');
+
+// Remove the element using remove()
+anotherChildElement.remove();
+
+```
+### 2.6. Modifying Styles
+
+- The `style` property allows to set or get inline styles for an element. This directly modifies the style attribute of the element in the DOM.
+
+```html
+
Hello world!
+```
+
+```js
+// Get the element
+const element = document.getElementById('myElement');
+
+// Change the background color and font size using the style property
+element.style.backgroundColor = 'blue';
+element.style.fontSize = '20px';
+```
+
+- The `classList` property provides methods to add, remove, and toggle CSS classes on an element. This is a more flexible way to manage an element's classes compared to directly setting the `class` attribute.
+
+```js
+// Get the element
+const element = document.getElementById('myElement');
+
+// Add a new class to the element
+element.classList.add('newClass');
+
+// Remove an existing class from the element
+element.classList.remove('initialClass');
+
+// Toggle a class on the element (add it if it doesn't exist, remove it if it does)
+element.classList.toggle('toggledClass');
+```
+
+### 2.7. Event Handling
+
+- The `addEventListener()` method attaches an event handler to an element. It allows multiple event listeners to be added to a single element for the same event type.
+
+```html
+
Click Me
+```
+
+```js
+// Define the event handler function
+function handleClick() {
+ alert('Button was clicked!');
+}
+
+// Get the button element
+const button = document.getElementById('myButton');
+
+// Add a click event listener
+button.addEventListener('click', handleClick);
+```
+
+- The `removeEventListener()` method removes an event handler that was added with `addEventListener()`.
+
+```js
+button.removeEventListener('click', handleClick);
+```
+
+## Conclusion
+
+Mastering DOM manipulation is crucial for creating dynamic, interactive web pages. The ability to access, modify, and interact with the DOM using JavaScript allows developers to build responsive and engaging user experiences.
+
+- **Understanding the DOM**: By understanding the structure and representation of a web document through the DOM, developers can effectively interact with and manipulate web pages.
+
+- **Accessing Elements**: Methods like `getElementById()`, `getElementsByClassName()`, `getElementsByTagName()`, `querySelector()`, and `querySelectorAll()` enable precise selection of elements within the DOM, facilitating targeted manipulations.
+
+- **Modifying Content and Attributes**: Techniques such as using `innerHTML`, `textContent`, and `innerText` for content modification, alongside `getAttribute()`, `setAttribute()`, and `removeAttribute()` for attribute management, provide powerful ways to dynamically change the document's content and properties.
+
+- **Creating and Inserting Elements**: Methods like `createElement()`, `appendChild()`, `insertBefore()`, `append()`, and `prepend()` allow developers to construct and integrate new elements into the DOM, enabling the dynamic construction of web pages.
+
+- **Removing Elements**: Using `removeChild()` and `remove()` methods facilitates the removal of elements from the DOM, which is essential for maintaining clean and efficient document structures.
+
+- **Modifying Styles**: Direct manipulation of inline styles via the `style` property and managing classes with classList methods (`add()`, `remove()`, `toggle()`) offer flexible control over the appearance and styling of elements.
+
+- **Event Handling**: The ability to attach and remove event listeners using `addEventListener()` and `removeEventListener()` empowers developers to create interactive elements that respond to user actions, enhancing the user experience.
+
+By leveraging these DOM manipulation techniques, developers can create rich, interactive web applications that provide a seamless and dynamic user experience. Understanding and utilizing these tools effectively is key to modern web development.