Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CSS = PRESENTATION
SCREEN
STRUCTURE
HANDHELD
In HTML almost all tags inside the <body> create a box. In many cases, these boxes have pre-defined CSS styles, but most of these can be overridden with your own custom stylesheet. CSS is used to define the look, style & positioning of your HTML elements.
There are many HTML tags, each with its own specific purpose.
external stylesheets
Style rules are contained inside their own CSS document Multiple HTML documents can reference a single CSS file and share the same styles Expedites website creation and maintenance while ensuring a consistent look across all pages
CSS selectors
main types of selectors
Type selectors Select a specified HTML element for styling
Class selectors
Select an element whose class attribute contains the specified class Select an element with the matching id attribute. Select an element, class, or id, somewhere within a specified element, class, or id.
ID selectors
Descendant selectors
Type Selectors
CSS
em { } color: #ffffff;
<body>
HTML
<p>Lorem ipsum <em>dolor</em> sit</p> <ul> <li>vehicula</li> <li>tempor</li> </ul> <li><em>rutrum</em></li>
</body>
Class Selectors
CSS
.big { } color: #ffffff;
<body>
HTML
<p class=big>Lorem <em>dolor</em></p> <ul> <li class=big>vehicula</li>
<li>tempor</li> </ul>
<li><em>rutrum</em></li>
</body>
ID Selectors
CSS
#nav { } color: #ffffff;
<body>
HTML
<p>Lorem <em>dolor</em></p> <ul id=nav class=big> <li>vehicula</li> <li>tempor</li> </ul>
<li><em>rutrum</em></li>
</body>
Descendant Selectors
CSS
#ul em { } color: #ffffff;
<body>
HTML
amet.</p> <p>Lorem ipsum dolor <em>sit</em> <ul>
</body>
</ul>
CSS selectors
Allow you to target a specific element or group of elements within your HTML document to apply styles to You can be as vague or specific as you want in your selection.
VAGUE
p { } line-height: 21px; }
SPECIFIC
#header ul li .special { color: #ffffff;
selects all paragraphs in the document and applies a line height of 21px
selects anything with the class special, inside of an li that is inside a ul that is inside something with the id nav
IDs are intended for elements that appear only once on a page. Use them in your HTML markup to block off sections (eg. #page, #header, #content, #footer).
Classes
Classes are intended mainly for styling purposes. You can re-use them on any kind of element. You can also apply multiple classes to a single HTML element to combine various styles.
BLOCK: New lines appear before and after the element with it consuming the full width available.
INLINE: These elements do not force new lines before or after its placement, and it only consumes as much space as necessary.
floats
Using CSS, you can tell a block element to float to the left or to the right. Causing other elements to wrap around it.
Floated elements will be placed to the left or right until their outer edge touches the containing block edge or the outer edge of another float.
floats (contd)
This technique allows you to place block elements beside one another, or directly across on the other side of their container.