Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Styling a Simple Webpage with Inline, Internal, and External CSS
📖 Scenario: You are creating a simple webpage for a small bakery. You want to style the page using three different CSS methods: inline styles, internal styles, and external styles. This will help you understand how CSS can be applied in different ways.
🎯 Goal: Build a webpage with a heading, a paragraph, and a button. Style the heading with inline CSS, the paragraph with internal CSS, and the button with external CSS.
📋 What You'll Learn
Create an HTML file with a heading, paragraph, and button
Use inline CSS to color the heading text red
Use internal CSS to make the paragraph text blue and italic
Use external CSS to style the button with a green background and white text
Link the external CSS file correctly in the HTML
💡 Why This Matters
🌍 Real World
Web developers often use inline, internal, and external CSS to style webpages depending on the situation. Understanding these methods helps in maintaining and organizing styles effectively.
💼 Career
Knowing how to apply CSS in different ways is essential for frontend web development jobs, enabling you to create visually appealing and well-structured websites.
Progress0 / 4 steps
1
Create the basic HTML structure with content
Create an HTML file with a <h1> heading that says Welcome to Sweet Bakery, a <p> paragraph that says Freshly baked goods every day!, and a <button> with the text Order Now.
CSS
Hint
Start by writing the HTML tags for heading, paragraph, and button with the exact text.
2
Add inline CSS to style the heading
Add inline CSS to the <h1> tag to make its text color red using the style attribute.
CSS
Hint
Use the style attribute inside the <h1> tag to set color: red;.
3
Add internal CSS to style the paragraph
Inside the <head> section, add a <style> block. Inside it, write CSS to make the <p> text color blue and italic using the font-style property.
CSS
Hint
Inside the <style> tags, write CSS for p selector with color: blue; and font-style: italic;.
4
Create external CSS file and link it to style the button
Create an external CSS file named styles.css with CSS to style the button element. Set the button background color to green and text color to white. Then, link this CSS file inside the <head> of your HTML using a <link> tag.
CSS
Hint
Create a file named styles.css with CSS for button to have background-color: green; and color: white;. Then add a <link> tag in the <head> to connect it.
Practice
(1/5)
1. Which type of CSS is written directly inside an HTML tag using the style attribute?
easy
A. Internal CSS
B. Inline CSS
C. External CSS
D. Embedded CSS
Solution
Step 1: Understand CSS placement types
Inline CSS is applied directly inside an HTML element using the style attribute.
Step 2: Match the description to the type
Since the question asks for CSS inside the tag, this matches Inline CSS.
Final Answer:
Inline CSS -> Option B
Quick Check:
CSS inside tag = Inline CSS [OK]
Hint: Style attribute inside tag means Inline CSS [OK]
Common Mistakes:
Confusing internal CSS with inline CSS
Thinking external CSS is inside the tag
Mixing embedded CSS term with inline
2. Which of the following is the correct way to include internal CSS in an HTML document?
easy
A. inside the <head> section
B. inside the <body> section
C. inside the <head> section
D.
Solution
Step 1: Identify internal CSS syntax
Internal CSS uses a <style> tag placed inside the <head> section.
Step 2: Check each option
<style> p { color: blue; } </style> inside the <head> section correctly uses <style> with CSS inside <head>. Others misuse tags or placement.
Final Answer:
<style> p { color: blue; } </style> inside the <head> section -> Option A
Quick Check:
Internal CSS = <style> in <head> [OK]
Hint: Internal CSS uses <style> in the head section [OK]
Common Mistakes:
Placing <link> inside body for internal CSS
Using <script> tag for CSS
Using <style> with src attribute
3. What will be the color of the paragraph text in this HTML snippet?