×    Online HTML Editor

Share 4

Share 4

×   Embed Video - Inline CSS

Copy  

× Help - HTML Programming

YouTube

GSSS KHOKHAR Online HTML Editor

Write, Run & Share HTML code online using GSSS KHOKHAR HTML online Code editor for free.


About HTML

HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.

  • Any HTML document must start with document declaration <!DOCTYPE html>
  • HTML documents begin with <html> and ends with </html>
  • Headings are defined with <h1> to <h6> where <h1> is the highest important heading and <h6> is the least important sub-heading.
  • Paragrahs are defined in <p>..</p> tag.
  • Links are defined in <a> tag.

    Example:

    
    <!DOCTYPE html>
    <html>
    <head>    
        <title>Simple HTML Program</title>
    </head>
    <body>
        <h1>Simple HTML Program</h1>
        <h2>GSSS KHOKHAR, Sri Muktsar Sahib</h2>
    </body>
    </html>
    

Now, Click on the RUN button and output will display in output framework.

  • Images are defined in <img> tag, where src attribute consists of image name.
  • Buttons are defined in <button>..</button> tag
  • Lists are defined in <ul> for unordered/bullet list and <ol> for ordered/number list, and the list items are defined in <li>.

HTML Elements and Attributes

  • HTML element is everything present from start tag to end tag.
  • The text present between start and end tag is called HTML element content.
  • Anything can be a tagname but it's preferred to put the meaningful title to the content present as tag name.
  • Do not forget the end tag.
  • Elements with no content are called empty elements.
  • Elements can have attributes which provides additional information about the element.
  • In the below example, href is an attribute and a is the tag name.

    Example:

    
    <a href="https://www.gssskhokhar.com/html/">HTML</a>

CSS

CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.

Example:

Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.


body{
  padding: 25px;
}
.title {
	color: #228B22;
	font-family: Candara;
}

HTML Tables

  • HTML Tables are defined in <table> tag.
  • Table row should be defined in <tr> tag
  • Table header should be defined in <th> tag
  • Table data should be defined in <td> tag
  • Table caption should be defined in <caption> tag

HTML- Javascript

  • Javascript is used in HTML pages to make them more interactive.
  • <script> is the tag used to write scripts in HTML
  • You can either reference a external script or write script code in this tag.

Example


<script src="script.js"></script>

× Contact advertising

Coming Soon...



×    Video - Inline CSS


×    Inline CSS - HTML


ਸਟਾਈਲ ਸ਼ੀਟਸ (Style Sheels)

ਕੈਸਕੇਡਿੰਗ ਸਟਾਈਲ ਸ਼ੀਟ, ਜਿਸ ਨੂੰ CSS (Cascading Style Sheets) ਵੀ ਕਿਹਾ ਜਾਂਦਾ ਹੈ, ਇੱਕ ਸਧਾਰਨ ਡਿਜ਼ਾਈਨ ਭਾਸ਼ਾ ਹੈ ਜੋ ਵੈੱਬਪੇਜਾਂ ਦੇ ਡਿਜ਼ਾਈਨ ਨੂੰ ਸਧਾਰਨ ਅਤੇ ਪ੍ਰਭਾਵਸ਼ਾਲੀ ਬਣਾਉਣ ਲਈ ਵਰਤੀ ਜਾਂਦੀ ਹੈ। ਜਿਥੇ CSS ਸਿੱਖਣਾ ਅਤੇ ਸਮਝਣਾ ਆਸਾਨ ਹੈ, ਉਥੇ ਇਹ ਮਜ਼ੇਦਾਰ ਵੀ ਹੈ। ਇਹ ਆਮ ਤੌਰ 'ਤੇ HTML ਨਾਲ ਵੈੱਬਸਾਈਟਸ ਬਣਾਉਣ ਲਈ ਵਰਤੀ ਜਾਂਦੀ ਹੈ। CSS ਨਿਰਧਾਰਤ ਕਰਦਾ ਹੈ ਕਿ HTML Element ਕਿਵੇਂ ਪ੍ਰਦਰਸ਼ਿਤ ਕੀਤੇ ਜਾਣੇ ਚਾਹੀਦੇ ਹਨ।

CSS ਦੀ ਵਰਤੋਂ ਕਿਸੇ ਵੈੱਬਪੇਜ ਦੀ ਦਿੱਖ ਨੂੰ ਬਿਹਤਰ ਬਣਾਉਣ ਲਈ ਕੀਤੀ ਜਾਂਦੀ ਹੈ। ਟੈਕਸਟ ਦਾ ਰੰਗ, ਵੱਟ ਸ਼੍ਰੇਣੀਆਂ, ਪੈਰਾਡਿਜ਼ਮ, ਕਾਲਮ, ਇਮੇਜ਼, ਲੇਆਊਟ ਡਿਜ਼ਾਈਨ, ਵੱਖ-ਵੱਖ ਡਿਵਾਈਸਾਂ ਅਤੇ ਸਕਰੀਨਜ਼ ਲਈ ਡਿਸਪਲੇਅ ਸਾਈਜ਼ ਅਤੇ ਹੋਰ ਬਹੁਤ ਸਾਰੇ ਡਿਜ਼ਾਈਨ ਅਤੇ ਡਿਜ਼ਾਈਨ Elements ਦੇ ਪ੍ਰਦਰਸ਼ਨ ਵਿਚ ਤਬਦੀਲੀਆਂ ਕਰਨ ਲਈ CSS ਦੀ ਵਰਤੋਂ ਕੀਤੀ ਜਾਂਦੀ ਹੈ।

1. CSS (Benefits of CSS)

1. ਸਮੇਂ ਦੀ ਬਚਤ- CSS ਕੋਡ ਨੂੰ ਜ਼ਰੂਰਤ ਅਨੁਸਾਰ ਵਾਰ-ਵਾਰ ਵਰਤਿਆ ਜਾ ਸਕਦਾ ਹੈ ਅਤੇ ਫਿਰ ਉਸੇ ਬੀਟ ਨੂੰ ਕਈ HTML ਪੰਨਿਆਂ ਵਿਚ ਦੁਬਾਰਾ ਇਸਤੇਮਾਲ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ।

2. ਸਪੀਡ (ਤੇਜ਼ੀ ਨਾਲ ਵੈੱਬਪੇਜ ਲੋਡ ਹੋਣਾ) – CSS ਨੂੰ html ਵਿਚ ਫਾਰਮੈਟਿੰਗ ਕਰਨ ਲਈ ਘੱਟ ਕੋਡ ਦੀ ਜ਼ਰੂਰਤ ਹੁੰਦੀ ਹੈ, ਜਿਸ ਨਾਲ ਵੈੱਬਪੇਜ ਬਣਾਉਣ ਅਤੇ ਵੈੱਬ ਬ੍ਰਾਊਜ਼ਰ ਵਿਚ Loud ਹੋਣ ਦੀ ਸਪੀਡ ਵੀ ਵੱਧ ਜਾਂਦੀ ਹੈ। ਇਸ ਨਾਲ ਵੈ ਬਪੇਜ ਦਾ ਆਕਾਰ ਵੀ ਘੱਟਦਾ ਹੈ ਅਤੇ ਵੈੱਬਪੇਜ ਹਲਕਾ (Light Design) ਦਾ ਬਣਦਾ ਹੈ।

3. ਆਸਾਨ ਰੱਖ-ਰਖਾਅ ਇੱਕ ਜਗ੍ਹਾ 'ਤੇ CSS ਕੋਡਿੰਗ ਵਿਚ ਕੀਤੀਆਂ ਗਈਆਂ ਤਬਦੀਲੀਆਂ ਆਪਣੇ ਆਪ ਹੀ ਹਰ ਜਗ੍ਹਾ 'ਤੇ ਲਾਗੂ ਹੋ ਜਾਂਦੀਆਂ ਹਨ, ਮਤਲਬ ਕਿ ਪੂਰੇ ਵੈੱਬਸਾਈਟ/ਵੈੱਬਪੇਜ ਦੇ ਭਾਗਾਂ (ਬਣਤਰ ਅਤੇ ਡਿਜ਼ਾਈਨ) ਨੂੰ ਬਦਲਿਆ ਜਾ ਸਕਦਾ ਹੈ ਅਤੇ ਇਸ ਤਰ੍ਹਾਂ ਮੁੱਖ ਵੈੱਬ ਕੋਡਿੰਗ ਨੂੰ ਬਦਲਣ ਦੀ ਜਰੂਰਤ ਨਹੀਂ ਹੈ ਜਿਸ ਨਾਲ ਗਲਤੀਆਂ ਹੋਣ ਦੀ ਸੰਭਾਵਨਾ ਵੀ ਘੱਟ ਜਾਂਦੀ ਹੈ।

4. ਵਧੇਰੇ ਸ਼ਕਤੀਸ਼ਾਲੀ ਵੈੱਬਪੇਜਾਂ ਨੂੰ CSS ਦੀ ਵਰਤੋਂ ਨਾਲ ਵਧੇਰੇ ਬਿਹਤਰ ਅਤੇ ਆਸਾਨ ਤਰੀਕੇ ਨਾਲ ਤਿਆਰ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ। CSS ਵਿਚ HTML ਨਾਲੋਂ ਜ਼ਿਆਦਾ ਪ੍ਰਾਪਰਟੀਜ ਹਨ।

5. ਮਲਟੀਪਲ ਡਿਵਾਈਸ ਸਪੋਰਟ- CSS ਦੀ ਵਰਤੋਂ ਵੱਖ-ਵੱਖ ਸਕਰੀਨ ਸਾਈਜ਼ ਡਿਵਾਈਸਿਸ ਤੇ ਵੈੱਬਪੇਜਾਂ ਨੂੰ ਸਹੀ ਢੰਗ ਨਾਲ ਡਿਸਪਲੇਅ (ਦਿਖਾਉਣ) ਕਰਨ ਲਈ ਕੀਤੀ ਜਾ ਸਕਦੀ ਹੈ ਅਤੇ CSS ਦੀ ਵਰਤੋਂ ਕਰਦਿਆਂ, ਵੱਖ-ਵੱਖਰੇ ਡਿਵਾਈਸਿਸ ਲਈ ਵੈੱਬਸਾਈਟ ਦੇ ਵੱਖ-ਵੱਖ version ਬਣਾਏ ਜਾ ਸਕਦੇ ਹਨ। 

 

ਸਟਾਈਲ ਬੀਟਸ ਦੀਆਂ ਕਿਸਮਾਂ (1ypes of Style Sheets)

CSS ਨੂੰ ਵਰਤਣ ਦੇ 3 ਤਰੀਕੇ ਹਨ :

1) Inline sytle : ਇਹ HTML ਦੇ <BODY> ਸੈਕਸ਼ਨ ਵਿੱਚ ਟੈਗਜ਼ ਵਿਚ ਵਰਤੀ ਜਾਂਦੀ ਹੈ। ਉਦਾਹਰਣ : <p style="color: red; border: 2px solid;"> This is an inline css example, </p>.

2) Internal style sheet : ਇਹ ਪੂਰੇ ਵੈੱਬਪੇਜ ਲਈ ਵਰਤੀ ਜਾਂਦੀ ਹੈ ਅਤੇ ਇਸਦਾ ਕਡ <head> ਟੈਗ ਵਿੱਚ ਲਿਖਿਆ ਜਾਂਦਾ ਹੈ, ਉਦਾਹਰਣ :

<head>

<style>

p {

color: red; border: 2px solid;

}

</style>

</head>

3) External style sheet : ਇਸਦੀ ਵਰਤੋਂ ਵੱਖਰੀ ਫਾਈਲ ਬਣਾ ਕੇ ਕੀਤੀ ਜਾਂਦੀ ਹੈ। ਸਾਰੀ Coding ਇਸ ਵੱਖਰੀ ਫ਼ਾਈਲ ਵਿੱਚ ਕੀਤੀ ਜਾਂਦੀ ਹੈ ਅਤੇ ਇਸ ਫ਼ਾਈਲ ਦੀ ਐਕਸਟੈਂਸ਼ਨ .css ਹੁੰਦੀ ਹੈ। ਇਹ ਫਾਈਲ ਦੇ ਰੂਪ ਵਿੱਚ ਬਣਾਈ ਜਾਂਦੀ ਹੈ ਅਤੇ ਇਸ ਫਾਈਲ ਨੂੰ ਅਲੱਗ-ਅਲੱਗ ਦੇ ਥਪੇਜਿਜ਼ ਨਾਲ ਲਿੰਕ ਕਰਕੇ ਵਰਤਿਆ ਜਾ ਸਕਦਾ ਹੈ। ਜਦੋਂ ਇਸ ਫ਼ਾਈਲ ਵਿਚ ਤਬਦੀਲੀ ਕੀਤੀ ਜਾਂਦੀ ਹੈ ਤਾਂ ਸਾਰੇ ਲਿੰਕ ਕੀਤੇ ਵੈੱਬਪੇਜਾਂ 'ਤੇ ਇਹ ਤਬਦੀਲੀ ਦਿਖਾਈ ਦਿੰਦੀ ਹੈ। ਅਸੀਂ ਇਹ ਐਕਸਟਰਨਲ ਸਟਾਈਲ ਸੀਟ ਫਾਈਲ ਨੂੰ ਲਿੰਕ ਕਰਨ ਲਈ, ਵੈੱਬਪੇਜ ਦੇ <head> ਸੈਕਸ਼ਨ ਵਿਚ <link ਟੈਗ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹਾਂ | ਉਦਾਹਰਣ :

<head>

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

</head>

Exteral CSS ਫਾਈਲਜ਼ ਕਿਸੇ ਵੀ ਟੈਕਸਟ ਐਡੀਟਰ ਵਿੱਚ ਬਣਾਈਆਂ ਜਾ ਸਕਦੀਆਂ ਹਨ। ਵਿੱਚ ਕੋਈ ਵੀ hian] ਟੈਗ ਨਹੀਂ ਹੋਣੇ ਚਾਹੀਦੇ। ਸਟਾਈਲ ਸੀਟ ਫਾਈਲ ਦੀ ਉਦਾਹਰਣ CSS Filename: "myStyle.css":

color: red; border:2px solid;

 

CSS SYNTAX CSS rule-set ਵਿੱਚ ਇੱਕ selector ਅਤੇ declaration block ਹੁੰਦਾ ਹੈ :

CSS Selector : ਇਹ ਉਸ ਐਲੀਮੈਂਟ ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ ਜਿਸਦਾ style ਅਸੀਂ ਫਾਰਮੇਟ ਕਰਨਾ

CSS Declaration : ਇਹ ਐਲੀਮੈਂਟ ਦੀਆਂ ਪ੍ਰਾਪਰਟੀਜ਼ ਨੂੰ ਨਿਰਧਾਰਤ ਕਰਨ ਲਈ ਵਰਤੀ ਜਾਂਦੀ ਹੈ ਅਤੇ ਹਰੇਕ ਪ੍ਰਾਪਰਟੀ ਨੂੰ ਸਮੀਕਾਲਨ (;) ਨਾਲ End ਕੀਤਾ ਜਾਂਦਾ ਹੈ | ਇੱਥੇ ਬਹੁਤ ਸਾਰੀਆਂ ਪ੍ਰਾਪਰਟੀਜ਼ ਹੁੰਦੀਆਂ ਹਨ ਜੋ ਡਿਕਲੇਰੇਸ਼ਨ ਬਲਾਕ ਵਿੱਚ ਵਰਤੀਆਂ ਜਾ ਸਕਦੀਆਂ ਹਨ। ਇਸਨੂੰ HTML ਟੈਗ ਐਟਰੀਬਿਊਟ ਦੇ ਤੌਰ 'ਤੇ ਇੰਟਰਪੋਟ (Interpret) ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ।
 

CSS ਸਿਲੈਕਟਰਜ HTML ਐਲੀਮੈਂਟਸ ਨੂੰ ਚੁਣਨ ਅਤੇ ਫਾਰਮੇਟ ਕਰਨ ਵਿੱਚ ਸਾਡੀ ਸਹਾਇਤਾ ਕਰਦੇ ਹਨ ਅਤੇ cases, types, attributes ਆਦਿ Selectors ਵੱਜੋਂ ਵਰਤੇ ਜਾ ਸਕਦੇ ਹਨ।

1. ਐਲੀਮੈਂਟ ਸਿਲੈਕਟਰ ਐਲੀਮੈਂਟ ਸਿਲੇ ਵਰ; html ਐਲੀਮੈਂਟ ਨੂੰ ਬਟਨ ਜਾਂ ਫਾਰਮੇਟ ਕਰਨ ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ ਜਿਵੇਂ ਕਿ ਪੈਰਾਗ੍ਰਾਫ ਇੱਕ ਪੈਰਾਗ੍ਰਾਫ ਲਈ html ਵੈੱਬਪੇਜ ਵਿੱਚ ਹੇਠ ਲਿਖੀ ਉਦਾਹਰਣ ਨੂੰ ਸਮਝੇ : <p>This is an example of paragraph in web page</p> ਜੇ ਅਸੀਂ ਇਸ ਨੂੰ Element Selector ਦੀ ਸਹਾਇਤਾ ਨਾਲ CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਫਾਰਮੈਟ ਕਰਨਾ ਚਾਹੁੰਦੇ ਹਾਂ,

ਤਾਂ ਸਾਨੂੰ ਇਸਨੂੰ ਹੇਠਾਂ ਦਿੱਤੇ ਅਨੁਸਾਰ ਲਿਖਣਾ ਪਏਗਾ (ਜਾਂ ਤਾਂ Intemal CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਜਾਂ External of ਵਰਤੋਂ ਕਰਕੇ।

p {

text-align: center;

color: red;

}

2. 1D ਸਿਲੈਕਟਰ ਇਹ HTML ਦੇ id ਐਟਰੀਬਿਊਟ ਨੂੰ ਫਾਰਮੇਟ ਕਰਨ ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ। ਅਸੀਂ ਇਸ ਸਿਲੈਕਟਰ ਦੀ ਵਰਤੋਂ ਕਿਸੇ ਵਿਸ਼ੇਸ਼ ਐਲੀਮੈਂਟ ਨੂੰ ਫਾਰਮੈਟ ਕਰਨ ਲਈ ਕਰਦੇ ਹਾਂ। ਇਹ ॥ (ਹੇਸ਼) ਚਿੰਨ੍ਹ ਅਤੇ ਐਲੀਮੈਂਟ ਦੇ ਨਾਮ ਨਾਲ ਸ਼ੁਰੂ ਹੁੰਦਾ ਹੈ। ਇੱਕ ਪੈਰਾਗ੍ਰਾਫ ਲਈ html ਵੈੱਬਪੇਜ ਵਿੱਚ ਹੇਠ ਲਿਖੀ ਉਦਾਹਰਣ ਵੇਖੋ :

<p id="#paral"> This is an example of paragraph in web page</p> ਜੇ ਅਸੀਂ ਇਸ ਨੂੰ id ਸਿਲੈਕਟਰ ਦੀ ਸਹਾਇਤਾ ਨਾਲ CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਫਾਰਮੇਟ ਕਰਨਾ ਚਾਹੁੰਦੇ ਹਾਂ, ਤਾਂ ਸਾਨੂੰ ਇਸਨੂੰ ਹੇਠਾਂ ਦਿੱਤੇ ਅਨੁਸਾਰ ਲਿਖਣਾ ਪਏਗਾ (ਜਾਂ ਤਾਂ Intemal CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਜਾਂ Extemal CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ)

#paral {

text-align: center;

color: red;

}

3. ਕਲਾਸ ਸਿਲੈਕਟਰ ਇਹ ਐਲੀਮੈਂਟ ਦੇ ਕਲਾਸ ਐਟਰੀਬਿਊਟ ਨੂੰ ਫਾਰਮੇਟ ਕਰਨ ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ। ਇਹ ਬਿੰਦੀ ( ) ਅਤੇ CLASS ਦੇ ਨਾਮ ਨਾਲ ਸ਼ੁਰੂ ਹੁੰਦਾ ਹੈ| Html ਵੈੱਬਪੇਜ ਵਿੱਚ ਹੇਠ ਲਿਖੀ ਉਦਾਹਰਣ ਨੂੰ ਸਮਝੋ : <p class="center"> This is an example of paragraph in web page</p> <h1 class="center"> This is an example of Heading Level 1</h1> <p class="center"> This is another example of paragraph in web page</p> ਜੇ ਅਸੀਂ CLASS ਸਿਲੈਕਟਰ ਦੀ ਸਹਾਇਤਾ ਨਾਲ ਇਨ੍ਹਾਂ ਦੋਵਾਂ ਐਲੀਮੈਂਟਸ ਨੂੰ ਇਕੋ ਜਿਹੇ ਫਾਰਮੇਟ ਕਰਨ ਚਾਹੁੰਦੇ ਹਾਂ, ਤਾਂ ਸਾਨੂੰ ਇਸਨੂੰ ਹੇਠਾਂ ਦਿੱਤੇ ਅਨੁਸਾਰ ਲਿਖਣਾ ਪਵੇਗਾ (ਜਾਂ ਤਾਂ Intermil CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਜਾਂ Elemal CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ)

.center {

text-align: center;

color: red;

}

 

4. ਗਰੁੱਪਿੰਗ ਸਿਲੈਕਟਰਜ਼ ਇਹ ਕੋਡਿੰਗ ਨੂੰ ਘਟਾਉਣ ਅਤੇ ਸਮਾਂ ਬਚਾਉਣ ਲਈ ਵਰਤੇ ਜਾਂਦੇ ਹਨ। ਕਈ ਐਲੀਮੈਂਟਸ ਨੂੰ ਇਕੋ ਸਮੂਹ ਵਿਚ ਇਕੱਠਿਆਂ ਕਰਕੇ ਇਕੋ ਜਿਹਾ ਫਾਰਮੈਟ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ। HTML ਵੈੱਬਪੇਜ ਵਿੱਚ ਹੇਠ ਲਿਖੀ ਉਦਾਹਰਣ ਤੇ ਵਿਚਾਰ ਕਰੋ :

<p>This is an example of paragraph in web page</p>

<h1> This is an example of Heading Level 1</h1>

<h2> This is an example of Heading Level 2</h2>

ਜੇ ਅਸੀਂ Grouping Selector ਦੀ ਸਹਾਇਤਾ ਨਾਲ ਇਨ੍ਹਾਂ ਸਾਰੇ ਐਲੀਮੈਂਟਸ ਨੂੰ ਇਕੋ ਜਿਹਾ ਫਾਰਮੇਟ ਕਰਨਾ ਚਾਹੁੰਦੇ ਹਾਂ ਤਾਂ ਸਾਨੂੰ ਇਸਨੂੰ ਹੇਠਾਂ ਦਿੱਤੇ ਅਨੁਸਾਰ ਲਿਖਣਾ ਪਵੇਗਾ (ਜਾਂ ਤਾਂ Internal CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਜਾਂ Extemal CSS ਦੀ ਵਰਤੋਂ ਕਰਕੇ);

h1, h2, pl {

text-align: center;

color: red;

}

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:

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

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.

The following example sets the text color of the <h1> element to blue, and the text color of the <p> element to red:


<!DOCTYPE html>
<html>
<head>
<title>Inline CSS</title>
<body>
<h1>Inline CSS</h1>
<hr>
<h1 style="color:blue;">GSSS KHOKHAR</h1>
<p style="color:red;">Sri Muktsar Sahib, 152025</p>

</body>
</html>


Output


 

Run « »