Core Concept of Applying Internal CSS in HTML
When the requirement is to add CSS (cascading style sheets) inside the HTML file, then with the help of the <style> tag, the CSS is added internally or embedded inside the HTML page.
In this program, the style tag is used inside the <head> tag.
Why is it used?
- When you need only one HTML page and don’t want to create an external CSS file.
- Cleaner than inline CSS, so code maintenance is easier compared to inline CSS.
Real-life Applications
- Email Templates: In email templates like newsletters or promotional emails, typically internal and inline CSS is used.
- Single-page landing pages or demos: To test a quick landing page or web app.
- Online Code Editors & Tutorials: To test the code inside the online editors like MDN or online HTML viewer the inline style is the good choice.
Key Benefits of this Program
- Everything in a single file: All the HTML and CSS code exists in a single file.
- Clean Code: Better than inline CSS and easy to maintain.
Limitations of this Program
- Less Reusability: Because the code is added inside the HTML, common CSS code cannot be shared among multiple files. So, you need to repeat the code.
- Heavy File Size: Due to CSS inside the HTML, the file size will be large. And the page load speed will be slow. This is not good for SEO.
Alternate Way
You can use the external CSS approach, which can reduce the file size, no need to duplicate the code, and improve the page speed which is good for SEO.
