# getElementById is not a function - styling elements made in p5.js

**URL:** <https://discourse.processing.org/t/getelementbyid-is-not-a-function-styling-elements-made-in-p5-js/2456>\
**Category:** Beginners\
**Created:** [August 7, 2018, 9:05pm UTC](https://discourse.processing.org/t/getelementbyid-is-not-a-function-styling-elements-made-in-p5-js/2456 "2018-08-07T21:05:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LWoodall](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@LWoodall](https://discourse.processing.org/u/LWoodall)\
**Post date:** [August 7, 2018, 9:05pm UTC](https://discourse.processing.org/t/getelementbyid-is-not-a-function-styling-elements-made-in-p5-js/2456/1 "2018-08-07T21:05:45Z")

</div>

```auto
var url1 = 'https://api.wordnik.com/v4/word.json/';
var word = 'vinyl';
var url2 = '/examples?includeDuplicates=false&useCanonical=false&limit=5&api_key=MY_API_KEY';
var input;
var submit;
var example;

function setup() {
  noCanvas();
  input = createInput('vinyl');
  submit = createButton('find example');
  submit.mouseClicked(getExample)
  example = createP("hello");
  example.getElementById('sentence');
}

function getExample() {
  loadJSON(url1 + input.value() + url2, gotData);
}

function gotData(data) {
  example.html(data.examples[0].text);
}

```

I’m trying to style my what i’ve made in the above code with css but when I try to link the element to my css file with example.getElementById(‘sentence’) I get the following error.

Uncaught ReferenceError: getElementById is not defined

Not sure what i’m doing wrong, a search seems to tell me that I need to define ‘example’ before I give it an ID?

Any help would be great.  
Thanks

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [August 7, 2018, 9:13pm UTC](https://discourse.processing.org/t/getelementbyid-is-not-a-function-styling-elements-made-in-p5-js/2456/2 "2018-08-07T21:13:03Z")

</div>

Your error says it all: `example.getElementById()` is not a function. And [the reference](https://p5js.org/reference/#/libraries/p5.dom) agrees with that.

Perhaps you’re looking for the `select()` function? Again, [the reference](https://p5js.org/reference/#/p5/select) is your best friend.
