Professional Documents
Culture Documents
3lab - Webdev - Css
3lab - Webdev - Css
DEVELOPMENT
(CSS)
By: Vera A. Panaguiton
OUTLINE
WHAT IS CSS?
INLINE STYLING
INTERNAL STYLING
EXTERNAL STYLING
ID
CLASS
BOX MODEL
<element style=“property:value;”>
<p style=“color:red;”>
APDEV 1 by Vera A. Panaguiton 10
INLINE: EXAMPLE 1
HTML CODE RESULT
RESULT
<html>
<head>
<title></title>
<style>
</style>
</head>
APDEV 1 by Vera A. Panaguiton 13
CSS RULE
A CSS rule is made up of two distinct parts — the selector and the
declaration. The selector determines what is being styled on a page,
and the declaration is how it should be styled.
type
- specifies the type of document being linked to. The value should be text/css.
rel
- specifies the relationship between the HTML page and the file it is linked to. The value
should be stylesheet whenAPDEV
linking
1 byto a CSS
Vera file.
A. Panaguiton 18
CSS CODE
EXTERNAL: EXAMPLE 1
RESULT
HTML CODE
RESULT
Note: If there are conflicts of similar properties but different values of the
same element, a page will first follow the inline styling, then followed by
internal and last is the external. APDEV 1 by Vera A. Panaguiton 20
STYLING LINKS: PSEUDO CLASSES
Links can be styled with any CSS property (e.g. color, background, etc.) but it
can also be styled depending on what state they are in.
Browsers tend to show links in blue with an underline by default, and they
will change the color of links that have been visited to help users know which
pages they have been to.
Different states that links can exist in, can be styled using different pseudo-
classes:
:link - a normal, unvisited link
:visited - a link the user has visited or has clicked on
:hover - a link when the user’s mouse cursor is place on top of the link without a click
:active - a link the moment it is clicked
:focus – a link selected using the Tab key on a keyboard.
RESULT
Try clicking
APDEV 1 by Vera A. Panaguiton the links to differentiate its states. 22
CSS SELECTORS
You have met selectors already, it is the first part of a CSS Rule.
It is a pattern of elements and other terms that tell the browser which HTML elements
should be selected to have the CSS property values inside the rule applied to them.
Categories:
Basic selectors
- select elements based on name, id, class. (We will focus on these type of selector)
Combinator selectors
- select elements based on a specific relationship between them.
- e.g. descendant, child, general sibling, etc.
Pseudo-class selectors
- select elements based on a certain state.
Pseudo-elements selectors
- select and style a part of an element.
Attribute selectors
- select elements based on an attribute or attribute value.
APDEV 1 by Vera A. Panaguiton 23
CSS SELECTORS
<div> </div>
CODE RESULT
<span> </span>
CODE RESULT
Content
- The content of the box, where text and images appear
Padding
- Clears an area around the content. The padding is
transparent
Border
- A border that goes around the padding and content
Margin
- Clears an area outside the border. The margin is transparent
Width, Height
– width and height of the box.
APDEV 1 by Vera A. Panaguiton 31
CODE
BOX MODEL:EXAMPLE 1 RESULT
Comment out
every border
property in the css
code or change
1px to 0px to hide
the borders.