8a. Cascading Style Sheet

Size: px
Start display at page:

Download "8a. Cascading Style Sheet"

Transcription

1 INFS 2150 Introduction to Web Development 8a. Cascading Style Sheet 1 Objectives Concepts of cascading style sheets (CSS). 3 ways of using CSS: inline styles, embedded styles, and external style sheet. Style precedence and style inheritance. Use cascading style sheets to format paragraphs, lists, and headings. Design a style for hypertext links in their four conditions. Define document content with the class and id attributes and create styles for them. Mark document content with the <div> and <span> tags and create styles for them. Use cascading styles to design page layout Peter Y. Wu, RMU 1

2 HTML and Page Layout Early versions of HTML had little support for Web page design. The philosophy was to: use basic text files that could be quickly downloaded rely on Web browsers to format the document s appearance The simplicity of HTML tags made creating Web pages easier and made pages load faster. 3 HTML and Page Layout Web authors looked for ways to deliver more visually interesting documents. This has been done chiefly in three ways: using HTML tag extensions converting text to images controlling page layout with tables Peter Y. Wu, RMU 2

3 HTML and Page Layout Upside HTML tag extensions: Provide the Web author with more choices in layout and design. Converting text to images: Don t have to worry whether a browser will support a particular font. Place in specific locations on the Web page. Tables: Use as a layout tool. 5 HTML and Page Layout Downside HTML tag extensions: Not all browsers support the various tag extensions. Converting text to images: You are limited in the number of inline images you can use and still have the page downloaded in a timely fashion. Moreover, it s difficult to make quick changes to the page s content if you have to edit the inline graphics first. Tables: This makes the HTML files more complicated to write and to interpret Peter Y. Wu, RMU 3

4 History and Support of CSS One principle of design theory is to separate the content of a document from its design. A style defines the appearance of a document element. The collection of styles for a Web page or Website is known as a style sheet. Style sheets use a common language and syntax. The main style sheet standard is Cascading Style Sheets (CSS). 7 Cascading Style Sheets (CSS) Like HTML, style sheets must use a common language and follow common rules. This language is known as Cascading Style Sheets, or more simply, CSS. CSS has been developed by the WWW Consortium ( the same organization that develops standards for HTML. CSS is designed to augment HTML, not replace it. CSS is a whole new way of formatting Web pages. CSS provides several tools not available with standard HTML Peter Y. Wu, RMU 4

5 CSS Versions CSS Level 1 was released in CSS Level 2 was released in CSS Level 3, the latest standard is being developed. Internet Explorer 6.0 and Mozilla Firefox 3.0 both support CSS Level 1, and most of CSS Level 2. CSS Level 3 support is uneven in many different browsers. Testing with different browsers is important. 9 Benefits of Style Sheets Use as a design tool. Makes website more flexible. Easier to maintain and modify. More aesthetically interesting. Consistent look Peter Y. Wu, RMU 5

6 Web Sites with Information on Cascading Style Sheets This figure displays websites that provide more information about the compliance of browsers with CSS1 and CSS2, and for information about the standards themselves. 11 Style Types There are three ways of employing CSS in Web pages: inline styles in which styles are added to each tag within the HTML file. The style affects that particular tag but does not affect other tags in the document. embedded styles applied to an entire HTML file, allowing the Web designer to modify the appearance of any tag in the document. linked or external style sheet placed in an external file and linked with pages in the Web site, allowing the Web designer to modify the appearance of tags in several documents Which approach you choose depends on the Web site s design Peter Y. Wu, RMU 6

7 Using Inline Styles If you need to format a single section in a Web page, you d probably use an inline style. To create in inline style, add the style attribute to the HTML tag using the following syntax: <tag style= style declarations > tag is the name of the tag (h1, h2, etc) style declarations are the styles you ll define for a particular tag style declaration must be enclosed within double quotation marks 13 A Style Declaration A style declaration consists of attribute names that specify such features as: font size color font type Attributes are followed by a colon and then the value of the attribute. Multiple attributes can be used as long as you separate each one by a semicolon. The general syntax for the style declaration is: attribute1:value1; attribute2:value2; Peter Y. Wu, RMU 7

8 Inserting an Inline Style This figure shows how to insert an inline style. 15 Heading with New Style This figure shows the heading with the new style Peter Y. Wu, RMU 8

9 Creating an Embedded Style An embedded style is a style applied to various sections within a Web page. Insert a <style> tag within the head section of the HTML file. Within the <style> tag, enclose the style declarations needed for the entire Web page. The syntax of an embedded style is: <style type= style sheet language > style declarations </style> style sheet language identifies the type of style language used in the document The default, is text/css for use with CSS 17 Selectors and Declarations Style declaration within the <style> tags obey the following syntax: selector {attribute1:value1; attribute2:value2;...} selector identifies an element in your document, such as a heading or paragraph, and the attributes and values within the curly braces indicate the styles applied to all the occurrences of that element this collection of attributes and values is also referred to as the declaration of the selector Peter Y. Wu, RMU 9

10 Selectors and Declarations For example, to display all h1 headings in the HTML document using a gold sans-serif font, use the following embedded style: <style> h1 {color: gold; font-family: sans-serif} </style> h1 is the selector and the text enclosed in the braces is the declaration 19 Defining a Global Style The type attribute was not included within the <style> tag. This is because text/css is the default style language, and unless you specify a different style language, you don t need to enter the type attribute. When using the <style> tags, you don t need to include double quotes around the attributes and attribute values Peter Y. Wu, RMU 10

11 Grouping Selectors You can apply the same declaration to a group of selectors by including all of the selector names separated by commas. The following is a sample style declaration to format all headings in a gold sans-serif font: <style> h1, h2, h3, h4, h5, h6 {color:gold; font-family:sans-serif} </style> 21 The Same Style Applied to Two Headings Even though the same style is used for all heading tags, there are still some differences in how the browser displayed text formatted with these tags. Most notably, the styles did not affect the relative sizes of the text. Text formatted with the <h1> tag is still larger than text formatted in the <h2> tag. This is because the size of the heading text was not defined, so that attribute is left to the browser Peter Y. Wu, RMU 11

12 Using an External Style Sheet Create styles that apply to an entire Web site by creating a text file containing style declarations. Most style sheets have the extension.css, though this is not a requirement. Within a style sheet, you don t need <style> tags, just the style declarations. 23 Linking to Style Sheets with the <link> Tag Use the <link> tag to link Web pages to a style sheet. The general syntax for using the <link> tag is as follows: <link href= URL rel= relation_type type= link_type > URL is the URL of the linked document relation_type establishes the relationship between the linked document and the Web page link_type indicates the language used in the linked document In order to link to a style sheet, the value of the rel attribute should be stylesheet and the value of the type attribute should be text/css. To link to a style sheet named mws.css, the <link> tag would be: <link href= mws.css rel= stylesheet type= text/css > Peter Y. Wu, RMU 12

13 Linking to Style Sheets Another way to link to a style sheet is to use command, which accesses the style sheet definitions from another file. To with styles, enclose command within the embedded <style> tags as follows: url(stylesheet.css); style declarations </style> stylesheet.css is the URL of the style sheet file 25 Command command provides greater flexibility than the <link> tag when working with multiple style sheets. command has limited browser support. Unless you have a compelling reason to you are probably better off using the <link> tag Peter Y. Wu, RMU 13

14 Resolving Style Precedence In cases where the styles conflict, precedence is determined in the following order: an inline style overrides any embedded style or external style sheet an embedded style overrides an external style sheet an external style sheet overrides the internal style rules set by the Web browser any style attributes left undefined by an inline style, an embedded style, or an external style sheet are left to the Web browser 27 Changing Styles As a change is made to a style at one level, the changes are cascaded through to the other levels (hence the term, cascading style sheets). Where a different font has not been specified, changes will cascaded through the embedded and inline styles. As you define more styles for a Web site, you need to keep track of the inline, embedded, and external style sheets to correctly predict the impact that style changes have on the appearance of each page Peter Y. Wu, RMU 14

15 Working with Style Inheritance Web pages invariably have elements placed within other elements. for example, a Web page might have a bold tag, <b>, placed within a paragraph tag, <p>, to create boldface text within the paragraph. The paragraph tag is likewise placed within the <body> tag. 29 Sample Tree Structure of HTML Elements This figure displays the HTML element relationship using a tree diagram Peter Y. Wu, RMU 15

16 Parent and Descendant Elements An element that lies within another element is called a descendant or descendant element. An element that contains another element is called the parent or parent element. An example of a parent is the <body> tag, which contains all of the other tags used to format the content of a Web page. Using the principle of inheritance, styles defined for each parent tag are transferred to its descendants. 31 Contextual Selectors Use the tree structure concept to better control how styles are applied to a Web page. CSS provides ways of fine-tuning the context in which the selector is applied. if you want to apply a style only to the descendant of a ancestral element, use the syntax: e1 e2 e1 and e2 are the names of HTML elements and e2 occurs below e1 in the hierarchy (tree structure) of elements in the document. for example: li b {color:blue} Color:blue is applied to <b> elements under <li> element Peter Y. Wu, RMU 16

17 Using Font Families The font-family attribute allows you to choose a font face for use in Web pages. CSS works with two types of font faces: a specific font, which is a font such as Arial, Garamond, or Times New Roman that is actually installed on a user s computer. a generic font, which is a general description of a font, allowing the operating system to determine which installed font best matches it. CSS supports five generic font types: serif, sansserif, monospace, cursive, and fantasy. 33 Generic Fonts This figure shows examples of each generic type. For each generic font there can be a wide range of designs Peter Y. Wu, RMU 17

18 Generic and Specific Fonts One issue with generic fonts is that you cannot be sure which specific font the Web browser uses to display your text. Whenever possible, it is a good idea to use specific fonts. Provide the Web browser with several fonts to choose from. Browsers that don t have access to the font you specified as your first choice may have your second or third choice available. List specific font names first, followed by a generic font name for the browser to use if none of the specific fonts can be found. 35 Managing Font Size The <address> tag can format address information on a Web page. by default, text formatted with the <address> tag is displayed in normal-sized type, italicized, and aligned with the left edge of the Web page. A common method for specifying font sizes with HTML is to use the size attribute of the <font> tag. The size attribute limits you to only seven font sizes. Browsers can display font sizes quite differently Peter Y. Wu, RMU 18

19 Managing Font Size Continued In CSS, you use the font-size attribute to manage font sizes. Font sizes can be expressed: as a unit of length with a keyword description as a percentage of the parent element with a keyword expressing the size relative to the font size of the parent element 37 Absolute and Relative Units If you choose to express size as a unit of length, you can use absolute units or relative units. absolute units define the font size based on one of the following standard units of measurement: mm (millimeter), cm (centimeter), in (inch), pt (point), and pc (pica). use a relative unit, which expresses the font size relative to a size of a standard character. There are two standard typesetting characters, referred to as em and ex. the em unit is equal to the width of the capital letter M in the browser s default font size the ex unit is equal to the height of a small x in the default font Peter Y. Wu, RMU 19

20 The EM and EX Units The em unit is more useful for page design, because 1 em is equal to the browser s default font size for body text. This is true no matter what font is being used (unlike the ex unit, whose size changes based on the font face being used). 39 The EM and EX Units As with absolute units, you can specify factional values for the em and ex units. Unlike the absolute units, em and ex units are scalable in that they retain their relative proportions regardless of the monitor size or resolution Peter Y. Wu, RMU 20

21 Pixels Pixels give you the greatest control over size. A pixel is the smallest element recognized by the monitor. Pixels should be used with some caution. Text that is 10 pixels high may be perfectly readable at a monitor resolution of 640 x 480, but it can become unreadable if the monitor is set to 1024 x Descriptive Keywords If you are uncomfortable dealing with units of length, you can use one of the seven descriptive keywords: xx-small x-small small medium large x-large xx-large These keywords correspond to the seven values of the size attribute in the <font> tag Peter Y. Wu, RMU 21

22 Expressing Font Size as a Percentage of the Parent Tag This figure shows the impact of such a style definition on boldface text in a Web page. The style has the same impact within a heading, since the heading is the parent element, and the boldface text is increased to 150% of the surrounding heading text. 43 Express a Font Size using Keywords Express a font size using the keywords larger and smaller, which makes the font one size larger or smaller than the size of the parent element. for example, to make the h2 heading one size larger than the body text, you could use the following style: body {font-size: medium} h2 {font-size: larger} Peter Y. Wu, RMU 22

23 Specifying Word, Letter, and Line Spacing Use CSS font attributes to control the spacing between letters, words, and lines of text. To set the space between individual letters, you use the letter-spacing attribute, with the syntax: letter-spacing: size size can either have the value normal, which allows the browser to determine the letter spacing based on the font being used, or a number expressed in the same measuring units used to describe font size (inches, millimeters, centimeters, em units, etc.) 45 Specifying Word, Letter, and Line Spacing Continued Another technique to change the spacing between individual words is the word-spacing attribute, with the syntax: word-spacing: size size is either equal to normal, to allow the browser to set the word spacing, or to a specific length using the standard units of measure Use the line-height attribute to modify the vertical space between lines of text. Graphic designers may know this spacing as leading. The line-height attribute specifies the minimum distance between the baselines of adjacent lines Peter Y. Wu, RMU 23

24 Comparison of Line Height to Font Size This figure shows how the line height relates to the font size. The line height is usually larger than the font size to leave additional space between lines of text. 47 Line Height To set the line height, use the style: line-height: size size is either a specific length, a percentage of the font size, or a number representing the ratio of the line height to the font size the standard ratio is 1.2, which means that the line height is 1.2 times the font size to make paragraphs double-spaced use the style definition p {line-height: 2} Peter Y. Wu, RMU 24

25 A Title with a Large Font Size and Small Line Height A common typographic technique is to create titles with large fonts and small line heights. This figure shows an example where the line height is actually smaller than the font size. This treatment can give the title greater impact than it would have with more space between the two lines. 49 Setting Font Styles and Weights Font styles are controlled by the font-style attribute. The font-style attribute has three possible values: normal, italic, or oblique. The italic and oblique styles are similar in appearance though there can be small differences depending on the font Peter Y. Wu, RMU 25

26 Font Weights CSS considers bold to be an aspect of the font s weight, or line thickness. Font weights can be expressed as an absolute number ranging in intervals of 100, going from 100 (the lightest) up to 900 (the heaviest or most bold ). For most fonts, you can assume that: a weight of 400 corresponds to normal text a weight of 700 can be used for bold text a weight of 900 for extra bold text 51 Font Weights Use the keywords normal and bold in place of a weight value. Express the font weight relative to the parent tag by using the keywords bolder or lighter. Use the CSS bolder attribute to get bolder text: h2 {font-weight: 700} b {font-weight: bolder} If these style definitions are applied to a Web page, h2 text formatted with the <b> tag will be bolder or thicker in appearance than the surrounding heading text Peter Y. Wu, RMU 26

27 Aligning Text Horizontally and Vertically Use the text-align attribute to left, center, right or justify text. To do this with CSS, use the text-align attribute: text-align: alignment alignment can be left, center, right, or justify setting the text-align value to justify stretches the text, extending it from the left to the right margin some browsers will ignore the text-align attribute value 53 Applying the Center Text-Align Style This figure shows how to apply the center text-align style Peter Y. Wu, RMU 27

28 Vertically Align Elements CSS allows you to vertically align elements such as text and images relative to the surrounding text. The syntax for setting the vertical alignment is: vertical-align: alignment alignment has one of the keyword values 55 Values of the Vertical Alignment Attribute This figure shows the alignment keyword values Peter Y. Wu, RMU 28

29 Examples of the Vertical Alignment Values This figure shows an example of each vertical-align value. Baseline is the default value for vertical alignment. 57 Indenting Text CSS allows you to indent the first line of a paragraph. The syntax for creating an indentation is: text-indent: indentation indentation is either the length, in either absolute or relative units, of the indentation or a percentage of the width of the paragraph Peter Y. Wu, RMU 29

30 Hanging Indent The length and percentage values also can be negative, which extends the first line to the left by the specified value or percentage, and then indents the rest of the lines in the paragraph. This particular effect, called a hanging indent, works sporadically on many browsers. 59 Special Text Attributes CSS provides three attributes for special text effects: text-decoration text-transform font-variant Peter Y. Wu, RMU 30

31 Values of the Text-Decorating Attribute This figure shows the text-decoration attribute can be used to underline your text or place a line over or through your text. You can also make your text blink on and off using the text-decoration: blink attribute. 61 The Text-Transform Attribute The text-transform attribute can be used to: capitalize the first letter of each word in a paragraph display the text in all capital letters display the text in all lowercase letters Peter Y. Wu, RMU 31

32 Values of the Text-Transform Attribute This figure shows the effect of the various text-transform values. 63 The Font-Variant Command Use the font-variant command to create small caps. Small caps are capital letters that are the same size as lowercase letters. The syntax for the font-variant attribute is: font-variant: small-caps Peter Y. Wu, RMU 32

33 Values of the Font-Variant Attribute This figure shows values of the font-variant attribute. 65 The font Attribute The font attribute provides an efficient way for you to define multiple attributes. The syntax for the font attribute is: font: font-style; font-variant; font-weight; font-size/lineheight; font-family font-style, font-variant, and so forth are the values for font and text style attributes The font attribute requires that you specify the font size, font variant, and font weight. If a font attribute is not included, the browser assigns the normal or standard value for the element Peter Y. Wu, RMU 33

34 The color Attribute CSS works with most of the color names supported by HTML. Another way to specify color in CSS is to use RGB color values. You can enter the hexadecimal form of the color value or the RGB color values directly. for example, to change the body text color to teal, use any of the following styles: body {color:teal} body {color: #008080} body {color: rgb (0,128,128)} body {color: rgb (0%, 50%, 50%} 67 Changing the Color of the H1-H6 Headings RGB color values range from 0 to 255, so specifying a color percentage of 50% for green and blue is close to a color value of 128. This figure shows an example of changing the color of the H1-H6 headings Peter Y. Wu, RMU 34

35 Working with Background Color By default, elements take on the background color of their parent element. To change the background color of almost any element, use the background-color style. 69 Applying a Background Color This figure shows how to apply a background color Peter Y. Wu, RMU 35

36 Working with Background Images Almost any element on the page can also be displayed with its own background image. The background image has four attributes: the source of the image file how the image is repeated in the background where the image is placed on the background whether the image scrolls with the display window To specify which file to use for a background, use the syntax: background-image: url(url) URL is the location of the image file 71 Applying a Background Image to an Element This figure demonstrates how you can apply this style to the <b> tag to create an interesting design for a section of boldface text Peter Y. Wu, RMU 36

37 Working with Background Images Continued By default, background images are tiled both horizontally and vertically behind the element until the entire element is filled. Control the way the tiling occurs using the background-repeat style attribute. The background-repeat attribute has four possible values. 73 Values of the Background-Repeat Attribute This figure shows the background-repeat attributes four possible values Peter Y. Wu, RMU 37

38 Examples of the Background-Repeat Values This figure shows examples of each background-repeat values. 75 The Background-Position Attribute Background images are placed in the upper-left corner of their element, and then repeated (if tiling is being used) from there. You can move the background image to a different location using the background-position style attribute. The background-position attribute has two values: the first indicates the distance from the left edge of the element the second indicates the distance from the element s top edge These values can be expressed as a percentage of the display area, in units of length, or with keywords Peter Y. Wu, RMU 38

39 Background-Position Keywords and Percentages This figure shows how background-position keywords relate to the percentage values. 77 The Background-Attachment Attribute By default, background images move along with the background of the page as the user scrolls through the Web page. To change the movement of background images, use the background-attachment attribute. The syntax of this style is: background-attachment: attach attached is either scroll, to scroll the image along with the element, or fixed, which places the image in a fixed place in the browser s display window, preventing it from moving even if the user scrolls down through the Web page Peter Y. Wu, RMU 39

40 Background Images Fixed background images are often used to create the impression of a watermark. a watermark is a term that refers to a translucent graphic impressed into the very fabric of the paper and used in specialized stationery If you use a background image that employs a transparent color, you can combine the background-color and background-image attributes to create a new image. for example, the style: body {background-color: yellow; background-image: url(logo.gif)} displays logo.gif on the background, and anywhere that a transparent color appears in the logo the background color yellow will shine through 79 The Background Attribute You can combine all of the various attributes for backgrounds into one attribute, called the background attribute. The syntax for the background attribute is: background: background-color background-image backgroundrepeat background-attachment background-position background-color, background-image, etc., are the values for the various background attributes Peter Y. Wu, RMU 40

41 Using the Background Style Attribute This figure shows an example of the background style attribute. 81 Working with List Styles CSS provides more control over the appearance and behavior of ordered, unordered, and definition lists than does HTML. CSS allows you to specify the types of labels attached to list items and how to position the labels with respect to the label text. The list-style-type attribute allows you to choose the type of label to display alongside text formatted with the <ul>, <ol>, or <li> tags Peter Y. Wu, RMU 41

42 Values of the List-Style-Type Attribute This figure shows the possible values of the list-style-type attribute. 83 Creating a Nested Outline Style Use contextual selectors to create an outline style for several levels of nested lists. This figure shows a set of contextual selectors used to create an outline style for different outline levels Peter Y. Wu, RMU 42

43 Using a list-style-image Attribute You can create a label, not included in the list-styletype values, with an image file and the liststyle-image attribute. The syntax for applying this attribute is: list-style-image: url(url) URL is the location and the filename of the image file It s a good idea to include the list-style-type attribute along with the list-style-image attribute. 85 Defining the List Style Position List items are treated by CSS as if they have an invisible box around them. The syntax for specifying the location of the list item label is: list-style-position: location location is either inside or the default value, outside Peter Y. Wu, RMU 43

44 Defining the Position of the List Label This figure shows that the labels for the list items can be placed either outside or inside the box. 87 The list-style Attribute You can combine all of these attributes into the list-style attribute. The syntax for this style is: list-style: list-style-type liststyle-image list-style-position list-style-type, list-style-image, and liststyle-position are the attribute values for each of the individual list style attributes Peter Y. Wu, RMU 44

45 Defining the Appearance of a List Label This figure shows how to define the appearance of a list label. 89 Formatting Hypertext Links Hypertext has an additional attribute that normal text doesn t have: the condition of the hypertext link itself. A hypertext link can be in one of four states: the link s target has already been visited by the user the link s target has never been visited by the user the link is currently being clicked by the user the user s mouse pointer is hovering over the link Web browsers provide a visual clue for each of these states, such as a different color for visited links, and a different shape for the pointer when it is hovering over a link Peter Y. Wu, RMU 45

46 Formatting Hypertext Links Continued CSS provides a different selector for each condition. The general syntax is: a:visited {styles for previously visited targets} a:link {styles for targets that have never been visited} a:active {styles for links that are currently being clicked} a:hover {styles when the mouse cursor is hovering over the link} - this is called a rollover effect You can use a variety of CSS attributes to create a different style for each condition. for example, to change the color of previously visited targets to red, use the style: a:visited {color:red} 91 Creating a Rollover Effect This figure shows the rollover effect Peter Y. Wu, RMU 46

47 Working with ids and Classes A pseudo-class is a classification of an element based on its status or its use. in the example of the rollover effect, the status was the condition of the hypertext link the element itself, a hypertext link with the pointer located over it, is called a pseudoelement CSS introduces additional pseudo-classes, including the first-line pseudo-class and the first-letter pseudoclass, which are used for formatting the first line and first letter of a block of text, respectively. 93 Applying a Style to a Pseudo-Class This figure shows how to apply a style to a pseudo-class and what it would like in the browser Peter Y. Wu, RMU 47

48 The class Attribute Many browsers do not support the first-letter and firstline pseudo-classes yet. The only pseudo-classes widely supported are the four hypertext link conditions. You can create customized classes by adding the class attribute to HTML tags. The syntax for creating a class is: <tag class= class_name > tag is the HTML tag class_name is the name of the class 95 Applying a Style to a Pseudo-Class This figure demonstrates creating an inline style for the h1 heading with the class name First Header. This technique is useful when you have multiple Web pages in which you want the first heading in each page to be formatted in the same way Peter Y. Wu, RMU 48

49 The id Attribute Closely related to the class attribute is the id attribute, which applies an id to a specific element in the document. The id attribute must be unique; there can not be more than one tag with the same id value. The syntax for creating an id is: <tag id= id_name > tag is the HTML tag id_name is an id name assigned to the tag The class and id attribute are useful HTML features to use with CSS to define styles for specific content without using inline styles. The id selector style rule can be applied only once per web page, The class selector style rule can be applied many times. 97 Creating a Class for Monthly Specials This figure shows how to create a class for monthly specials Peter Y. Wu, RMU 49

50 Working with Container Elements HTML supports two types of container types: the <span> tag, which is used to contain inline elements such as individual letters, words, phrases, or inline images the <div> tag, which is used to group blocks of text such as paragraphs, block quotes, headings, or lists. Collectively, these text blocks are known as block-level elements 99 Using the <div> Tag This figure shows an example in which a heading and a paragraph have been enclosed in a <div> container. The <div> tag does not actually format the block-level elements; it merely groups them as a unit. For this reason, the <div> tag always includes either a class or id attribute that identifies that group Peter Y. Wu, RMU 50

51 Using the <div> and <span> Tags This figure shows an example of how the <span> tag can be used to format a selection of text within a paragraph. A <div> tag is used to format the entire paragraph. You almost always include an id or class attribute with the <span> tag. 101 Formatting Block-Level Element Boxes With CSS, you can control the layout of a Web page by manipulating the size and location of block-level elements. CSS treats all block-level elements as a group. HTML tags that can be treated as block-level elements are: <h1> - <h6> tags <p> tag <blockquote> and <address> tags <ul>, <ol>, and <dl> list tags <li>, <dt>, or <dd> tags (individual list items) <div> tag <body> tag <hr> tag <img> tag Peter Y. Wu, RMU 51

52 Parts of the Block-Level Element Box There are three elements: margin between the box and the parent element border of the box padding, which is the space between the box around the block-level element and the border CSS provides attributes you can use to control the appearance and behavior of each of these elements. 103 Features of the Box Around a Block-Level Element This figure shows features of the box around a block-level element Peter Y. Wu, RMU 52

53 Some Block-Level Elements in a Web page. This figure shows some of the boxes in a Web page. 105 Controlling Margins The margin is the space between the block-level element and the parent element. There are four attributes that control the margin size: margin-top - the space between the top of the box and the top margin margin-right - the space between the right side of the box and the right margin margin-bottom - the space between the bottom of the box and the bottom margin margin-left - the space between the left side of the box and the left margin Peter Y. Wu, RMU 53

54 Controlling Margins Continued Margin sizes can be expressed in units of length (points, pixels, em units, etc.) or as a percentage of the width of the parent element box. Use the auto value, which allows the browser to determine the margin size. A margin size can be negative, although this can lead to unpredictable results when viewed with certain browsers. 107 Creating an Overlay Effect Web page designers can use negative margins to place one block-line element on top of another, creating an overlay effect. This figure shows an example of an overlay effect Peter Y. Wu, RMU 54

55 Controlling Margins The four margin attributes can be combined into a single attribute with the syntax: selector {margin-top margin-right margin-bottom margin-left} if you only include three values in the combined attribute, they are applied in the following order: top, right, bottom, and the browser sets the left margin to match the right margin if two values are specified, they are applied to the top and right margins, and the browser sets the bottom and left margins to match the top and right margins if only one value is entered, the browser applies the value to all four margins 109 Setting Padding Size Padding refers to the amount of space between the element and its border. Four attributes are used to control the size of the element s padding: padding-top padding-right padding-bottom padding-left Peter Y. Wu, RMU 55

56 Formatting the Border CSS provides a variety of attributes for managing the box s border width, border color, and border style. To combine all of the border attributes, use the syntax: border: border-width border-style border-color; These attributes can be applied to all four borders at once, or you can work with individual borders. There are a variety of ways with which border styles can be expressed. Support for the border declaration is inconsistent across browser types and versions. 111 Different Border Attributes The figure summarizes the various border attributes Peter Y. Wu, RMU 56

57 Example of Border-Style Values Border widths can be expressed using units of length or with the keywords thin, medium, or think. The border color can be defined using color names or color values. This figure shows that each of the nine different styles that can be applied to a border. 113 Formatting the Width and Height of Block-Level Boxes To change the width of a box, use the width attribute. Box width can be expressed in terms of absolute or relative units of length, or as a percentage of the width of the parent element. for example, the style: body {width: 75%} reduces the width of the Web page body to 75% of the width of the browser s display area The width attribute is seldom used except with text boxes and inline images Peter Y. Wu, RMU 57

58 Formatting the Width and Height of Block-Level Boxes Continued The height attribute sets the height of the element. Heights can be expressed in absolute or relative lengths, but not percentages. Typically, you won t set the height of a block-level element because problems can arise when the amount of text in the element exceeds the height allowed. The height attribute is usually applied to inline images and little else. 115 The float Attribute The float attribute works like the align= left or align= right attributes used with the <img> tags. This attribute places the block-level element on the left or right margin of the parent element Peter Y. Wu, RMU 58

59 Floating a Block-Level Element This figure shows that when a browser encounters the float attribute, it moves the element over to whatever margin the Web author has specified and then brings the next blocklevel element up. The text in that element is wrapped around the floating element. 117 Using the clear Attribute Prevent other elements from wrapping around the floating element by adding the clear attribute to the element below the floating element. When the value of the clear attribute is set to right, the browser displays the element on the page at the point where the right margin is clear. Other possible values for the clear attribute are left and both (for both margins) Peter Y. Wu, RMU 59

60 An Example Web site This figure shows an example Web site with the features discussed in this tutorial. 119 Summary The concepts of cascading style sheets. Three types of style sheets: inline, embedded or global, and linked or external style sheets. Syntax of CSS: declarations, selectors, attributes, and attribute values. Style precedence and style inheritance. HTML document structure: parent and descendant elements and contextual selectors. Color and background attributes. Font and text attributes including word and letter spacing, font styles and weights, and text alignment. Style attributes applied to lists. Pseudo-Class Selectors and Styles for Hyperlinks. Class Selectors and ID Selectors Use of <div> for block elements and <span> for in-line elements. Styles to control the margin, padding, and border attributes of their block-level elements Peter Y. Wu, RMU 60

Appendix D CSS Properties and Values

Appendix D CSS Properties and Values HTML Appendix D CSS Properties and Values This appendix provides a brief review of Cascading Style Sheets (CSS) concepts and terminology, and lists CSS level 1 and 2 properties and values supported by

More information

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets 3.1 Introduction - The CSS1 specification was developed in 1996 - CSS2 was released in 1998 - CSS2.1 reflects browser implementations - CSS3 is partially finished and parts are implemented in current browsers

More information

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations 3.1 Introduction - The CSS1 specification was developed in 1996 - CSS2 was released in 1998 - CSS2.1 reflects browser implementations - CSS3 is partially finished and parts are implemented in current browsers

More information

Tutorial 3: Working with Cascading Style Sheets

Tutorial 3: Working with Cascading Style Sheets Tutorial 3: Working with Cascading Style Sheets College of Computing & Information Technology King Abdulaziz University CPCS-665 Internet Technology Objectives Review the history and concepts of CSS Explore

More information

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style precedence and style inheritance Understand the CSS use

More information

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents 3.1 Introduction - The CSS1 specification was developed in 1996 - CSS2 was released in 1998 - CSS3 is on its way - CSSs provide the means to control and change presentation of HTML documents - CSS is not

More information

CSS Selectors. element selectors. .class selectors. #id selectors

CSS Selectors. element selectors. .class selectors. #id selectors CSS Selectors Patterns used to select elements to style. CSS selectors refer either to a class, an id, an HTML element, or some combination thereof, followed by a list of styling declarations. Selectors

More information

Cascade Stylesheets (CSS)

Cascade Stylesheets (CSS) Previous versions: David Benavides and Amador Durán Toro (noviembre 2006) Last revision: Manuel Resinas (october 2007) Tiempo: 2h escuela técnica superior de ingeniería informática Departamento de Lenguajes

More information

CSS Styles Quick Reference Guide

CSS Styles Quick Reference Guide Table 1: CSS Font and Text Properties Font & Text Properties Example(s) font-family Font or typeface font-family: Tahoma font-size Size of the font font-size: 12pt font-weight Normal or bold font-weight:

More information

COSC 2206 Internet Tools. CSS Cascading Style Sheets

COSC 2206 Internet Tools. CSS Cascading Style Sheets COSC 2206 Internet Tools CSS Cascading Style Sheets 1 W3C CSS Reference The official reference is here www.w3.org/style/css/ 2 W3C CSS Validator You can upload a CSS file and the validator will check it

More information

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) Web Development & Design Foundations with HTML5 Ninth Edition Chapter 3 Configuring Color and Text with CSS Slides in this presentation contain hyperlinks. JAWS users should be able to get a list of links

More information

Introduction to Web Tech and Programming

Introduction to Web Tech and Programming Introduction to Web Tech and Programming Cascading Style Sheets Designed to facilitate separation of content and presentation from a document Allows easy modification of style for an entire page or an

More information

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC CSS Selectors & Measurments 1 Back to descendants remember walking down the document tree structure and see how parents and children interact not only is it important to know about inheritance walking

More information

Text and Layout. Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11. This presentation 2004, MacAvon Media Productions

Text and Layout. Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11. This presentation 2004, MacAvon Media Productions Text and Layout Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 11 This presentation 344 345 Text in Graphics Maximum flexibility obtained by treating text as graphics and manipulating

More information

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

<body bgcolor=  fgcolor=  link=  vlink=  alink= > These body attributes have now been deprecated, and should not be used in XHTML. CSS Formatting Background When HTML became popular among users who were not scientists, the limited formatting offered by the built-in tags was not enough for users who wanted a more artistic layout. Netscape,

More information

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB Unit 3 Cascading Style Sheets (CSS) Slides based on course material SFU Icons their respective owners 1 Learning Objectives In this unit you

More information

CASCADING STYLESHEETS

CASCADING STYLESHEETS CASCADING STYLESHEETS Cascading StyleSheets (CSS) has been mainly created because HTML is just not the right tool for precision and flexibility. HTML is not a very effective for designing web pages. Most

More information

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

CSS مفاهیم ساختار و اصول استفاده و به کارگیری CSS مفاهیم ساختار و اصول استفاده و به کارگیری Cascading Style Sheets A Cascading Style Sheet (CSS) describes the appearance of an HTML page in a separate document : مسایای استفاده از CSS It lets you separate

More information

CSS: The Basics CISC 282 September 20, 2014

CSS: The Basics CISC 282 September 20, 2014 CSS: The Basics CISC 282 September 20, 2014 Style Sheets System for defining a document's style Used in many contexts Desktop publishing Markup languages Cascading Style Sheets (CSS) Style sheets for HTML

More information

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets 3.1 Introduction - HTML is primarily concerned with content, rather than style - However, tags have presentation properties, for which browsers have default values - The CSS1 cascading style sheet specification

More information

BIM222 Internet Programming

BIM222 Internet Programming BIM222 Internet Programming Week 7 Cascading Style Sheets (CSS) Adding Style to your Pages Part II March 20, 2018 Review: What is CSS? CSS stands for Cascading Style Sheets CSS describes how HTML elements

More information

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values 3.1 Introduction - HTML is primarily concerned with content, rather than style - However, tags have presentation properties, for which browsers have default values - The CSS1 cascading style sheet specification

More information

CSS: Cascading Style Sheets

CSS: Cascading Style Sheets What are Style Sheets CSS: Cascading Style Sheets Representation and Management of Data on the Internet, CS Department, Hebrew University, 2007 A style sheet is a mechanism that allows to specify how HTML

More information

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100 Introduction to Multimedia MMP100 Spring 2016 profehagan@gmail.com thiserichagan.com/mmp100 Troubleshooting Check your tags! Do you have a start AND end tags? Does everything match? Check your syntax!

More information

Cascading Style Sheets (CSS)

Cascading Style Sheets (CSS) Cascading Style Sheets (CSS) Mendel Rosenblum 1 Driving problem behind CSS What font type and size does introduction generate? Answer: Some default from the browser (HTML tells what browser how)

More information

Tutorial 4: Creating Special Effects with CSS

Tutorial 4: Creating Special Effects with CSS Tutorial 4: Creating Special Effects with CSS College of Computing & Information Technology King Abdulaziz University CPCS-403 Internet Applications Programming Objectives Work with CSS selectors Create

More information

Introduction to CSS. Fijihosting.com Introduction to CSS page 1. What are style sheets? Lovely! How do I use them?

Introduction to CSS. Fijihosting.com Introduction to CSS page 1. What are style sheets? Lovely! How do I use them? Introduction to CSS Style sheets (or to give them their full title, cascading style sheets or CSS) are becoming more and more common on the Web. They were first introduced in a limited form to Internet

More information

HTML TUTORIAL ONE. Understanding What XHTML is Not

HTML TUTORIAL ONE. Understanding What XHTML is Not HTML TUTORIAL ONE Defining Blended HTML, XHTML and CSS HTML: o Language used to create Web pages o Create code to describe structure of a Web page XHTM: o Variation of HTML o More strictly defines how

More information

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web HTML & CSS SWE 432, Fall 2017 Design and Implementation of Software for the Web HTML: HyperText Markup Language LaToza Language for describing structure of a document Denotes hierarchy of elements What

More information

Cascading Style Sheets. Overview and Basic use of CSS

Cascading Style Sheets. Overview and Basic use of CSS Cascading Style Sheets Overview and Basic use of CSS What are Style Sheets? A World Wide Web Consortium (W3C) defined standard A way for web page designers to separate the formatting of a document from

More information

CS105 Course Reader Appendix A: HTML Reference

CS105 Course Reader Appendix A: HTML Reference Stanford CS106E Young CS105 Course Reader Appendix A: HTML Reference Tag Index by Section The tags are listed in one of nine sections as shown below: Character Appearance Elements , Bold

More information

escuela técnica superior de ingeniería informática

escuela técnica superior de ingeniería informática Tiempo: 2h escuela técnica superior de ingeniería informática Previous versions: David Benavides and Amador Durán Toro (noviembre 2006) Manuel Resinas (october 2007) Last revision:pablo Fernandez, Cambios

More information

ID1354 Internet Applications

ID1354 Internet Applications ID1354 Internet Applications CSS Leif Lindbäck, Nima Dokoohaki leifl@kth.se, nimad@kth.se SCS/ICT/KTH What is CSS? - Cascading Style Sheets, CSS provide the means to control and change presentation of

More information

CSS Cascading Style Sheets

CSS Cascading Style Sheets CSS Cascading Style Sheets site root index.html about.html services.html stylesheet.css images boris.jpg Types of CSS External Internal Inline External CSS An external style sheet is a text document with

More information

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

Session 4. Style Sheets (CSS) Reading & References.   A reference containing tables of CSS properties Session 4 Style Sheets (CSS) 1 Reading Reading & References en.wikipedia.org/wiki/css Style Sheet Tutorials www.htmldog.com/guides/cssbeginner/ A reference containing tables of CSS properties web.simmons.edu/~grabiner/comm244/weekthree/css-basic-properties.html

More information

DAY 4. Coding External Style Sheets

DAY 4. Coding External Style Sheets DAY 4 Coding External Style Sheets LESSON LEARNING TARGETS I can code and apply an embedded style sheet to a Web page. I can code and apply an external style sheet to multiple Web pages. I can code and

More information

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em>

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em> Introduction to CSS Review Question 1 Which tag is used to create a link to another page? 1. 2. 3. 4. Review Question 1 Which tag is used to create a link to another page? 1. 2.

More information

Creating and Building Websites

Creating and Building Websites Creating and Building Websites Stanford University Continuing Studies CS 21 Mark Branom branom@alumni.stanford.edu Course Web Site: http://web.stanford.edu/group/csp/cs21 Week 6 Slide 1 of 28 Week 6 Agenda

More information

CSS. Text & Font Properties. Copyright DevelopIntelligence LLC

CSS. Text & Font Properties. Copyright DevelopIntelligence LLC CSS Text & Font Properties 1 text-indent - sets amount of indentation for first line of text value: length measurement inherit default: 0 applies to: block-level elements and table cells inherits: yes

More information

The Benefits of CSS. Less work: Change look of the whole site with one edit

The Benefits of CSS. Less work: Change look of the whole site with one edit 11 INTRODUCING CSS OVERVIEW The benefits of CSS Inheritance Understanding document structure Writing style rules Attaching styles to the HTML document The cascade The box model CSS units of measurement

More information

Assignments (4) Assessment as per Schedule (2)

Assignments (4) Assessment as per Schedule (2) Specification (6) Readability (4) Assignments (4) Assessment as per Schedule (2) Oral (4) Total (20) Sign of Faculty Assignment No. 02 Date of Performance:. Title: To apply various CSS properties like

More information

CSCB20 Week 7. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

CSCB20 Week 7. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017 CSCB20 Week 7 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 Cascading Style Sheets (CSS) Examples of CSS CSS provides a powerful and stillevolving toolkit of style

More information

Web Design and Development Tutorial 03

Web Design and Development Tutorial 03 Table of Contents Web Design & Development - Tutorial 03... 2 Using and Applying CSS to XHTML... 2 Conventions... 2 What you need for this tutorial... 2 Common Terminology... 3 Parent / Child Elements...

More information

1 of 7 11/12/2009 9:29 AM

1 of 7 11/12/2009 9:29 AM 1 of 7 11/12/2009 9:29 AM Home Beginner Tutorials First Website Guide HTML Tutorial CSS Tutorial XML Tutorial Web Host Guide SQL Tutorial Advanced Tutorials Javascript Tutorial PHP Tutorial MySQL Tutorial

More information

CSS: Formatting Text. CSS for text processing: font-family. Robert A. Fulkerson

CSS: Formatting Text. CSS for text processing: font-family. Robert A. Fulkerson CSS: Formatting Text Robert A. Fulkerson College of Information Science and Technology http://www.ist.unomaha.edu/ University of Nebraska at Omaha http://www.unomaha.edu/ CSS for text processing: font-family

More information

IMY 110 Theme 6 Cascading Style Sheets

IMY 110 Theme 6 Cascading Style Sheets IMY 110 Theme 6 Cascading Style Sheets 1. Cascading Style Sheets 1.1. Cascading Style Sheets Up to now we have done styling by using the style attribute. e.g. paragraph What

More information

INFS 2150 / 7150 Intro to Web Development / HTML Programming

INFS 2150 / 7150 Intro to Web Development / HTML Programming XP Objectives INFS 2150 / 7150 Intro to Web Development / HTML Programming Designing a Web Page with Tables Create a text table Create a table using the , , and tags Create table headers

More information

Web Site Design and Development Lecture 6

Web Site Design and Development Lecture 6 Web Site Design and Development Lecture 6 CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM Inheritance Before we talk about font properties, it needs to be known that font properties are inherited by the descendants

More information

Fundamentals of Web Programming a

Fundamentals of Web Programming a Fundamentals of Web Programming a Cascading Style Sheets Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science a Copyright 2009 Teodor Rus. These slides have been developed

More information

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student Welcome Please sit on alternating rows powered by lucid & no.dots.nl/student HTML && CSS Workshop Day Day two, November January 276 powered by lucid & no.dots.nl/student About the Workshop Day two: CSS

More information

CMPT 165: More CSS Basics

CMPT 165: More CSS Basics CMPT 165: More CSS Basics Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University October 14, 2011 1 The Favorites Icon The favorites icon (favicon) is the small icon you see

More information

Client-Side Web Technologies. CSS Part I

Client-Side Web Technologies. CSS Part I Client-Side Web Technologies CSS Part I Topics Style declarations Style sources Selectors Selector specificity The cascade and inheritance Values and units CSS Cascading Style Sheets CSS specifies the

More information

Adding CSS to your HTML

Adding CSS to your HTML Adding CSS to your HTML Lecture 3 CGS 3066 Fall 2016 September 27, 2016 Making your document pretty CSS is used to add presentation to the HTML document. We have seen 3 ways of adding CSS. In this lecture,

More information

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space. HTML Summary Structure All of the following are containers. Structure Contains the entire web page. Contains information

More information

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations).

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations). WDI Fundamentals Unit 4 CSS Cheat Sheet Rule The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations). Declaration A declaration is made

More information

Chapter 3 Style Sheets: CSS

Chapter 3 Style Sheets: CSS WEB TECHNOLOGIES A COMPUTER SCIENCE PERSPECTIVE JEFFREY C. JACKSON Chapter 3 Style Sheets: CSS 1 Motivation HTML markup can be used to represent Semantics: h1 means that an element is a top-level heading

More information

2005 WebGUI Users Conference

2005 WebGUI Users Conference Cascading Style Sheets 2005 WebGUI Users Conference Style Sheet Types 3 Options Inline Embedded Linked Inline Use an inline style sheet to modify a single element one time in a page.

More information

Using Dreamweaver to Create Page Layouts

Using Dreamweaver to Create Page Layouts Using Dreamweaver to Create Page Layouts with Cascading Style Sheets (CSS) What are Cascading Style Sheets? Each cascading style sheet is a set of rules that provides consistent formatting or a single

More information

HTML/XML. HTML Continued Introduction to CSS

HTML/XML. HTML Continued Introduction to CSS HTML/XML HTML Continued Introduction to CSS Entities Special Characters Symbols such as +, -, %, and & are used frequently. Not all Web browsers display these symbols correctly. HTML uses a little computer

More information

Reading 2.2 Cascading Style Sheets

Reading 2.2 Cascading Style Sheets Reading 2.2 Cascading Style Sheets By Multiple authors, see citation after each section What is Cascading Style Sheets (CSS)? Cascading Style Sheets (CSS) is a style sheet language used for describing

More information

CSS. https://developer.mozilla.org/en-us/docs/web/css

CSS. https://developer.mozilla.org/en-us/docs/web/css CSS https://developer.mozilla.org/en-us/docs/web/css http://www.w3schools.com/css/default.asp Cascading Style Sheets Specifying visual style and layout for an HTML document HTML elements inherit CSS properties

More information

CASCADING STYLE SHEETS (CSS) BY: RIHAM ALSMARI, PNU. Lab 4

CASCADING STYLE SHEETS (CSS) BY: RIHAM ALSMARI, PNU. Lab 4 1 CASCADING STYLE SHEETS (CSS) BY: RIHAM ALSMARI, PNU Lab 4 Cascading Style Sheets (CSS) 2 Three ways to apply a style to an HTML or XHTML document: Inline Styles Embedded Style Sheet External Style Sheet

More information

Creating A Website - Part 1: Web Design principles, HTML & CSS. CSS Color Values. Hexadecimal Colors. RGB Color

Creating A Website - Part 1: Web Design principles, HTML & CSS. CSS Color Values. Hexadecimal Colors. RGB Color Notes Week 3 By: Marisa Stoolmiller CSS Color Values With CSS, colors can be specified in different ways: Color names Hexadecimal values RGB values HSL values (CSS3) HWB values (CSS4) Hexadecimal Colors

More information

INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations

INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations Hun Myoung Park (1/26/2019) Cascading Style Sheets: 1 INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations ADC5030401 (2 Credits) Introduction

More information

APPLIED COMPUTING 1P01 Fluency with Technology

APPLIED COMPUTING 1P01 Fluency with Technology APPLIED COMPUTING 1P01 Fluency with Technology Cascading Style Sheets (CSS) APCO/IASC 1P01 Brock University Brock University (APCO/IASC 1P01) Cascading Style Sheets (CSS) 1 / 39 HTML Remember web pages?

More information

Module 2 (VII): CSS [Part 4]

Module 2 (VII): CSS [Part 4] INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module 2 (VII): CSS [Part 4] Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals

More information

Html basics Course Outline

Html basics Course Outline Html basics Course Outline Description Learn the essential skills you will need to create your web pages with HTML. Topics include: adding text any hyperlinks, images and backgrounds, lists, tables, and

More information

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework Presented by Roel Fermont 1 Today more than ever, Cascading Style Sheets (CSS) have a dominant place in online business. CSS

More information

Introducing Cascading Style Sheets. Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS

Introducing Cascading Style Sheets. Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS Introducing Cascading Style Sheets Cascading Style Sheet Basics Creating Styles Using Styles Manipulating Styles Text Formatting with CSS Cascading Style Sheet Basics CSS has many benefits: The pages look

More information

CSS 1: Introduction. Chapter 3

CSS 1: Introduction. Chapter 3 CSS 1: Introduction Chapter 3 Textbook to be published by Pearson Ed 2015 in early Pearson 2014 Fundamentals of Web http://www.funwebdev.com Development What is CSS? You be styling soon CSS is a W3C standard

More information

GoSquared Equally Rounded Corners Equally Rounded Corners -webkit-border-radius -moz-border-radius border-radius Box Shadow Box Shadow -webkit-box-shadow x-offset, y-offset, blur, color Webkit Firefox

More information

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

<style type=text/css> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page*** Chapter 7 Using Advanced Cascading Style Sheets HTML is limited in its ability to define the appearance, or style, across one or mare Web pages. We use Cascading style sheets to accomplish this. Remember

More information

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo Note: We skipped Study Guide 1. If you d like to review it, I place a copy here: https:// people.rit.edu/~nbbigm/studyguides/sg-1.docx

More information

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors Unit 10 - Client Side Customisation of Web Pages Week 5 Lesson 1 CSS - Selectors Last Time CSS box model Concept of identity - id Objectives Selectors the short story (or maybe not) Web page make-over!

More information

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image GIMP WEB 2.0 MENUS Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR DYNAMIC BACKGROUND IMAGE Before you begin this tutorial, you will need

More information

Zen Garden. CSS Zen Garden

Zen Garden. CSS Zen Garden CSS Patrick Behr CSS HTML = content CSS = display It s important to keep them separated Less code in your HTML Easy maintenance Allows for different mediums Desktop Mobile Print Braille Zen Garden CSS

More information

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148 Index Numbers & Symbols (angle brackets), in HTML, 47 : (colon), in CSS, 96 {} (curly brackets), in CSS, 75, 96. (dot), in CSS, 89, 102 # (hash mark), in CSS, 87 88, 99 % (percent) font size, in CSS,

More information

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo CSS THE M\SS1NG MANUAL David Sawyer McFarland POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo Table of Contents The Missing Credits Introduction xiii I Part One: CSS

More information

CSS: formatting webpages

CSS: formatting webpages CSS: formatting webpages Why CSS? separate content from formatting (style) style can be changed easily without rewriting webpages keep formatting consistent across website allows more advanced formatting

More information

CSc 337 LECTURE 3: CSS

CSc 337 LECTURE 3: CSS CSc 337 LECTURE 3: CSS The bad way to produce styles welcome to Greasy Joe's. You will never, ever, ever beat our

More information

Chapter 4 CSS basics

Chapter 4 CSS basics Sungkyunkwan University Chapter 4 CSS basics Prepared by J. Lee and H. Choo Web Programming Copyright 2000-2018 Networking Laboratory 1/48 Copyright 2000-2012 Networking Laboratory Chapter 4 Outline 4.1

More information

CSS. Lecture 16 COMPSCI 111/111G SS 2018

CSS. Lecture 16 COMPSCI 111/111G SS 2018 CSS Lecture 16 COMPSCI 111/111G SS 2018 No CSS Styles A style changes the way the HTML code is displayed Same page displayed using different styles http://csszengarden.com Same page with a style sheet

More information

> > > > Cascading Style Sheets basics

> > > > Cascading Style Sheets basics > > > > Cascading Style Sheets basics CSS A style language used to control the design layout of an.html or.php document more efficiently and globally than using HTML attributes. Good Stuff Gives you greater

More information

Parashar Technologies HTML Lecture Notes-4

Parashar Technologies HTML Lecture Notes-4 CSS Links Links can be styled in different ways. HTML Lecture Notes-4 Styling Links Links can be styled with any CSS property (e.g. color, font-family, background, etc.). a { color: #FF0000; In addition,

More information

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube { .hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in;.tube { color: #996600; height: 3in; width: 12in; position: fixed; What is CSS? Cascading Style Sheets CSS is responsible

More information

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST GIMP WEB 2.0 MENUS Web 2.0 Menus: Horizontal Navigation Bar WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR Hover effect: CREATING AN HTML LIST Most horizontal or vertical navigation bars begin with a simple

More information

7300 Warden Avenue, Suite 503 Markham, Ontario Canada L3R 9Z6. Phone: Toll Free: Fax:

7300 Warden Avenue, Suite 503 Markham, Ontario Canada L3R 9Z6. Phone: Toll Free: Fax: HTML and CSS 7300 Warden Avenue, Suite 503 Markham, Ontario Canada L3R 9Z6 Phone: 905-479-3780 Toll Free: 877-479-3780 Fax: 905-479-1047 e-mail: info@andarsoftware.com Web: www.andarsoftware.com.com Copyright

More information

Using Advanced Cascading Style Sheets

Using Advanced Cascading Style Sheets HTML 7 Using Advanced Cascading Style Sheets Objectives You will have mastered the material in this chapter when you can: Add an embedded style sheet to a Web page Change the body and link styles using

More information

ITNP43: HTML Lecture 4

ITNP43: HTML Lecture 4 ITNP43: HTML Lecture 4 Niederst, Part III (3rd edn) 1 Style versus Content HTML purists insist that style should be separate from content and structure HTML was only designed to specify the structure and

More information

Cascading Style Sheet Quick Reference

Cascading Style Sheet Quick Reference Computer Technology 8/9 Cascading Style Sheet Quick Reference Properties Properties are listed in alphabetical order. Each property has examples of possible values. Properties are not listed if they are

More information

View all articles by Kevin Verdana, Tahoma, etc.) for the main body text of a site.

View all articles by Kevin Verdana, Tahoma, etc.) for the main body text of a site. 1 von 14 27.03.2008 09:50 Article Home» Client Side Coding» CSS Tutorials» CSS Is Easy! CSS Is Easy! By Kevin Yank January 2nd 2001 Reader Rating: 9.1 Cascading Style Sheets. The name alone is intimidating,

More information

CSS Lecture 16 COMPSCI 111/111G SS 2018

CSS Lecture 16 COMPSCI 111/111G SS 2018 No CSS CSS Lecture 16 COMPSCI 111/111G SS 2018 Styles Astyle changes the way the HTML code is displayed Same page displayed using different styles Same page with a style sheet body font-family: sans-serif;

More information

HTML and CSS COURSE SYLLABUS

HTML and CSS COURSE SYLLABUS HTML and CSS COURSE SYLLABUS Overview: HTML and CSS go hand in hand for developing flexible, attractively and user friendly websites. HTML (Hyper Text Markup Language) is used to show content on the page

More information

COMS 359: Interactive Media

COMS 359: Interactive Media COMS 359: Interactive Media Agenda Review CSS Preview Review Transparent GIF headline Review JPG buttons button1.jpg button.psd button2.jpg Review Next Step Tables CSS Introducing CSS What is CSS? Cascading

More information

ACSC 231 Internet Technologies

ACSC 231 Internet Technologies ACSC 231 Internet Technologies Lecture 7 Web Typography Efthyvoulos Kyriacou - Assoc. Prof. Frederick University Resources: C. Markides (Frederick University) Slide 1 ACSC 231: Internet Technologies 23/12/2008

More information

Introduction to WEB PROGRAMMING

Introduction to WEB PROGRAMMING Introduction to WEB PROGRAMMING Web Languages: Overview HTML CSS JavaScript content structure look & feel transitions/animation s (CSS3) interaction animation server communication Full-Stack Web Frameworks

More information

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles Using Dreamweaver 6 So far these exercises have deliberately avoided using HTML s formatting options such as the FONT tag. This is because the basic formatting available in HTML has been made largely redundant

More information

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1 Make a Website A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1 Overview Course outcome: You'll build four simple websites using web

More information

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles Using Dreamweaver CC 6 So far we have used CSS to arrange the elements on our web page. We have also used CSS for some limited formatting. In this section we will take full advantage of using CSS to format

More information

Creating a Website: Advanced Dreamweaver

Creating a Website: Advanced Dreamweaver Creating a Website: Advanced Dreamweaver Optimizing the Workspace for Accessible Page Design 1. Choose Edit > Preferences [Windows] or Dreamweaver > Preferences [Macintosh]. The Preferences dialog box

More information