higher computing css. what is css? css: cascaded style sheets used to separate a web site’s...

18
HIGHER COMPUTING CSS

Upload: madlyn-webster

Post on 15-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

HIGHER COMPUTINGCSS

Page 2: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

WHAT IS CSS?

• CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks).

Page 3: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

HOW DOES IT LOOK?• In the head section, add a style tag

<style> </style>

• Goes inside the style tag, add css code. <style> CSS code goes here </style>

• CSS code looks different than html code. Syntax for CSS code is:

• selector {property:value}• selector {property:value; property:value;…}

Page 4: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

HOW DOES IT WORK?

• selector: Name of the tag. For example Body, p, h1 etc

• property: the property you want to change for example the colour, font, background image etc

• value: the value you want to give the property. For example 14 px, blue etc

Page 5: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

CSS PRACTICECreate the following webpage using the script below:

<html>

<head>

<title> CSS example </title>

<style type="text/css">

body {background-color: red}

h1 {background-color: green}

h2 {background-color: yellow}

p {background-color: blue}

div {background-color:blue; color:white; font-size:4em}

</style>

</head>

<body>

<h1> This is a heading1 </h1>

<h2> This is a heading2 </h2>

<h3> This is a heading 3 </h3>

<div> This is a div tag</div>

<p> This is a paragraph </p>

</body>

</html>

Page 6: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

HOW TO SPECIFY TEXT SIZE?

h1 {font-size: 12em or 12px, or 12pt or 12%}

• em is the unit for the calculated size of a font. So "2em", for example, is two times the current font size.

• px (such as font-size: 12px) is the unit for pixels.• pt (such as font-size: 12pt) is the unit for points.• % (such as font-size: 80%) 80% of the original

size.

Page 7: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

CSS COLORS

• CSS brings 16,777,216 colors to your disposal.

• body {background-color: “red” or “#ff0000”}

• red

#ff0000

• There are 17 valid predefined colour names. They are aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, and yellow.

Page 8: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

TEXT COLOR AND BACKGROUND COLOR PROPERTIES• Text color property: color

• Background color property: background-color

• Examples

• h1 { color: yellow; background-color: blue; }

Page 9: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

CHANGING THE FONT TYPE• Property: font-family• This is the font itself, such as Times

New Roman, Arial, or Verdana.• The font you specify must be on the

user's computer( 'safe' fonts are arial, verdana and times new roman)

• Examples:• h1 {font-family: arial, helvetica}

Page 10: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

CHANGING THE SIZE OF YOUR FONT

• Size of your font: font-size

• Be careful with this - text such as headings should not just be a paragraph in a large font; you should still use heading tags (h1, h2 )

• Example:

• p {font-size: 14px}

Page 11: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

MAKE IT BOLD AND/OR ITALIC

Property for bold: font-weight

Exampleh2 {font-weight: bold}

Property for italic: font-style

Exampleh3 {font-style: italic}

Page 12: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

UNDERLINE TEXT• Property: text-decoration • text-decoration: overline, which

places a line above the text. • text-decoration: line-through, strike-

through.• text-decoration: underline • text-decoration: none• Example

• a {text-decoration: underline, color:blue}

Page 13: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

TRANSFORM TEXT• Property: text-transform

• text-transform: capitalize turns the first letter of every word into uppercase.

• text-transform: uppercase turns everything into uppercase.

• text-transform: lowercase turns everything into lowercase.

• text-transform: none

Page 14: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

ID AND CLASS SELECTORS

• What is you have 2 paragraphs that you want to look different?

p {color: blue} changes the style of all paragraphs!

• There are other ways select elements to style. They are called ID and CLASS selectors

Page 15: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

ID SELECTOR• HTML code

• <body><p id=“para1”>

I’m paragraph 1!

</p>

<p id=“para2”>

I’m paragraph 2!

</p>

• </body>

CSS code<head><style type=“text/css”>#para1 {color:red}#para2 {color:blue}

</style></head>

Page 16: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

CLASS SELECTOR• HTML code

• <body>• <p

class=“para1”>

• I’m paragraph 1!

• </p>

• <p class=“para2”>

• I’m paragraph 2!

• </p>

• </body>

CSS code<head><style type=“text/css”>.para1 {color:red}.para2 {color:blue}

</style></head>

Page 17: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

WHAT’S THE DIFFERENCE?

• An id can only be used once.<body>

<h1 id=“red”>I’m the only red allowed! HaHa </h1>

</body>

• A class can be used many times<body>

<h1 class=“blue”>I’m blue </h1>

<p class=“blue”>I’m blue too!</p>

</body>

Page 18: HIGHER COMPUTING CSS. WHAT IS CSS? CSS: Cascaded Style Sheets used to separate a web site’s content(information) from its style(how it looks)

Thanks to J.Hubbard for some examples in this presentation