Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language.
There’s a difference between HTML and CSS.
HTML – What to show on a web page
CSS – How to show the content
Three ways to apply css to html element:
- Inline – An inline style loses many of the advantages of a style sheet (by mixing content with presentation). To use inline styles, add the style attribute to the relevant tag. The style attribute can contain any CSS property.
<p style=”color:blue;text-align: center;”>This is a paragraph.</p>
- Internal – An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section of an HTML page, inside the <style> tag, like this:
Output in Browser :
- External – An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing just one file. Each page must include a link to the style sheet with the <link> tag. The <link> tag goes inside the head section:
<link rel=”stylesheet” type=”text/css” href=”mystyle.css”>
An external style sheet can be written in any text editor. The file should not contain any html tags. The style sheet file must be saved with a .css extension.