# help me please with Uncaught TypeError: Cannot read property 'style' of null

**URL:** <https://forum.kirupa.com/t/help-me-please-with-uncaught-typeerror-cannot-read-property-style-of-null/638230>\
**Category:** programming\
**Created:** [May 17, 2018, 3:26am UTC](https://forum.kirupa.com/t/help-me-please-with-uncaught-typeerror-cannot-read-property-style-of-null/638230 "2018-05-17T03:26:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingcarlostello](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ingcarlostello/32/9125_2.png) [@ingcarlostello](https://forum.kirupa.com/u/ingcarlostello)\
**Post date:** [May 17, 2018, 3:26am UTC](https://forum.kirupa.com/t/help-me-please-with-uncaught-typeerror-cannot-read-property-style-of-null/638230/1 "2018-05-17T03:26:17Z")

</div>

I am starting to learn to develop in html, css and javascrip and I was applying the example of “requestAnimationFrame” to an exercise I’m doing to understand more. but when I run the code I get an error like this:

“Uncaught TypeError: Can not read property ‘style’ of null”

my code editor is visual studio code and I run everything in the latest version of chrome. and attached the CSS file and javascript file[ejercicios.js](https://forum.kirupa.com/uploads/short-url/kONO8BmxFyRlR0iNyMzQOd3JEcw.js) (384 Bytes)  
[mover.css](https://forum.kirupa.com/uploads/short-url/rwrgTkteXJxwGCDwv3oaQWdkMIW.css) (233 Bytes)

+++++++++++++++++++++++++++++++++++

```
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="mover.css" />
<script src="ejercicios.js"></script>

```

++++++++++++++++++++++++++++++++++++++++++++

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [May 17, 2018, 4:24am UTC](https://forum.kirupa.com/t/help-me-please-with-uncaught-typeerror-cannot-read-property-style-of-null/638230/2 "2018-05-17T04:24:44Z")

</div>

This line is where the problem is:

`var element = document.getElementById("thing");`

The `element` variable is set to **null**. The reason probably has to do with your code running before the full DOM has loaded. You can fix this by putting your `script` tag at the bottom of the page just above the closing `body` tag. You can learn more about other approaches you can take at the following tutorial: [https://www.kirupa.com/html5/running\_your\_code\_at\_the\_right\_time.htm](https://www.kirupa.com/html5/running_your_code_at_the_right_time.htm)

Let me know if that change fixes it for you 🙂

Cheers,  
Kirupa

---

<div class="post-metadata">

**Author:** ![ingcarlostello](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ingcarlostello/32/9125_2.png) [@ingcarlostello](https://forum.kirupa.com/u/ingcarlostello)\
**Post date:** [May 17, 2018, 8:18pm UTC](https://forum.kirupa.com/t/help-me-please-with-uncaught-typeerror-cannot-read-property-style-of-null/638230/3 "2018-05-17T20:18:02Z")

</div>

thank you Kirupa for the answer soon, really appreciate that. about your advice its works I did the change and is working finally I will could keep study.

thanks a lot.
