Saturday, November 15, 2025
HomeLanguagesJavascriptp5.js | createA() Function

p5.js | createA() Function

The createA() function in p5.js is used to create an anchor element in the DOM (Document Object Model) for creating a hyperlink. This function includes the p5.dom library. Add the following syntax in the head section. 
 

Syntax:  

createA( href, html, target )

Parameters:  

  • href: It holds the url of the page to the link.
  • html: It holds the display text.
  • target: It holds the target where the link will open.

The “target” can be ‘_blank’ (link will open in a new tab), ‘_self’ (link will open in the same tab), etc.
Example: This example uses createA() function to create a link of neveropen home page.

javascript




// Create a variable for anchor object
var link;
  
function setup() {
     
    // Create a canvas
    createCanvas(400, 200);
     
    // Set the background-color
    background('green');
     
    // Create a anchor object using createA() function
    link = createA("https://www.geeksforgeeks.org/",
                       "Go to neveropen", "_blank");
     
    // Position the anchor objects
    link.position(120, 80);   
}


Output: 

After clicking the link, neveropen home page will open in a new tab.
Reference: https://p5js.org/reference/#/p5/createA

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6890 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS