HTML Style CSS

HTML Style CSS:-

What is CSS:-

  • Cascading Style Sheets (CSS) is used to format the layout of a webpage.
  • With CSS, you can control the color, font, the size of text, the spacing between elements, how elements are positioned and laid out, what background images or background colors are to be used, different displays for different devices and screen sizes, and much more!  CSS can be added to HTML documents in 3 ways:
  1. Inline–   by using the style attribute inside HTML element.
  2. Internal-by using a <style> element in the <head> section
  3. External– by using a <link> element to link to an external CSS file.

 1.Inline-An inline CSS is used to apply a unique style to a single HTML element.

An inline CSS uses the style attribute of an HTML element.

Example:-

<h1 style=”color :blue;”>A Blue Heading</h1>

<p style=”color :red;”>A red paragraph.</p>

2.internal:-

An internal CSS is used to define a style for a single HTML page.

An internal CSS is defined in the <head> section of an HTML page, within a <style> element.

Example:-

<!DOCTYPE html>
<html>
<head>
<style>
<body>
{background color :blue;}
 h1{color :Red;}
p{color :pink;}

</style>

</head>

<body>

<h1>This is heading</h1>

<p>This is a paragraph</p>

</body>

</html>

3.External:-

An external style sheet is used to define the style for many HTML pages.

Example:-

 <!DOCTYPE html>
<html>
<head>
  <link rel=”stylesheet” href=”styles.css”>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph</p>
</body>
</html>