getting started with css

21
Getting Started with CSS

Upload: shivani-thakur-daxini

Post on 15-Aug-2015

39 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Getting started with css

Getting Started with

CSS

Page 2: Getting started with css

Do U know these HTML Tags?<body>I am main container</body><p> I am P tag </p><div> I am Div </div><span> I am Span </span>

HTML ReferencePen for HTML

Page 3: Getting started with css

<P> or Paragraph Tag

- Paragraph tag is of type Block Content- Special thing about <P> element is,

browser will not display more than one space character in a row.

- It can contain other Tags/element

Page 4: Getting started with css

<div> or Division Tag- Division tag is of type Block Content- Division always starts on new line- Block content tag can contain all type of

inline and block content tagsExamples of Block Content tags<blockquote>, <p>, <ol>, <ul> etc.

Page 5: Getting started with css

<span> Tag- Span is inline content type tag - Does not begin with new line- Mostly inline tags only contains inline tags Examples of Inline tags<b>, <strong>, <em>, <code> etc

Page 6: Getting started with css

Ways to apply CSS to HTMLInline <p style="color: green">text</p>Internal

<style type=”text/css”> p{ color: green } </style>External mystyles.css file and content is: p {color: green}

Page 7: Getting started with css

CSS PrecedenceBrowser Default (Lowest) External StylesheetInternal StylesheetInline Stylesheet (Highest)

Page 8: Getting started with css

The way HTML has TAGS

CSS has SELECTORS

Page 9: Getting started with css

HTML TAG - CSS SELECTOR

How we will <p> it in CSS?1. #p{ }2. :p{ } 3. p{ }4. .p{ }

<p> Hello Word</p>

<div> I am div </div>

Page 10: Getting started with css

HTML Selectors are easy to understand as they are just names of the HTML tags

HTML SELECTORS

<p></p>

<div></div>

<span></span>

p { }

div{ }

span{ }

Page 11: Getting started with css

Every selector has- Curly Braces selector always starts with curly braces { } - Properties Every property has a value

separated by Colon ( : ) not equal ( = ) Ends with semicolon ( ; )

SELECTORS

Page 12: Getting started with css

CSS uses many property specific units - Codepen for units in CSS

px (pixel) smallest and it is fixed size unit. One pixel is equal to one dot on computer. Pixel does not scale automatically :(

pt (point)Used in print media. Fixed size non-scalable1pt = 1/72 inch

Units in CSS

Page 13: Getting started with css

Units in CSSem

em is equal to font size of the parent element. If parent element is 8px then that will be equal to 1em, 2em = 16pxIf no font-size is defined on parent element then it is default 16pxAlso em is scaleable unit. For responsive web design they are good

% (percentage)Similar to “em”font size = 100% e.g. 8px = 100%completely scalable

Page 14: Getting started with css

Units in CSSrem

Here comes new unit “root em” in css3It works on root element <html> font-size and not on the immediate parent sizeIf no font-size is defined on root element “html” then default is 16px

There are some more units - cm, in, mm etc

Page 15: Getting started with css

ColorsRGB (Red, blue, green) Values in RGB ranges from (0 - 255)Red - rgb(255,0,0)

HexadecimalValues in Hexadecimal ranges from (0 - f) i.e. (0-9 and a-f)

HSL (Hue, Saturation, lightness)Values in HSL set like RGB (will cover this later….)

RGBa (Red, Blue, Gree, Alpha) - (will cover this later….)

Page 16: Getting started with css

CSS Color Propertiescolor- Through this we specify font or border color. It is foreground

colordiv { color: orange; }

- Possible values for property are “- inherit- color value

background-colorThrough this we specify the box color. e.g. we’ll apply this property on a <div> tag, it will fill that <div> tag with the specified background color

Page 17: Getting started with css

CSS Color Propertiesbackground-color

div { background-color: yellow; }- Possible values for property are

- transparent- inherit- color value

Pen for CSS color properties

Page 18: Getting started with css

Text StylingTo change the shape and size of the text on the web we use multiple text propertiesfont-family - Basically it is the name of the font e.g. “Arial”, “Verdana”font-size - - Size of the font- As learnt earlier it can use unit “px”, “pt” or “em” etc

font-weight - This will tell whether the font is bold or not- bold- normal

These values are supported in most of the browsers

Page 19: Getting started with css

Text Stylingfont-weight -Other than bold and normal there are other values which are supported in new browsers- 100, 200, 300, 400 (normal)- (500, 600, 700) (bold)

font-style To specify whether text style should be italic or not- italic- normal

Page 20: Getting started with css

Questions?

Page 21: Getting started with css