Internal CSS with Example
Internal CSS is written inside the same HTML page, it is used inside the head tag
In other words -
CSS enclosed in tags within an HTML document functions like an external stylesheet, except that it lives in the HTML document it styles instead of in a separate file, and
Therefore can only be applied to the document in which it lives.
Note that this element must be inside the element for HTML validation (though it will work in all current browsers if placed in body)
Now we will see Examples -
Example - Adding border-
CSS @import rule (one of CSS at-rule) -
The @import CSS at-rule is used to import style rules from other style sheets.
These rules must precede all other types of rules, except @charset rules;
as it is not a nested statement, @import cannot be used inside conditional group at-rules.
CSS Inline with Examples
Inline CSS is written inside the element itself in a HTML page.
Use inline styles to apply styling to a specific element. Note that this is not optimal.
Placing style rules in a <style> tag, or external CSS file is encouraged in order to maintain a distinction between content and presentation.
Inline styles override any CSS in a <style> tag or external style sheet.
While this can be useful in some circumstances, this fact more often than not reduces a project's maintainability.
The styles in the following example apply directly to the elements to which they are attached.
Now we will see an Example -