How to work with HTML Style

In this article I will explain the Styles in HTML.
  • 1966

HTML is not good when we want the look and feel or the attractive website, In order to achieve this we use the CSS in HTML or we can say that we apply the stylesheet in HTML by using the <Style> tag.CSS can be added to the documents by the following ways,

  • Inline - using the style attribute in HTML elements
  • Internal - using the <style> element in the <head> section
  • External - using an external CSS file

Inline Styles

An inline style can be used if a unique style is to be applied to one single occurrence of an element.

Example

<html>

<head>

    <title></title>

</head>

<body>

    <h3 style="color:Red">Richa Garg</h3>

    <h2 style="background-color:Blue">Richa Garg</h2>

</body>

</html>

 

 

Output

1111.jpg

 

Internal Styles

 

An internal style sheet can be used if one single document has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag,

 

<html>

<title></title>

<head>

    <style type="text/css">

        body

        {

            background-color: yellow;

        }

        h3

        {

            color: blue;

        }

    </style>

</head>

<body>

    <h3>

        Hypertext markup language</h3>

</body>

</html>

 

Output
 

2222.jpg

 

External Styles
 

We can pass the reference of external css file by using the external style sheets for this we use link element of the HTML.

 

<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

 

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 
Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.