EDITORCLASSBLOGLOGINOpkleOpkle, the Editor for CreatorsInfiniteExpression,In New Forms.New ContentOpkle makes an editor so anyone can build for the web without code, and share it anywhere.Blending text and screen, we build tools that make the web about imagination, not code.The body Tag: Where Documents Meet Readershtml6Why Is CSS Separate from HTML?css1CSS Selectors: Finding What You Want to Stylecss2How Does CSS Syntax Meet HTML?css3The CSS Box Model: How a Tag Gets Its Placecss414151617183 How Does CSS Syntax Meet HTML?

Open CSS for the first time and you meet short English words followed by colons, semicolons and curly braces. This form, which looks like `p { color: …; }`, is unfamiliar, but what it wants to say is simple: “Pick the paragraph called p, and show its text in this color.” CSS does not explain things in long sentences. It is a language that writes down, in a fixed order, who to pick and how to make them look.

In the earlier article, we learned that a selector finds what to style. Now it is time to look at what promises that selector hands to the things it picked. A CSS rule begins with a selector and writes several promises inside curly braces. Each promise divides into “what to change” and “what to change it to.” And only when this rule is connected to an HTML document does it begin to work on the screen.

CSS is not always written directly inside HTML tags. Usually the styling rules are gathered in a separate CSS file, and the HTML loads that file in its head. Depending on need, you can also write them in a style tag inside one document, or attach them with a style attribute to one very special element. Understand these three roads, and “where do you write CSS, and where does HTML meet it?” falls into place at once.

1.We learn the order of selector, curly braces, property and value that make up a CSS rule.

2.We look at why the colon and the semicolon separate several promises.

3.We understand three ways to connect to HTML: an external CSS file, a style tag and a style attribute.

4.We sum up the flow by which a browser meets HTML and CSS and builds the screen.

One Line of CSS Is Made of a Choice and a Promise

The most basic CSS rule looks like `selector { property: value; }`. As we learned before, the selector is the word that finds what to style. The curly braces are a box holding the promises to be handed to that target. And the `property: value;` inside the box is one promise. By fixing these four places, CSS grammar lets you make clear instructions from just a few short symbols.

For example, read the rule `p { color: navy; }` slowly. `p` picks the paragraph tag. Inside `{ }` goes what applies only to the selected paragraphs. `color` is the property saying you will speak about the color of letters, and `navy` is the value that sets that color to a deep navy blue. The semicolon at the end tells you this promise ends here.

This form is also a way of dividing roles with HTML. The p tag in HTML leaves the meaning that its content is a paragraph. The `p` selector in CSS reads that meaning and goes to find the paragraphs. After that, the promise called color decides how the paragraphs look. The relationship in which HTML says “who it is” and CSS says “how it looks” is present even in the smallest CSS rule.

Reading a CSS Rule in Four Pieces

Selector: Picks what to style. Examples are `p`, `.notice` and `#signup`.

Curly braces `{ }`: A box that holds the promises to apply to the picked target.

Property: Says what to decide. For example, color is the property for text color.

Value: Says what to set that property to. For example, navy is a color value.

The Colon and the Semicolon Divide Promises Clearly

Inside CSS's curly braces you needn't write only one promise. After setting the text color, you can also set the letter size, line spacing and paragraph margins together. Here the colon joins a property to its value, and the semicolon separates one promise from the next. It is similar to how a colon in a sentence signals, “Now I will state what is explained,” and a period ends one sentence.

For instance, writing `p { color: navy; line-height: 1.7; }` holds two promises. The first is the paragraph's text color, and the second is the spacing between lines. Both apply to the same p selector but are different properties. Without the semicolon, the browser would find it hard to judge where the first value ends and the next promise begins.

CSS can be written on one line, or split with a line for each promise. The browser reads grammar symbols as more important than line breaks. But for a person to reread and fix it later, it is better to write each property on a new line. CSS is a set of rules for the computer to read, but also a document that my future self will meet again and edit.

The CSS standard explains that promises made of a name, a colon and a value go inside the curly braces after a selector, and that these promises are separated with semicolons. At first, just telling these four symbols apart accurately is enough to read CSS's basic grammar. The curly braces mark the boundary of a rule, the colon the link between question and answer, and the semicolon the end of one promise.

Properties and Values Say “What” and “How” Separately

A CSS property is the name of an item you can adjust on screen. color handles text color, font-size handles letter size, margin handles outer spacing, and background-color handles background color. When you look at a property, it helps to think “which part is CSS trying to change?” rather than translating each English word. A property is like the title of a question.

A value is the concrete answer given to that question. Put navy in color and you get navy blue, put 18px in font-size and you get an 18-pixel size, and put 1rem in margin and you mean spacing by a set standard. Even the same property can create very different looks depending on its value. Learning CSS is less about memorizing a list of properties than a process of gradually getting used to what kinds of values each property accepts.

It is worth remembering here that HTML attributes and CSS properties, though similarly named, do different work. HTML's `href` and `src` are attributes that write the information and addresses a tag needs. CSS's color and margin are properties that decide the presentation of an element already selected. Both are called “attributes” or “properties,” but HTML handles a document's meaning and connections, while CSS handles its look.

Questions for Reading Properties and Values

`color: navy;` is the question and answer, “What should the text color be?”

`font-size: 18px;` is the question and answer, “How large should the letters be shown?”

`margin: 1rem;` is the question and answer, “How much room to breathe should there be outside the element?”

Under a single selector you can write several different properties and values in a row.

The Most Common Connection: Loading a CSS File in the Head

The most common way to connect CSS to HTML is to make a separate `.css` file. For example, you gather the CSS rules in a file called `style.css`, and write `〈link rel="stylesheet" href="style.css"〉` in the HTML document's head. The link tag's rel tells how this file relates to the document, and stylesheet means “this is a file of rules that decide the look.” The href points to the address where that file is.

When the browser, reading the HTML head, meets this link, it fetches style.css. It compares the selectors written inside with the elements of the HTML document, and applies the CSS rules to the matching elements. The HTML file takes charge of the structure of the writing and the CSS file of the promises of presentation, with the link tag laying a bridge between them.

Splitting into an external file is especially good because many pages can share the same CSS. If you want every article on a site to have the same title typeface and basic margins, you needn't repeat the same rules in each HTML file. Fix the one file, style.css, and the look of the many connected pages changes together. It is also the approach that best fits CSS's original idea of managing documents and design separately.

Writing Inside One Page: The `style` Tag in the Head

For a very short document, or styling needed only on that page, you can place a `〈style〉` tag in the head and write CSS rules directly between its tags. Inside the style tag go complete CSS rules with a selector and curly braces, like `p { color: navy; }`. CSS stays together with the HTML document, but is not mixed into the body's text; it is arranged in the head, the preparation room.

The style tag doesn't have to go find an external file, so it can be convenient for a small experiment on one page or a special document for printing. But if you need to use the same rule on several pages, you must fix every document's style tag. So it is natural to connect an external CSS file for shared design, and to consider the style tag when writing rules that only that document truly needs.

The text inside a style tag does not appear on screen like the sentences of the body. This is because the CSS rules themselves are not body text for readers to read but promises the browser uses to prepare the screen. The reason we said earlier that the head is an invisible preparation room shows up again in the place where CSS is connected.

Writing on One Element Only: HTML's `style` Attribute

The last method is to attach a style attribute to the HTML tag itself. You write it right inside a paragraph's opening tag, like `〈p style="color: navy;"〉`. This way you don't need a selector, because you are already pointing directly at that one tag. You don't use curly braces either; you write only the promise of property and value, like `color: navy;`.

It can look convenient when one special element needs to look different for a moment. But as this approach multiplies, a document's structure and its styling rules begin to mix again inside HTML tags. It becomes hard to reuse the same expression elsewhere, and hard to change the design all at once later. So it is better to keep the styling of ordinary pages in an external CSS file or the head's style tag, and to use the style attribute carefully, only for an exception needed by truly one element.

All three methods can apply CSS to HTML, but they differ in where the rules sit. An external file is closer to a shared promise across many documents, a style tag to one document's promise, and a style attribute to a memo of exception for one element. Knowing this division makes it easier each time to judge where CSS should be.

Three Roads by Which CSS Reaches HTML

External CSS file: Connected with `〈link rel="stylesheet" href="style.css"〉` in the head. Suited to shared design across many pages.

style tag: Write CSS rules inside `〈style〉…〈/style〉` in the head. Usable for rules needed by only one document.

style attribute: Write only declarations inside the tag, like `〈p style="color: navy;"〉`. Suited to a rare exception for one element.

The Browser Reads HTML's Structure and Applies CSS's Promises

When a browser opens a web page, it first reads the HTML and grasps its structure: titles, paragraphs, links, images. When it meets a CSS file or a style tag in the head, it reads the CSS rules too. Then it checks which HTML elements each CSS selector picks, and applies the presentation written as properties and values to the matching elements. So even though HTML and CSS are written separately, they meet as one page on the screen.

Knowing this flow gives you a sense of where to look even when CSS isn't being applied. You can check in turn whether the CSS file's address matches HTML's link tag, whether the selector actually picks a real HTML element, and whether the colon and semicolon between property and value are in place. When you run into trouble, instead of suspecting all the code at once, you can check separately: “Is it connected? Did it select? Did I write the promise correctly?”

Next, we can look further at which promise remains when different CSS rules pick the same element, and why the word “Cascading” is in CSS's name. For now, it is enough to understand what shape one rule takes and how it reaches HTML. CSS's symbols are not a complicated cipher, but short, clear sentences that hand an HTML document the look it should show.

Key Takeaways

A basic CSS rule is read in the flow of `selector { property: value; }`.

The selector picks the target, the property says what to change, and the value says how to change it.

The colon joins a property and a value, and the semicolon separates several promises.

CSS can be applied by connecting an external file with link, or with the style tag in the head and the style attribute in HTML.

The browser reads the HTML structure and the CSS rules together to build the screen.

PreviousListNext
CopyrightAll design outputs and videos on this website are copyrighted by Abstract Cloud and protected under copyright law and related regulations. All content, including web, video, text, cover, and interior designs, is the property of the copyright holder. Unauthorized reproduction, distribution, creation of derivative works, or online sharing without prior consent is strictly prohibited. Violations may result in civil and criminal liability under copyright law. Legitimate purchases and copyright protection preserve creators' rights and fuel better works in return.Copyright: Abstract Cloud | CEO: Bae Changkyu
© Abstract Cloud. All Rights Reserved.
HOMEFAQTerms of ServicePrivacy PolicyRefund PolicySeller Informationhelp@opkle.app
+82 10-2747-3403
Business Name :Abstract Cloud  |  CEO :Bae ChangkyuBusiness Registration Number :249-74-00533E-commerce Registration Number :2025-Uijeongbu Songsan-0634Address :402, 108-dong, 49 Buyong-ro, Uijeongbu-si, Gyeonggi-do, Republic of KoreaAll content, designs, and source code on this website
are copyrighted by Opkle.
Opkle