DEV Community

Cover image for 🌈 CSS for Beginners: Style Your Web Page Like a Pro (Even If You're Not One Yet)
Himanshu Bhagwat
Himanshu Bhagwat

Posted on

🌈 CSS for Beginners: Style Your Web Page Like a Pro (Even If You're Not One Yet)

  • ✨ What Is CSS? CSS stands for Cascading Style Sheets. It’s a language that tells the browser how your website should look.

HTML builds the structure of a web page (like walls in a house), and CSS adds the design (like paint, furniture, and decorations).

  • 🎨 Why Use CSS?

Makes your website look modern and clean
Lets you control colors, fonts, spacing, layout
Helps create responsive websites that look good on all devices

  • πŸ› οΈ Types of CSS

There are 3 main ways to use CSS. Let's look at each one

  1. Inline CSS – Style directly in the HTML tag

<p style="color: red; font-size: 20px;">This is red text!</p>

output:

Image description

βœ… Easy for testing
❌ Not recommended for big websites β€” it becomes hard to manage.

  1. Internal CSS – Write inside the HTML file Put your styles in a block inside the <head> tag.</li> </ol> <p><code>&lt;!DOCTYPE html&gt;<br> &lt;html&gt;<br> &lt;head&gt;<br> &lt;style&gt;<br> h1 {<br> color: blue;<br> }<br> p {<br> font-size: 18px;<br> }<br> &lt;/style&gt;<br> &lt;/head&gt;<br> &lt;body&gt;<br> &lt;h1&gt;Welcome!&lt;/h1&gt;<br> &lt;p&gt;This is styled using internal CSS.&lt;/p&gt;<br> &lt;/body&gt;<br> &lt;/html&gt;<br> </code></p> <p>output:</p> <p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkls1ya8qpmtmi7jdvxe.png" alt="Image description"/></p> <p>βœ… Great for small projects<br> ❌ Not reusable across multiple pages</p> <p>3️⃣ External CSS – The best and cleanest way.</p> <p>Write CSS in a separate file, then link to it from your HTML.<br> Step 1: HTML file index.html</p> <p>&lt;!DOCTYPE html&gt;<br> <html><br> <head><br> <link rel="stylesheet" href="style.css"><br> </head><br> <body><br> <h1>Hello!</h1><br> <p>This is styled using external CSS.</p><br> </body><br> </html></p> <p>Step 2: CSS file style.css</p> <p>body {<br> background-color: #f5f5f5;<br> font-family: Arial, sans-serif;<br> }</p> <p>h1 {<br> color: green;<br> text-align: center;<br> }</p> <p>p {<br> color: gray;<br> font-size: 18px;<br> }</p> <p>output:</p> <p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxjgixhisorjsxwcim4w.png" alt="Image description"/></p> <p>βœ… Best for real websites<br> βœ… Keeps styles organized and reusable</p> <p>πŸ–‹οΈ Written by Himanshu Bhagwat<br> πŸ“š Learning through @devsync </p>

Top comments (0)