What is CSS?: CSS stands for cascading stylesheets. It is a language used for describing the look and formatting of a document in a markup language such as HTML or XML. It is used to control the presentation and layout of the website. Overall, CSS plays a crucial role in the development of modern websites, making them visually appealing, responsive, accessible, and optimized for search engines.
How to add CSS to HTML? There are three ways to add CSS to HTML:
(1) Inline Styling: Inline Styling is a technique which allows us to apply style directly to an HTML element using the style attribute. It is called "Inline" because the style is applied directly to the element in the same line of HTML code. It has the highest specificity, Which means it overrides any other styles that are applied to the same element.
(2) Internal Styling: In this method, we add the style attribute to the <head> section of an HTML document and the style elements contain a list of CSS rules that specify the styles for the element on the page.
(3) External Styling: In this method, CSS is added to a separate file with a .css extension, and then linked to the HTML document using the <link> tag in the <head> section of the HTML document.
It is generally recommended to use the external CSS method for larger websites with multiple pages, as it allows for greater flexibility and consistency across the entire site. The internal and inline methods can be useful for smaller projects or for making quick, one-off changes to specific elements.