HTML and CSS are kept in separate files in order to keep code maintainable and readable, as well as keep structure separate from styling.
The <style> element allows you to write CSS code within an HTML file.
A CSS stylesheet can be linked to an HTML file using the <link> element, which required three attirbutes:
href - set equal to the path of the CSS file.
type - set equal to text/css
rel - set equal to stylesheet
exmaple as that in html file:
<link href="/style.css" type="text/css" rel="stylesheet">
CSS comments begin with /* comment */
summmary:
A CSS sekector targets an HTML element.
CSS declarations style HTML elements.Declarations must contain the following two things:
1.the property you want to style.
2.the value for the property you are styling.
CSS declarations must end in a semicolon(;)
A CSS rule consist of a CSS selector and the declarations inside for the selector.
Multiple elements selectors can be used to style multiple elements at once.
Comments keep code easy to read and allow you to experiemnt with new code without hacing to remove old code.
CSS follows certain best practices for spacing and indentation:
On line of spacing between a selector and the opening curly brace.
No spacing between CSS declarations and the opening and closing curly braces of the CSS rule.
Two spaces od indentation for CSS declarations.
One line of spacing between CSS rules.