KOSUNI KOREA
Korean News in English
Technology

CSS Basics: Understanding Selectors and Application Methods

Published October 17, 2026 · 1 views
CSS Basics: Understanding Selectors and Application Methods


[Html/CSS 강좌] 7강 CSS란? 선택자(Selector)와 적용 방법 배우기

image



What is CSS?

When you create a webpage using only HTML, the content appears but lacks any design elements.

For example, headings and paragraphs may display, but there are no colors, spacing, or visual appeal—making it look monotonous.

This is where CSS (Cascading Style Sheets) comes in—it's the technology that enhances HTML to create visually appealing layouts.

With CSS, you can:

  • Change text color

  • Modify font styles

  • Adjust background colors

  • Style buttons

  • Resize images

  • Create menu designs

  • Arrange page layouts

  • Implement responsive web design

In simple terms, if HTML is the skeleton of a house, CSS handles the wallpaper, paint, furniture, and interior decoration.


The Roles of HTML and CSS

HTML and CSS are always used together.

Their respective roles are:

HTML

CSS

Creates structure

Applies design

Writes headings, paragraphs, and images

Specifies colors, sizes, and backgrounds

Lays out content

Makes it visually appealing

You can build a webpage with HTML alone, but most real-world websites combine both HTML and CSS for the final result.


Three Ways to Apply CSS

CSS can be applied to HTML in three main ways:

1. Inline Styles

This method involves writing styles directly inside HTML tags.

<h1 style="color: blue;">
HTML Course
</h1>

While useful for quick tests, this approach is rarely used in actual projects.


2. Internal Styles

This method involves writing <style> tags inside the <head> section of HTML.

<style>

h1{
    color: blue;
}

</style>

This works for small projects but becomes harder to manage as the number of pages increases.


3. External Styles

This is the most commonly used method.

Create a separate CSS file and link it to your HTML.

<link rel="stylesheet" href="style.css">

Then, write your CSS in the style.css file:

h1{
    color: blue;
}

This is how most web development projects are structured.


CSS Basic Syntax

CSS follows this structure:

Selector {

    property: value;

}

For example:

h1 {

    color: blue;

}

This code means, "Change the text color of all h1 elements to blue."


What Are Selectors?

The most important concept in CSS is the selector.

Selectors determine which HTML elements will receive a specific design style.

Understanding selectors allows you to style exactly what you want, with precision.


Tag Selectors

This is the most basic type of selector.

p {

    color:red;

}

All <p> elements will have red text.


Class Selectors

Class selectors are the most commonly used type of selector.

HTML:

<p class="title">
HTML Course
</p>

CSS:

.title {

    color:blue;

}

Class selectors are written with a . (period) before the name.

The same class can be used across multiple elements.


ID Selectors

ID selectors target a single element on a page.

HTML:

<h1 id="main-title">
HTML
</h1>

CSS:

#main-title {

    color:green;

}

ID selectors use the # symbol.

Each ID should be unique on a single page (used only once).


Applying Styles to Multiple Elements

You can select multiple elements at once using commas.

h1,
h2,
h3 {

    color:navy;

}

All heading tags will now share the same navy blue color.


The Universal Selector

This selects all HTML elements on a page.

* {

    margin:0;

}

Developers commonly use this to remove default margins across the entire site.


A Simple Example

HTML:

<h1>HTML & CSS</h1>

<p>Learning web design.</p>

<button>Start</button>

CSS:

h1 {

    color:#154B95;

}

p {

    color:#555;

}

button {

    background:#154B95;
    color:white;

}

Even though this is simple, it creates a much more visually appealing layout compared to HTML alone.


Linking CSS Files

Typically, projects are structured like this:

project/

 ├── index.html

 └── style.css

Then link it in your HTML file:

<link rel="stylesheet" href="style.css">

Now, modifying style.css automatically updates the design of your HTML.


Common Beginner Mistakes

1. Forgetting to Link CSS Files

<link rel="stylesheet" href="style.css">

If this code is missing, your CSS won't apply.


2. Incorrect File Names

style.css

But written as:

href="styles.css"

The link won't work.


3. Using Non-Existent Selectors

title {

}

If the selector doesn't match any HTML element, nothing will change.


4. Missing Semicolons

color:red

Always include semicolons:

color:red;

This is a good habit to develop early.


Key Takeaways

Let's summarize what we've covered today:

  • CSS enhances HTML with styling and design.

  • CSS can be applied via inline, internal, or external methods.

  • External CSS is most commonly used in real projects.

  • Selectors specify which HTML elements receive styles.

  • Tag, class, and ID selectors are the most frequently used types.

  • CSS uses properties and values to define design elements.

Mastering CSS syntax and selectors gives you a solid foundation for creating diverse web designs.


In Conclusion

This lesson covered what CSS is, how to apply styles to HTML, and the crucial concept of selectors.

Starting with simple color changes, learning CSS opens up possibilities for building more sophisticated websites.

In our next lesson, we'll explore how to style fonts, colors, and backgrounds, taking your web design skills to a more professional level.

FAQ

What is the main purpose of CSS?

CSS enhances HTML by adding visual styles such as colors, fonts, and layouts to make webpages more appealing.

Which method of applying CSS is most commonly used in real projects?

External CSS files are the standard approach for real-world web development projects.

Korean Source

This article is an English localization of a Korean-language report from BlogScore. Original: [Html/CSS 강좌] 7강 CSS란? 선택자(Selector)와 적용 방법 배우기