Introduction to CSS for Designers
Explore basic CSS styling techniques
Some designers still find CSS daunting and challenging to learn. The good thing is that you don't have to learn everything to master CSS and create appealing interfaces. With CSS knowledge, you have much more control over your designs — you can implement them exactly how you intend them to look. Plus, you don't need a developer to troubleshoot an issue.
Even though HTML and CSS are separate languages, you never use one without the other. If you haven't already been through our HTML for Designers course, we recommend you start with an intro to HTML before learning CSS.
To better understand what
For example, imagine you're a designer, and the client sends you a task: "Make the <h1>
red." In an hour, they send you an update: "Make the <h1>
blue." What color will you set for the headline? The last word has a bigger weight. The headline should be blue. Yes, it has lower precedence, but that's how CSS works.
Let's say that you composed a style sheet, and it's ready to go. How can you apply
- External stylesheet: You add a standalone CSS file from an external resource. This one file can change the look of the entire website.
- Internal stylesheet: You add the
<style>
element in the head section of an HTML file and apply them only to this particular web page. - Inline styling: Inline styling applies unique rules to only one component using the
<style>
attribute.
The default
Default style varies slightly from browser to browser but generally includes some basic settings for buttons, links, padding, margin, borders, different headings, and other useful things. If you want to see browser defaults to make sure they'll comply with your cascading sheets, you can find them online, e.g., Chrome default styles.[1] Some developers use special tools like Meyerweb's CSS reset or Normalize.css to remove those defaults.
You can apply a wide range of formatting properties to text with color
background-color
property, developers use
In this example, we inserted styles with an external stylesheet method that separates CSS code from HTML, by linking the .css file inside the <link>
element.
You can either use a common padding
padding-top
, padding-right
, padding-bottom
, and padding-left
properties.
Unlike
You can either select a shorthand margin
margin-top
, margin-right
, margin-bottom
, and margin-left
).
For horizontal text alignment, developers use the text-align
center
, left
, right
, or justify
.
Like in the example, centered alignment is a good fit for titles and short copy, while the left alignment is the most popular type for large blocks of text.
<h1>
...<h6>
) and paragraphs (<p>
) and specify their values according to their priority on a
There are two ways to define the font-size
Conversely, the relative size allows you to change the font size in browsers. It's the best choice for large body text pieces, so users can change it to fit their needs. Developers usually use pixels to specify the absolute font-size
value and em
for relative font sizes.