Understanding javascript in the context of HTML, CSS?

At freecodecamp, I’ve learned HTML, then CSS builds on that. But then I jump into javascript, and I feel like I’m on another planet in a different universe. What is the relationship between javascript and HTML? I feel that if I knew how to make javascript code render output to a browser, I might have an easier time understanding what I’m trying to learn.

I’ve taken a peek at w3schools’ javascript tutorial, it it starts right away with executing javascript inside HTML. Will the freecodecamp lessons come back around to using javascript in an HTML context?

Thanks for any help with this.

Hello!

Which certification are you currently working on? I mean, the front end libraries certification is specifically aimed at JavaScript, HTML and CSS.

JavaScript is what helps you build interactive HTML websites. If you had only HTML, it would be hard to, for example, add new tags to the page:

// There's no way to add HTML content without a programming language
// JavaScript is the standard (EcmaScript is, actually) for this.
const theBody = document.body;
const aParagraph = document.createElement('P');
aParagraph.innerText = 'This is how we add dynamic content to the document';
theBody.appendChild(aParagraph);

// Working code: https://jsfiddle.net/skaparate/yx8o270d/1/
1 Like