Style CSSIntroductionWhen we are trying to build a web page without HTML, it is not possible. With the help of HTML, we can create page content, including headings, paragraphs, images, tables, forms, and lists inside our web page. But only with HTML can we not create a beautiful and responsive webpage. To achieve this, we have to take the help of CSS. What is CSS?CSS stands for Cascading Style Sheet. With the help of Cascading Style Sheet(CSS), we can provide all the style properties to the web page. With the help of CSS, we can set the background color, font-size, font-family, color, … etc., properties of elements on a web page. The CSS also determines how all the content should be displayed on the web page. How to Add CSS to HTMLWe can add CSS inside the HTML in three ways. These are as follows.
Inline CSSIn inline CSS, we have to provide the required CSS properties inside the opening tag in the body tag. This is known as inline CSS. We can perform this with the help of style attributes. How to Add Inline CSS to HTML Inline CSS is also known as an embedded stylesheet. We must follow the syntax below to add the CSS in HTML. The inline CSS can override any other applied CSS because it is close to the HTML tag. Example: Output Explanation: We have taken inline CSS to apply different styles to the h1, p, and div elements in the above code. Internal or Embedded CSSWhen there is a single HTML file, and we have to provide the property to it, we have to go for Internal or Embedded CSS. We can write the CSS property inside the head tag in this CSS. We can write the CSS property with the help of <style> tag. How to Add Internal CSS to HTML We can write the internal CSS inside the head tag with the <style> tag. We can write the internal CSS with the help of the below syntax. Using the internal css is the better practice in comparison to inline CSS. With the help of internal CSS, we can provide the style property to the group of elements at once. We can separate the CSS and HTML, but we have to write these in one document. All of our code is present in one file. However, taking internal CSS is not a good practice when we have more than one HTML page. In that situation, we have to go for external CSS. Example: |