Use the <link>
tag:
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
<link rel="stylesheet" href="/styles/site.css">
<link rel="stylesheet" href="in-same-folder.css">
</head>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<body>
</body>
</html>
Absolute path to another website’s CSS:
Relative path to your website url. ex: to access a CSS file on your localhost server at http://localhost:3000/styles/site.css
:
Absolute path imports:
Relative path imports:
div
, li
, a
, p
)<button class=“active”>
)To select a button
with class of active
:
<div id=”list-1”>
)To turn all elements background-color: red
:
[title]
matches all a elements with a title attribute)To select all elements with a title
attribute:
The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.
To select all input
tags with the type
attribute of submit
, <input type="submit">
:
class
selectorsSelect the div
with classes of box
and yellow
:
This will NOT select the div
with classes of box
and yellow
because there is a space between the class names:
Separate selectors with a comma, ,
, to make a single rule for all selectors:
Make h1
, h2
, h3
, h4
, h5
, h6
all have font-size: 14px;
:
To select all <abbr>
descendants of <p>
:
Will select all the following <abbr>
tags:
+
selector selects adjacent siblings (syntax: A + B). This means that the second element (B) directly follows the first (A), and both share the same parent.Will select h2
:
Will not select h2
:
>
selector selects nodes that are direct children of the first element (syntax: A > B). It will match every element B that is immediately nested inside an element A. This is different than the descendant selector because it selects only the direct children of an element.Will select <div class="is-active">
:
Will NOT select <div class="is-active">
:
Some examples of Pseudo-classes: - active: applies to elements like buttons when activated by a person, like when they “push down” on the button - checked: applies to radio inputs, checkbox inputs, and options in drop downs when the user has toggled it into an “on” state - disabled: applies to any disabled element, like a disabled button or input - first-child: applies to the first element among a group of sibling elements - focus: applies to elements that have the current focus, like inputs and buttons - hover: applies to elements that currently have the pointing device (cursor) directly over it (it is problematic on touchscreens because it may never match the element because there is no persistent pointing device) - invalid: applies to any form element in an invalid state due to client-side form validation - last-child: applies to the last element among a group of sibling elements not(selector): represents elements that do not match the provided selector - required: applies to form elements that are required - valid: applies to any form element in a valid state - visited: applies to anchor tags of which the user has already been to the URL that the href points to
To select <a>
on hover
pseudo-selector:
To select <a>
on hover
of a <button>
parent:
The two that you will use most often are the ::after
and the ::before
pseudo-selectors. Both of them create a pseudo-element as a child of the element to which the property applies.
Pseudo-selector example:
The same as:
font-family
- can use built-in font families or imported font families like Google Fonts
font-family: 'Times New Roman', sans-serif;
- if Times New Roman
does not exist or load properly, default to sans-serif
font-size
- can be expressed with different unit sizes like px
, em
, or rem
em
is relative font-size
to its parent, font-size: 1.4em;
is 1.4 times the font-size of its parentrem
is relative font-size
to the root html
element, font-size: 2rem;
is 2 times the font-size of the root element, html
tagfont-style
- for italicizing, font-style: italic;
font-weight
- for different units of boldness, font-weight: 700;
or font-weight: bold;
text-align
- for aligning text within an element, center
, right
, left
text-decoration
- for underlining, text-decoration: underline;
or text-decoration: none;
text-transform
- for changing the case of the content, capitalize
, undercase
, uppercase