Kanngongkanngoen

CSS Basics: How to Style a Web Page | Web Development 101

💡 Key takeaways

Learn how CSS styles HTML, how selectors target elements, and how common properties control text, spacing, layout, position, and images.

In Web Development 101, Episode 3 introduces CSS (Cascading Style Sheets), the language used to style web pages. After HTML provides a page’s structure, CSS controls presentation such as colors, type size, spacing, and layout.

What is CSS?

CSS defines how HTML content is displayed. Separating presentation from content makes a site easier to manage and update. CSS can be written in a <style> element in the HTML <head> or loaded from an external stylesheet. Its basic syntax is approachable for beginners, though building polished layouts takes practice.

CSS rules: selectors and properties

A CSS rule selects one or more HTML elements and applies properties to them. A selector answers “which element?”; properties answer “what should change?” Properties can set color, text size, spacing, and layout.

Comments

Comments add notes to a stylesheet without being displayed or applied by the browser. In CSS, a comment begins with /* and ends with */, as in /* This is a comment */.

Select elements with CSS

Selectors target the HTML elements you want to style. Common options include an ID, a class, or a tag name.

W3Schools is mentioned in the source article as a place to find CSS lessons and reference material, from introductory to advanced topics.

Text styling

CSS can control how text looks and is arranged.

The CSS box model

The box model treats each HTML element as a box made up of content, padding, border, and margin.

Browser developer tools such as Inspect Element can show the styles applied to an element and let you experiment with CSS in the browser.

Display and layout

The display property controls how an element participates in layout. Common values include block, inline, inline-block, flex, and grid.

Flexbox

Flexbox is a one-dimensional CSS layout system. The flex-direction property sets the direction of flex items, such as row, row-reverse, column, or column-reverse.

Flex grow

The flex-grow property determines how a flex item expands when free space is available.

CSS Grid

Grid is a two-dimensional layout system. grid-template-columns defines the column tracks in a grid, and grid items are the elements placed inside the grid container.

Positioning elements

The position property controls how an element is placed.

Float and clear

float moves an element to the left or right and lets text or other inline content flow around it. The source introduces floats as a way to build columns. clear can prevent an element from wrapping around floated content. Modern layouts often use Flexbox or Grid instead.

Style images with CSS

CSS can style images using properties such as width, height, border-radius, and object-fit.

💬 Looking for a free financial consultation? Message us on LINE.

LINE QR code

KGK

Kanngongkanngoen Editorial Team

We create clear educational content about personal finance, investing, and debt management, with an emphasis on accuracy and transparency.