1 / 25

HTML5 and CSS3 Illustrated Unit D: Formatting Text with CSS

HTML5 and CSS3 Illustrated Unit D: Formatting Text with CSS. Objectives. Assess Web fonts Declare a font family Declare font sizes Implement bold and italics. Objectives (continued). Change font colors Change background colors Use special characters Provide alternative style sheets.

Download Presentation

HTML5 and CSS3 Illustrated Unit D: Formatting Text with CSS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HTML5 and CSS3 IllustratedUnit D: Formatting Text with CSS

  2. Objectives • Assess Web fonts • Declare a font family • Declare font sizes • Implement bold and italics HTML 5 and CSS 3 – Illustrated Complete

  3. Objectives (continued) • Change font colors • Change background colors • Use special characters • Provide alternative style sheets HTML 5 and CSS 3 – Illustrated Complete

  4. Assessing Web Fonts • When formatting Web pages with different fonts, limited by fonts available on users’ machines • Makes it a challenge to ensure that Web pages appear consistently on different computers HTML 5 and CSS 3 – Illustrated Complete

  5. Assessing Web Fonts (continued) • Strategies for implementing fonts consistently: • Specifying multiple font families • Font stack: List of font families in order of preference, separated by commas • Specifying a generic font family • Generic font families: grouping of font families according to shared characteristics • Can be added to end of font stack HTML 5 and CSS 3 – Illustrated Complete

  6. Assessing Web Fonts (continued) • Strategies for implementing fonts consistently (continued): • Implementing downloadable fonts • User agent downloads and applies fonts not installed on user’s computer • Upload file containing elements of the font family to Web publishing location or reference licensed downloadable font • Add @font-face rule to style sheet • Indicates font name and location of necessary files HTML 5 and CSS 3 – Illustrated Complete

  7. Assessing Web Fonts (continued) • Generic font families HTML 5 and CSS 3 – Illustrated Complete

  8. Declaring a Font Family • font-family property: Used to specify fonts in CSS • Value is font stack that includes font family name(s) and ends with generic font family name • Can be included in any style rule to apply to elements selected in that rule • Downloadable font family name can be included in regular font stack • @font-face rule must be added HTML 5 and CSS 3 – Illustrated Complete

  9. Declaring a Font Family (continued) • Common @font-face descriptors HTML 5 and CSS 3 – Illustrated Complete

  10. Declaring Font Sizes • font-size property: used to specify font size of an element • Can specify size in many different units • Most widely supported are percent and em • Useful to specify font-sizes in style sheet to standardize visual display of headings in different browsers • Specify font size in em so that remains proportional to rest of Web page HTML 5 and CSS 3 – Illustrated Complete

  11. Declaring Font Sizes (continued) • Font size properties in style sheet and resulting presentation HTML 5 and CSS 3 – Illustrated Complete

  12. Implementing Bold and Italics • Can use CSS to format text to be bold and/or italic • font-weight property: used to make text bold • font-style property: used to add italics • span element: generic HTML element free of semantic meaning • Used to isolate specific section of a larger element • Include id attribute to create style rules HTML 5 and CSS 3 – Illustrated Complete

  13. Implementing Bold and Italics (continued) • Span element added HTML 5 and CSS 3 – Illustrated Complete

  14. Implementing Bold and Italics (continued) • Results of span element and bold and italic style rule HTML 5 and CSS 3 – Illustrated Complete

  15. Changing Font Colors • color property: used to specify the color of text and other HTML elements • Four ways to specify colors: • Name • hexadecimal format • rgb format • hsl format HTML 5 and CSS 3 – Illustrated Complete

  16. Changing Font Colors (continued) • Comparison of CSS color systems HTML 5 and CSS 3 – Illustrated Complete

  17. Changing Background Colors • You can use the background property to change the background color of HTML elements • Particularly important when working with text elements • Helps maintain contrast between text and background • Can use any of the color definition systems to set background colors HTML 5 and CSS 3 – Illustrated Complete

  18. Using Background Colors (continued) • Changes to font and background colors HTML 5 and CSS 3 – Illustrated Complete

  19. Using Special Characters • Some characters cannot be entered directly into HTML text • They may be misinterpreted as computer instructions • Character reference: formatted codes that represent characters in the HTML character set • Have the format &code; • Numeric references exist for all characters • Abbreviation references for some characters HTML 5 and CSS 3 – Illustrated Complete

  20. Using Special Characters (continued) • Important character references HTML 5 and CSS 3 – Illustrated Complete

  21. Providing Alternative Style Sheets • You may need to style a web document differently on different devices • Different resolution, screen size • Use media attribute of link element to specify which device should use the style sheet • May have multiple link elements for different media HTML 5 and CSS 3 – Illustrated Complete

  22. Providing Alternative Style Sheets (continued) • Values for the link element media attribute HTML 5 and CSS 3 – Illustrated Complete

  23. Summary • It is important to implement fonts so that they will be displayed consistently on different user agents • Font stacks are declared using the font-family property • span element: generic element used to isolate a portion of another element • Used to format the font of specific portion HTML 5 and CSS 3 – Illustrated Complete

  24. Summary (continued) • Different aspects of font can be set using CSS properties: • font-size property: set the font size • font-weight property: make font bold • font-style property: make font italic • In CSS colors can be specified using names, rgb, hexadecimal, or hsl • color property: sets font color • background property: sets background color HTML 5 and CSS 3 – Illustrated Complete

  25. Summary (continued) • Character references are used to identify characters that may be misinterpreted as computer instructions • Have the format &code; • You can specify different style sheets for different user agents • media attribute of link element HTML 5 and CSS 3 – Illustrated Complete

More Related