Introduction to CSS || HTML/CSS || BCIS Notes

Introduction to CSS || HTML/CSS || BCIS Notes

Introduction to CSS

Cascading Style Sheets (CSS)  is used to format the layout of a webpage.

While HTML is used to structure a web document (defining things like headlines and paragraphs and allowing you to embed images, video, and other media), it comes through and specifies your document’s style—page layouts, colors, and fonts.

With this, you can control the color, font, size of text, 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!

It can be added to HTML documents in 3 ways:

  1. Inline – by using the style attribute inside HTML elements
  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 CSS

An inline is used to apply a unique style to a single HTML element.

It uses the style the 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:

Inline CSS

2. Internal CSS

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.

The following example sets the text color of ALL the <h1> elements (on that page) to blue, and the text color of ALL the <p> elements to red. In addition, the page will be displayed with a “powderblue” background color:

Internal CSS

3. External CSS

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

The external style sheet can be written in any text editor. The file must not contain any HTML code and must be saved with a .css extension.

To use an external style sheet, add a link to it in the <head> section of each HTML page:

External CSS

Generally speaking, external style sheets are the most efficient method (it’s easier to keep track of and implement a site’s style from a dedicated file), while internal style sheets and inline style can be used on a case by case basis when individual style changes need to be made.

If you liked our content Introduction to CSS, then Introduction to HTML 

Be the first to comment

Leave a Reply

Your email address will not be published.


*