CSS Flashcards
What is css
CSS describes how HTML elements are to be displayed on screen, paper, or in other media
CSS saves a lot of work. It can control the layout of multiple web pages all at once
External stylesheets are stored in CSS files
CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.
CSS Syntax
The selector points to the HTML element you want to style.
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a value, separated by a colon.
Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded by curly braces.
Explain p { color: red; text-align: center; } sintax
p is a selector in CSS (it points to the HTML element you want to style: <p>).
color is a property, and red is the property value
text-align is a property, and center is the property value</p>
A CSS selector selects the HTML element(s) you want to style.
Name the types
The CSS element Selector p { text-align: center; color: red; } ----------------
The CSS id Selector
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element is unique within a page, so the id selector is used to select one unique element!
----------------- The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the class name. -------------------- The CSS Grouping Selector h1 { text-align: center; color: red; }
Special selector cases
p.center {
text-align: center;
color: red;
}
You can also specify that only specific HTML elements should be affected by a class.
Special selector cases
<p class="center large">This paragraph refers to two classes.</p>
In this example the <p> element will be styled according to class=”center” and to class=”large”:</p>
The CSS Universal Selector
The universal selector (*) selects all HTML elements on the page.
CSS Comments
/* This is a single-line comment */
Add a background color to an grouping selector
<h1>Hello World</h1>
Borders styles (10)
p.dotted {border-style: dotted;}
dotted - Defines a dotted border
dashed - Defines a dashed border
solid - Defines a solid border
double - Defines a double border
groove - Defines a 3D grooved border. The effect depends on the border-color value
ridge - Defines a 3D ridged border. The effect depends on the border-color value
inset - Defines a 3D inset border. The effect depends on the border-color value
outset - Defines a 3D outset border. The effect depends on the border-color value
none - Defines no border
hidden - Defines a hidden border
border-width property
The border-width property specifies the width of the four borders.
p.three {
border-style: solid;
border-width: 25px 10px 4px 35px; /* 25px top, 10px right, 4px bottom and 35px left */
border property is a shorthand property
The border property is a shorthand property for the following individual border properties:
border-width
border-style (required)
border-color
p {
border: 5px solid red;
}
CSS Margins
Margins are used to create space around elements, outside of any defined borders.
p { margin-top: 100px; margin-bottom: 100px; margin-right: 150px; margin-left: 80px; }
CSS Padding
Padding is used to create space around an element’s content, inside of any defined borders.
padding-top
padding-right
padding-bottom
padding-left
The height and width properties may have the following values
auto - This is default. The browser calculates the height and width
length - Defines the height/width in px, cm etc.
% - Defines the height/width in percent of the containing block
initial - Sets the height/width to its default value
inherit - The height/width will be inherited from its parent value