Is CSS really necessary sometimes?

Hi 

I’m just starting to learn code, and learning atom by myself.  My original problem, was that I couldn’t link a regular coloured box in atom between html and css.  After doing a bit of research, I came across this code:

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
background-color: green;
}

div {
background-color: lightblue;
}

p {
background-color: yellow;
}
</style>
</head>
<body>

<h1>CSS background-color example!</h1>
<div>
This is a text inside a div element.
<p>This paragraph has its own background color.</p>
We are still in the div element.
</div>

</body>
</html>

This is my original code.  As of right now, following the course, I was just looking at embedding a plain coloured box to my html via css:

I was just wondering, do I really need to link a css, if I can do it in the html, as mentioned in the first code above?

I don’t know the answer to the question myself, but I do know that there is an Atom User Forum where lots of people gather to discuss exactly these sorts of things. I think you may get some great responses if you post this question over there!

1 Like

I just recently took a whole course on HTML, CSS, & Javascript. To answer your question, no it is not necessary if all your looking to do is some very basic styling. HTML has basic styling you can include if you know the syntax for it. Web developers do not often use inline styles (Styling in HTML) when creating web pages, for many reasons. The reasons include “semantic markup”, maintainability, reusability, and scalability. The more advanced your styling is going to be, the more you should gravitate to creating a seperate CSS file. Hope this helps!

  • Robin.