css · CSS Basics
Which HTML attribute specifies an inline style sheet?
Answers
- style
- in-style
- font
- class
This is a blue-colored paragraph.
``` In this example, "style" is the attribute, "color" is the CSS property, and "blue" is the value. This results in the text inside the `` tags being displayed in blue color. ## Best Practices Though the "style" attribute is a robust tool, it's important to use it judiciously. Keeping your styles in an external CSS file is still the best practice as it can make maintenance simpler. This is because your styling rules are in a central place and you don't have to sort through your HTML document or documents to change a style. Using the style attribute can create repetition if you want to style multiple elements the same way, which goes against the "Don't Repeat Yourself" principle in programming. Unlike class selectors in CSS, you can't re-use inline styles across different elements. However, inline styles have the highest specificity, which means they override any conflicting styles declared elsewhere. This can be advantageous when you want to override styles in an external CSS file for a specific element. The takeaway here is that while the "style" attribute can be incredibly useful, particularly for small tasks or debugging, it would be best to keep the majority of your CSS in external or internal style sheets, using classes and ids for more efficient, manageable, and scalable styling.