The HTML Tag: style is used to define the style information for an HTML document. It is used to add styles to HTML elements such as text, images, and tables. The style information can be added to the HTML document in three ways: inline, internal, and external. The inline style is added directly to the HTML element, the internal style is added to the head section of the HTML document, and the external style is added to a separate CSS file.
The HTML Tag: style is a powerful tool for web developers to add styles to their HTML documents. It allows developers to control the appearance of their web pages and create a consistent look and feel across their website. The style information can be used to change the font, color, size, and layout of HTML elements. The style information can also be used to add animations, transitions, and other effects to HTML elements.
The HTML Tag: style is used in conjunction with CSS (Cascading Style Sheets) to create visually appealing web pages. CSS is a separate language that is used to define the style information for HTML elements. The HTML Tag: style is used to link the HTML document to the CSS file. This allows the HTML document to access the style information defined in the CSS file.
Inline Style:
To add an inline style to an HTML element, use the style attribute. The style attribute should be added to the opening tag of the HTML element. The value of the style attribute should be a CSS style rule.
<p style="color: red; font-size: 20px;">This is a red paragraph with font size 20px.</p>
Internal Style:
To add an internal style to an HTML document, use the style tag. The style tag should be added to the head section of the HTML document. The value of the style tag should be a CSS style rule.
<head> <style> p { color: red; font-size: 20px; } </style> </head> <body> <p>This is a red paragraph with font size 20px.</p> </body>
External Style:
To add an external style to an HTML document, use the link tag. The link tag should be added to the head section of the HTML document. The href attribute of the link tag should be set to the location of the CSS file.
<head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <p>This is a red paragraph with font size 20px.</p> </body>