CodesJava

Easy learning with example program codes

How to Add CSS

There are 3 ways to apply CSS to html elements. These are:

  • Inline CSS: Uses the style attribute in HTML elements.
  • Internal CSS: Uses a <style> element in the <head> section.
  • External CSS: Uses an external CSS file.

Inline CSS:

Uses the style attribute to apply CSS to a single HTML element.

Example:

<h1 style="color:crimson;font-style: italic;">Hello World!!</h1>

Internal CSS:

Uses a <style> element in the <head> section to apply CSS to a single HTML page.

Example:

<style>
h1 {background-color: crimson; color: white;}
p {color: crimson;font-size: 25px;font-style: italic;}
</style>

External CSS:

Uses an external CSS file to apply CSS to multiple HTML pages.

Example:

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

style.css:

h1   {
background-color: crimson; 
color: white;
}
p    {
color: crimson;
font-size: 25px;
font-style: italic;
}
Please follow and like us:
error
Posted in CSS   









Copyright © 2019 CodesJava DMCA.com Protection Status