CSS NOTES
CSS NOTES
Styles in HTML are basically rules that describe how a document will be presented in
a browser. Style information can be either attached as a separate document or
embedded in the HTML document.
1. Inline Style
Inline Style: In Inline styling, the CSS rules are directly written inside the starting
tag using the style attribute. The style attribute includes a series of CSS property and
value pairs. Each ‘property: value ‘pair is separated by a semicolon (;).
CSS Syntax
1|Page
Inline style sheet css save as inlinestyle.html
NB: it will change only the first h1 selector, changing the specific style
where its applied. That’s why in our output result first h1 colors blue and
the other h1 remains by default black.
2|Page
3.External Style Sheet:
External style sheets are the most flexible because with an external style sheet, you
can change the look of an entire website by updating just one file.
You can attach external style sheets in two ways — linking and importing:
• If the style-sheet file has large data, then downloading the file takes
time and it increases page download speed.
• For static site with limited pages and different design on each
page, external style-sheets are harder to maintain.
➢
Link rel — element defines the relationship between the file that hosts
this command and the file defined in the href attribute. The standard
value for this attribute is stylesheet.
➢
type — defines the content of the linked file. In this tutorial, set this
attribute’s value to text/css. However, you can skip it altogether if
you’re using HTML5
➢
href — specifies the location of the CSS file you want to link to the
HTML. If the CSS file is in the same directory as the HTML file, you only
need to enter the file name. Otherwise, you need to include the folder
name in which you store the CSS file (example: CSS/stylesheet.css).
3|Page
Step 1. Open sublime text > select file >open folder>select new folder>rename
to your own name of choice.
Step 3. Open new tab ctr+n. write css rules and save as mystyle.css in the
same folder
Step 4. Run the code using html file and right click >select open in browser
4|Page
5|Page