topskill.dev
CoursesTracks
0
All courses/CSSApply CSS Three Sources
CSS Foundations
5 / 10
← CSS
○CSS Rule Style an Exhibit Card○Write Your First CSS Rule○CSS Selectors Target Exhibit Details○Target Exhibit Details●Apply CSS Three Sources○Apply CSS Three Ways○Specificity Resolve a Style Conflict○Resolve Specificity○Inheritance and the cascade✦Module Quiz
○Color Palette○Color Palette○Background Layer○Background Layer○Type Rhythm○Type Rhythm○Borders and Shadows○Borders and Shadows✦Module Quiz
○Box Model Seed Packet Card○Space a Seed Packet○Display Swap Table Labels○Arrange Swap Table Labels○Positioning Pickup Pin○Pin the Pickup Location○Sizing and Overflow○Size a Seed-Swap Notice○Sticky scroll headings✦Module Quiz
○Advanced Selectors Book Cart Sign○Target a Book Cart Sign○Pseudo-Classes Night Cart States○Style Night Cart States○Pseudo-Elements○Add a Book-Quote Mark✦Module Quiz
○Lantern Market navigation○Lantern Market navigation✦Module Quiz
○Community garden request card○Community garden request card✦Module Quiz
○Flex Direction○Flex Direction○Main-Axis Spacing○Main-Axis Spacing○Cross-Axis Alignment○Cross-Axis Alignment○Wrapping and Flex Items○Wrapping and Flex Items○Flexbox Navigation○Flexbox Navigation✦Module Quiz
○Grid Tracks○Grid Tracks○Grid Gaps○Grid Gaps○Grid Placement○Grid Placement○Responsive Grid○Responsive Grid✦Module Quiz
○River radio schedule○Harbor radio schedule✦Module Quiz
○Field note color system○Field note color system○Transforms○Rotate a Field Note○Resilient styles✦Module Quiz
○Kite festival signal○Garden festival signal✦Module Quiz
○Garden forecast○Harbor forecast○Fluid sizing○Fluid weather bulletin○Images that fit✦Module Quiz
○Seed inventory table○Tool checkout table✦Module Quiz
○Community maker profile○Maker profile sheet✦Module Quiz

Apply CSS Three Sources

Where CSS can live

The museum inherited a page with CSS in three places. Each source has a different job here so you can find it easily. All three use the same property-and-value syntax.

Inside an element

In index.html, the heading has style="color: #7a1fa2;". This is inline CSS: declarations go directly in the element's style attribute. No selector or braces are needed because that element is already the target.

In the document head

The <style> element in <head> contains p { font-size: 18px; }. This is internal CSS. It uses a selector and can style matching elements throughout this document. font-size sets the text size; px means CSS pixels.

In a separate file

The body background rule lives in style.css. The head contains <link rel="stylesheet" href="style.css"> to connect that external stylesheet. rel identifies a stylesheet and href names its location. Several HTML pages can link to the same CSS file.

The course preview loads the stylesheet tab automatically, so removing the link here does not demonstrate a missing-link failure. A standalone HTML page still needs the connection.

Compare the sources

Run: the heading is purple, the paragraph is 18px, and the page is pale blue. Change the internal font-size to 24px and Run again. Only the paragraph should grow. Restore 18px before the exercise.

Hint 1
1 / 1
HINT 1

This completed example is for reading and previewing before the exercise.

Files
  • ⋄index.html
  • ⋄style.css
Loading editor…