Updating the HTML
Update the <body> tags in your HTML document to this.
<p id="foo">This is a paragraph.</p>
Next, let’s clear your script and add this bit of code.
var p = document.getElementById( 'foo' );
p.style.color = 'red';
To access the styles of your element, you first must access the style property of your element. Then, you type in the name of style you would like to change. You do not have to have a StyleSheet present in your HTML document. You also do not need to define a default style to change a style.
Your browser will automatically assign styles to elements if they aren’t set. Refresh your page and you should see your paragraph color change to the color red.
Changing the Visibility
Add this line of code into your script.
p.style.visibility = 'hidden';
This will hide your paragraph for you.