7 Basic CSS Flashcards
Change the colour of text as an attribute
<h1 style=”color:blue;”> textext /h1>
Create a style block for all of a certain kind of HTML element
<style> h2 { color:red; } </style>
Create a style block for all of a certain class
Apply the class to an HTML element
style> .class-name { color:red; } /style>
h2 class=”class-name”>
textext
/h2>
Control font size
<h1 style=”font-size: 12px;”> textext /h1>
Can you put multiple entries within 1 set of style tags?
yes <style> .red-text { color: red; } p { font-size: 29px; } </style>
Change font
<style> p { font-family: sans-serif; } </style>
Import font family from the web
<link href=”https://fonts.googleapis.com/css?family=Lobster” rel=”stylesheet” type=”text/css”>
Define a backup font
What happens if there is no backup font?
the one that appears first after : has higher priority <style> p { font-family: Helvetica, sans-serif; } </style>
If there’s no backup font it will use the default font Verdana
Define the width/height of something (image, text box etc.)
What happens if you only define 1 of them?
<style> .larger-image { width: 500px; } </style>
height: 500px
The image remains proportional.
Create a border. Define its:
size,
style,
edge roundness/circularity, and
colour
Which style creates the border itself?
<style> .thin-red-border { border-color: red; border-width: 5px; border-style: solid; border-radius: 3px (or in terms of %, 50% + is a complete circle); } </style>
To create the border you need:
border-style: solid;
Define multiple classes for a single element
List the classes within the “class” attribute separated by a space.
<img class=”class1 class2”>
Set background colour
.green-background {
background-color: green;
}
set id styles
#id-name { background-color: green; }
id=”id-name”
What is an id attribute
How do they interact with classes?
Benefits of id attribute (2 things)
The basic rule of ID elements
ids are like a “non-reusable” class used for a only a single element (although they seem to be able to be used for multiple elements).
They overwrite classes. Classes don’t overwrite ids.
You can use an id to style a single element
You can use them to select and modify specific elements with JavaScript.
id attributes should be unique.
All html elements are rectangular. What 3 properties can defines their shape?
padding- controls the amount of space BETWEEN the element’s content and its border
border-
margin- controls the amount of space between an element’s border and SURROUNDING elements. If negative it will grow beyond its neighbours.