Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML CSS Use
CSS Use

CSS is used in HTML to change elements styles like color, size, fonts etc. CSS is inserted in three ways within HTML page.


  • External CSS
  • Internal CSS
  • Inline CSS
External CSS

External CSS is inserted in HTML page by using <link> element. The benifit of using external CSS is it separate HTML form CSS and makes code easy to understand and you can apply same css file to multiple pages.

Syntax

<link rel=stylesheet type=text/css href=css file />


You can insert any number of stylesheets using link element.


Note:

You can give any name to css file but do not forget to give .css extension after css file name


Example

In external css file p element is styled

Internal CSS

Internal CSS is inserted in HTML page by using <style> element, if your web page has different styles or you have wanrt to apply styles to single page then internal CSS is good.

Syntax

<style>
CSS styles
</style>


You can use any number of stylesheets using link and style elements.


Note:

You can give any name to css file but do not forget to give .css extension after css file name


Example

Internal CSS File

Inline CSS

Inline CSS is used within a single element by using <style> element in inline

Syntax

<tag style=CSS styles>content</tag>


You can apply inline css to any element but single element have only single inline css.


Note:

You can give any name to css file but do not forget to give .css extension after css file name


Example

Inline CSS styles


Practice Task

Open notepad or any other text editor, follow the following points.


  • Create any HTML element
  • Use internal css
  • Assign element an id with name internal-css
  • Inside id put color property with orange value
  • also put font size property with value 20px

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

Paragraph with internal css file


Don't forget that you can use multiple stylesheets in single HTML page.