🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS in HTML

Style your web pages. Learn to use Inline, Internal, and External CSS methods to bring your HTML to life.

style.html
<!-- Inline Style -->
<h1
style="color: red;"
>Hello</h1>
<!-- Result: -->
Hello
🎨
index.html
1 / 10
🎨

Tutor:HTML defines the structure, but without CSS, it's just plain text. Let's explore how to add style to our skeleton.


CSS Mastery

Unlock nodes by learning how to inject styles into HTML.

Concept 1: What is CSS?

CSS (Cascading Style Sheets) describes how HTML elements are to be displayed on screen, paper, or in other media. It saves a lot of work and can control the layout of multiple web pages all at once.

System Check

What is the primary role of CSS?


Community Styles

Share Your Design

Created a cool CSS layout? Share your snippets with the community.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS in HTML

Author

Pascual Vila

Frontend Instructor.

CSS (Cascading Style Sheets) is what gives life to HTML. While HTML provides the structure, CSS provides the visual layout, colors, and typography. There are three primary ways to include CSS in your HTML documents.

1. Inline CSS

Inline styles are defined within the HTML style attribute of a specific element.
<h1 style="color: blue;">Hello</h1>
Pros: Quick fixes, high specificity.
Cons: Hard to maintain, repetitive, no separation of concerns.

2. Internal CSS

Internal styles are defined within a <style> element, typically inside the <head> section.
Pros: Affects the whole page, no external request needed.
Cons: Styles are limited to one page only.

3. External CSS

External styles are defined in a separate .css file and linked using the <link> tag.
<link rel="stylesheet" href="styles.css">
Pros: Best for maintenance, allows caching, separates structure from design completely.

Best Practices

Always prefer External CSS for production websites. Use Internal CSS for single-page demos or emails, and avoid Inline CSS unless absolutely necessary (e.g., dynamic styles via JavaScript).

CSS in HTML Glossary

Inline Style
CSS written directly inside an HTML tag using the style attribute.
Internal Style
CSS written inside a <style> block within the HTML document's head.
External Style
CSS written in a separate file (e.g., style.css) and linked via the <link> tag.
Selector
A pattern used to select the element(s) you want to style (e.g., h1, .class-name, #id).
Property & Value
The stylistic characteristic (property) and the setting (value). Example: color: red;.