I’m new to HTML/CSS and going through fcc curriculum at the moment (which is great). My question is this. I have already added a CSS entry to style the
elements for my web pages as I use a common style for the majority of my text across my whole site.
If I have to style a few other
elements differently and it requires only one change (in this case, centering text instead of dressing left), should I use an inline item like this in the html document:
<p style="text-align: center"
or use an ID attribute and entry in my CSS file. In both cases it’s only one extra entry in the html code. What is best practice regards coding? My sense is, the idea is to keep as much styling as possible in the css file?
Good question. I suggest keeping all of your styles in an external stylesheet.
For styling flexibility, remember you can add more than one class to an element’s class attribute, so to center just some of the elements, you could create a .center selector for that.