Prelims - CSS (Syntax&Selectors) Flashcards
describes how HTML elements are to be displayed on screen, paper, or in other media
Cascading stylesheets (CSS)
CSS syntax
h1 { color:blue; font-size:12px}
selector { declaration; declaration}
declarations consist of the property (color) and value (blue)
points to the HTML element you want to style
selector
includes a CSS property name and a value, separated by a colon
declaration
selects HTML elements based on the element name
CSS element selector
p { text-align: center; color: red; }
selector uses the id attribute of an HTML element to select a specific element
CSS id Selector
#para1 { text-align: center; color: red; }
An id name cannot start with a number!
The id of an element is unique within a page, so the id selector is used to select one unique element
To select an element with a specific id, write a ____ character, followed by the id of the element
#
selects HTML elements with a specific class attribute
CSS class Selector
.center { text-align: center; color: red; }
To select elements with a specific class, write a ____ character, followed by the class name
.
selects all HTML elements on the page
The CSS Universal Selector
* { text-align: center; color: blue; }
To select all HTML elements on the page use the ____ character
*
selects all the HTML elements with the same style definitions
CSS Grouping Selector
h1, h2, p { text-align: center; color: red; }
(the h1, h2, and p elements will have the same style definitions)