Know and understand characteristics of a style and a class including the difference between them

Resources | Subject Notes | Information Communication Technology ICT

21 Website Authoring: Styles and Classes

21 Website Authoring: Styles and Classes

Introduction

In web development, both styles and classes are fundamental concepts for controlling the visual presentation of a website. Understanding their characteristics and the differences between them is crucial for creating well-structured and maintainable web pages.

Classes

A class is a naming convention used in HTML to group elements that share common characteristics or require the same styling. Classes are defined within the HTML code using the class attribute.

Characteristics of a Class:

  • Classes are applied directly to individual HTML elements.
  • Multiple elements can belong to the same class.
  • Classes are used to apply consistent styling to multiple elements.
  • Classes can be reused throughout a website to maintain a uniform look and feel.

Example:

Suggested diagram: An HTML element with the class 'highlighted'.

This paragraph will be highlighted.

Styles

Styles define the visual appearance of HTML elements. Styles can be applied in three main ways:

  • Inline Styles: Styles are applied directly to an HTML element using the style attribute.
  • Internal Styles: Styles are defined within a