Key Concepts

Review core concepts you need to learn to master this subject

<link> Link Element

<!-- How to link an external stylesheet with href, rel, and type attributes --> <link href="./path/to/stylesheet/style.css" rel="stylesheet" type="text/css">

The <link> element is used to link HTML documents to external resources like CSS files. It commonly uses:

  • href attribute to specify the URL to the external resource
  • rel attribute to specify the relationship of the linked document to the current document
  • type attribute to define the type of content being linked
Arrow Chevron Left Icon
CSS Setup and Selectors
Lesson 1 of 2
Arrow Chevron Right Icon
  1. 1
    The basic structure of every web page, HTML, is very plain on its own. The beautiful websites that you see across the internet are styled with a variety of tools, including CSS. CSS, or Cascad…
  2. 2
    Although CSS is a different language than HTML, it’s possible to write CSS code directly within HTML code using inline styles. To style an HTML element, you can add the style attribute directly…
  3. 3
    Inline styles are a fast way of styling HTML, but they also have limitations. If you wanted to style, for example, multiple elements, you would have to add inline styling to each element manually…
  4. 4
    Developers avoid mixing code by storing HTML and CSS code in separate files (HTML files contain only HTML code, and CSS files contain only CSS code). You can create a CSS file by using the **.css…
  5. 5
    Perfect! We successfully separated structure (HTML) from styling (CSS), but the web page still looks bland. Why? When HTML and CSS code are in separate files, the files must be linked. Otherwise,…
  6. 6
    CSS can select HTML elements by using an element’s tag name. A tag name is the word (or character) between HTML angle brackets. For example, in HTML, the tag for a paragraph element is . The CSS …
  7. 7
    CSS is not limited to selecting elements by tag name. HTML elements can have more than just a tag name; they can also have attributes. One common attribute is the class attribute. It’s also possi…
  8. 8
    We can use CSS to select an HTML element’s class attribute by name. So far, we’ve selected elements using only one class name per element. If every HTML element had a single class, all the style …
  9. 9
    If an HTML element needs to be styled uniquely (no matter what classes are applied to the element), we can add an ID to the element. To add an ID to an element, the element needs an id attribute: …
  10. 10
    CSS can select HTML elements by their tag, class, and ID. CSS classes and IDs have different purposes, which can affect which one you use to style HTML elements. CSS classes are meant to be reused…
  11. 11
    Specificity is the order by which the browser decides which CSS styles will be displayed. A best practice in CSS is to style elements while using the lowest degree of specificity, so that if an ele…
  12. 12
    When writing CSS rules, it’s possible to require an HTML element to have two or more CSS selectors at the same time. This is done by combining multiple selectors, which we will refer to as chaini…
  13. 13
    In addition to chaining selectors to select elements, CSS also supports selecting elements that are nested within other HTML elements. For instance, consider the following HTML: … ….
  14. 14
    In the last exercise, instead of selecting all h5 elements, you selected only the h5 elements nested inside the .description elements. This CSS selector was more specific than writing only h5. Addi…
  15. 15
    In order to make CSS more concise, it’s possible to add CSS styles to multiple CSS selectors all at once. This prevents writing repetitive code. For instance, the following code has repetitive st…
  16. 16
    Throughout this lesson, you learned how to select HTML elements with CSS and apply styles to them. Let’s review what you learned: - CSS can change the look of HTML elements. In order to do this, …
  1. 1
    In this lesson, you’ll learn the basic structure and syntax of CSS so that you can start styling web page elements.
  2. 2
    To style an HTML element using CSS, you need to write a CSS declaration inside the body of a CSS selector. h1 { color: blue; } The example above selects the element. Inside of the selector’s…
  3. 3
    If you’ve ever used a formatted word processor, chances are that you probably also used a feature that allowed you change the font you were typing in. Font refers to the technical term typeface , …
  4. 4
    Changing the typeface isn’t the only way to customize text. Often times, different sections of a web page are highlighted by modifying the font size. To change the size of text on your web page…
  5. 5
    In CSS, the font-weight property controls how bold or thin text appears. p { font-weight: bold; } In the example above, all paragraphs on the web page would appear bolded. The font-weight …
  6. 6
    No matter how much styling is applied to text (typeface, size, weight, etc.), text always appears on the left side of the browser. To align text we can use the text-align property. The text-align…
  7. 7
    Before discussing the specifics of color, it’s important to make two distinctions about color. Color can affect the following design aspects: - Foreground color - Background color Foreground co…
  8. 8
    Opacity is the measure of how transparent an element is. It’s measured from 0 to 1, with 1 representing 100%, or fully visible and opaque, and 0 representing 0%, or fully invisible. Opacity can b…
  9. 9
    CSS has the ability to change the background of an element. One option is to make the background of an element an image. This is done through the CSS property background-image. Its syntax looks lik…
  10. 10
    !important can be applied to specific attributes instead of full rules. It will override any style no matter how specific it is. As a result, it should almost never be used. Once !important is us…
  11. 11
    Incredible work! You used CSS to alter text and images throughout a website. Throughout this lesson, you learned concepts including: - CSS declarations are structured into property and value pair…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo