This is an abbreviated list of what I believe are the core css properties you should know. There are even more than this. You can see more properties along with detailed examples with this CSS property reference offered from W3C Schools.
Remember, to tell the browser what HTML element to apply a property to, you use selectors. Learn more about selectors from these class slides.
If you need a reference for HTML tags, see the Core HTML Tags page
.red-example { */predefined color*/ color: red; /*hex code */ color: #00ff00; /*Red, Green, Blue*/ color: rgb(0,0,255); /*RGB with alpha (opacity) */ color: rgba(0,0,255, 1); /*Hue, Saturation, Brightness*/ color: hsl(0, 100%, 50%) }
.font-size-example { /* With pixels */ font-size: 40px; /*with rem */ font-size: 4rem }
.font-family-example { font-family: 'Times New Roman', serif; }
.font-weight-example { font-weight: bold; /* or */ font-weight: 700; }
.list-style-example { list-style: square; }
.line-height-example { line-height: 1.5; }
.text-align-example { text-align: right; }
.text-decoration-example { text-decoration: underline dotted red; }
.display-examples { display: block; display: inline; display: inline-block; display: flex; display: none; }
Display is an important property determining an element's layout and behavior. The main thing you want to keep in mind is the difference between inline and block. Inline is the default value for elements like span, a, bold, button, input, etc. These elements take up only as much width as they need to fit their content. Their height and width cannot be set, and they can be used in line without disrupting the content around them. Block elements on the other hand, like div, p, sections, headings, etc take up an entire line, not just their content width. Their height and width can be set. Inline-block is a hybrid of the two. It only takes up as much space as it needs, but it's height and width can be set. You can adjust the default behavior of elements with this property.
display: flex is super useful for creating columns and rows of content. It involves a bunch more properties that work with this one, but they only work if display: flex; is set. You can read more about flexbox and all of its properties here.
display: none; will hide an element and remove the space it had taken up. It's very useful to use with javascript to show/hide elements.
.width-example { width: 300px; width: 30%; width: max-content; }
.height-example { height: 150px; height: 30%; height: max-content; }
.margin-example { /* top, right, bottom, left */ margin: 5px 45px 5px 45px; /* vertical, horizontal */ margin: 5px 45px; /* applies to all 4 sides */ margin: 10px; /*top, left/right, bottom */ margin: 10px 45px 5px; /* centers the element by automatically calculating the margin on either side, given the element's width */ width: 100px; margin: auto; }
.padding-example { /* top, right, bottom, left */ padding: 5px 45px 5px 45px; /* vertical, horizontal */ padding: 5px 45px; /* applies to all 4 sides */ padding: 10px; /*top, left/right, bottom */ padding: 10px 45px 5px; }
.position-example { position: relative; top: 50px; left: -150px; }
Position: relative will allow you to set the top, right, bottom and left properties of the element, and it will shift relative to it's default position.
Position: absolute will take the element out of the normal flow of a document and position it globally to the page.
Position: fixed will fix and element to a specific point on the screen and it will stay fixed there even as other elements scroll.
Position: sticky will keep an element in it's normal position until the user scrolls past it, then it will "stick" on the page according to the top, right, bottom, and left properties.
.overflow-example { overflow: scroll; overflow-x: hidden; overflow-y: visible; }
.z-index-example { Z-index: 10; }
.background-color-example { background-color: #8BABFC; }
.background-image-example { /* for image backgrounds */ background-image: url('image.png'); /*for gradient backgrounds*/ background-image: linear-gradient(red,yellow); }
.border-example { border: 3px solid; border: 2px dashed red; }
.border-radius-example { border-radius: 30px; }
.opacity-example { opacity: 55% }
.transform-example { transform: rotate(45deg); transform: scale(2) transform: translateY(20px) }
.transition-example { color: red; transition: color .5s; } .transition-example:hover { color: blue; }
@keyframes example { from {background-color: red;} to {background-color: yellow;} } .keyframe-example { background-color: red; animation-name: example; animation-duration: 4s; animation-direction: alternate; animation-iteration-count: infinite; }
.accent-color-example { accent-color: #ff0000; }
.cursor-example { cursor: pointer; }