style html css code example

Example 1: how to link css to html

<link rel="stylesheet" href="styles.css">

Example 2: how to write css in html

<p style="color: blue; font-size: 46px;">

Example 3: css how to style a

/*a normal, unvisited link*/
a:link{
	color: green;
}
/*a link the user has visited*/
a:visited{
	color: purple;
}
/*a link when the user mouses over it*/
a:hover{
	color: yellow;
}
/*a link the moment it is clicked*/
a:active{
	color: brown;
}

Example 4: how to link css to html

<link rel="stylesheet" href="file_name.css">

Example 5: CSS IN HTML

<!-- There are 3 ways to do this-->

<!-- #1: Inline CSS-->
<h1 style="color: red;">Red Heading</h1>

<!-- #2 Element CSS-->
<style>
  h1 {
    color: red;
  }
</style>
<h1>Red Heading</h1>

<!-- #3 Stylesheet CSS-->
<link rel="stylesheet" href="[stylesheet link]">

Example 6: css without separate file

just add any style inside the first <p> or other element tag using style=" ;" 
<p style="font-size: xx-large;">test</p>

Tags:

Html Example