VOOZH about

URL: https://www.geeksforgeeks.org/python/beautifulsoup-append-to-the-contents-of-tag/

⇱ BeautifulSoup - Append to the contents of tag - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BeautifulSoup - Append to the contents of tag

Last Updated : 23 Jul, 2025

Prerequisites: Beautifulsoup

Beautifulsoup is a Python library used to extract the contents from the webpages. It is used in extracting the contents from HTML and XML structures. To use this library, we need to install it first. Here we are going to append the text to the existing contents of tag. We will do this with the help of the BeautifulSoup library.

Approach

  • Import module
  • Open HTML file
  • Read contents
  • Append content to the required tag
  • Save changes to the file

Function used:

Append function of the Beautifulsoup module is used to append content to desired tags.

Syntax:

append("<string>"

File Used:

Python Code: 

Output:

👁 Image
output.html file
Comment
Article Tags: