Styling HTML elements created in JavaScript

Hi

I was wondering how i’d be able to give elements like the ones I made with createP specific styling.

As a starting point i’d want to do something simple like make elements
made from createP(wants.wants[i].basic_information.artists[0].name); bold but leave createP(wants.wants[i].basic_information.title); elements as they are, so they stand out from each other.

I’ve gone over things like this before but I think a lot of my confusion comes from knowing when elements should be created in HTML and when they should be made in JS. It seems like this is a case where I maybe should be making them in HTML but i’m not sure how to get the data from the source to HTML and where JS would come in to it.

Thanks

var wants;

function setup() {
  noCanvas();
  loadJSON('https://api.discogs.com/users/lee182jib/wants', getData);
}

function getData(data) {
  wants = data;
  for(var i = 0; i < wants.wants.length; i++) {
    createP(wants.wants[i].basic_information.artists[0].name);
    createP(wants.wants[i].basic_information.title);
  }
}

function draw() {

}

1 Like