JavaScript Adding an ID attribute to another created Element June 29, 2023 by Tarik Since id is an attribute don’t create an id element, just do this: myPara.setAttribute("id", "id_you_like");