What is the preferred way of including CSS within a project? How do I know when to Use inline styles, the <style> tags, or a .css file?


#1

Question

What is the preferred way of including CSS within a project? How do I know when to
Use inline styles, the tags, or a .css file?

Answer

As a web developer you will eventually come across HTML documents which include CSS either inline with style attributes or within the <style> tags at the head of the document. Hence, it is important to be aware of all the various ways to include CSS in a project.

That having been said, mashing HTML and CSS together is not a great habit to get into. As developers we want to “separate our concerns” because this usually creates codebases that are more flexible, readable, and maintainable. As such, keeping our CSS contained within a separate .css file is the preferred way of including CSS within most projects.
For a deeper dive into some of the nuances here, take a look at this article.


FAQ: Learn CSS Selectors Visual Rules - CSS Setup Selectors - The CSS File
#2

I can’t see the link to the article suggested. I’ve noticed this in other answers from the bot. Am I missing something? Thank you.


#4

I’m not seeing the answer to the question as well.