Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Roland O'Donnell
Roland O'Donnell
5,667 Points

how to style my javascript???

i know basic html and css, now I'm learning java script building a basic program..how to i style my javascript, I'm printing out results and want to style things differently. my css just applies it to the entire script tag (which I'm understanding why) how do i access different parts of my javascript in the html?

i am learning more and more everyday so i will proberly find out soon but its bugging me coz my program looks ugly

thanks

1 Answer

Well, if you are creating the HTML within you JavaScript for some reason then you need to add div or span tags in there to, essentially the same as plain HTML

document.getElementById("demo").innerHTML = "Paragraph changed!"; // Assuming demo is an existing paragraph with no content

But if you mean styling it from inside the javascript then you could try something simular to this:

myElement.style.backgroundColor = "#D93600";

You simply need to change the css of the selected element to remove the default css in your stylesheet