13

Higher Computing Science CSS

Embed Size (px)

Citation preview

Page 1: Higher Computing Science CSS
Page 2: Higher Computing Science CSS

CSSHTML is a style sheet language used for describing the presentation of a document written in a markup language (e.g. HTML).

CSS stands for Cascading Style Sheets.

Page 3: Higher Computing Science CSS

Why CSS?HTML was intended to describe the content of a web page, not the design.

As HTML developed it allowed web designers to define design style information for a page and so the HTML for each web page became unwieldy. Changing a web site design involved changing the attributes on every web page.

Page 4: Higher Computing Science CSS

Why CSS?HTML was intended to describe the content of a web page, not the design.

As HTML developed it allowed web designers to define design style information for a page and so the HTML for each web page became unwieldy. Changing a web site design involved changing the attributes on every web page.

CSS removes the style information from the HTML page.

CSS style definitions are commonly stored in a separate file. Changes to the style information in this file can change the style of the entire website.

Page 5: Higher Computing Science CSS

Inline, Internal & External CSSInline CSSWith Inline CSS, the style attribute is included within an HTML tagOverrides any other CSS formattingAdvantage: Can be used for quick fixesDisadvantage: Somewhat defeats the purpose of CSS

Page 6: Higher Computing Science CSS

Inline, Internal & External CSSInternal CSSWith internal CSS, the internal styles are defined in the <head> of each HTML page.Advantage: Faster download – CSS loads with the pageDisadvantage: Each page may need to be updated if redesigning the style.Larger file size.

Page 7: Higher Computing Science CSS

Inline, Internal & External CSSExternal CSSWith external CSS, the CSS is held in a separate file.Advantage: Changing the file will update the style change across all pages in website

Page 8: Higher Computing Science CSS

CSSCSS RuleA CSS rule set consists of a selector and a declaration block.

Page 9: Higher Computing Science CSS

CSSCSS RuleA CSS rule set consists of a selector and a declaration block.

Page 10: Higher Computing Science CSS

CSSIn this example:Each page will have the background colour #ffffb3All h1 content will be red, centredAll paragraph content will be Times New Roman 18

Page 11: Higher Computing Science CSS

CSSID SelectorIt’s possible to define individual elements which to have a style specified in CSS. To do this, use an ID Selector.Note that ID Selectors can only be used once on any page.

CSS HTML

Page 12: Higher Computing Science CSS

CSSClass SelectorClass selectors work like ID selectors but they can be applied to many elements on a page.

CSS HTML

Page 13: Higher Computing Science CSS

CSSExternal CSSWhen using external CSS, each page needs to specify the name of the CSS file being usedThe <link> tag is used and should be placed within the <head> element of the page