330 likes | 451 Views
Using CSS to Control Appearance. 1. Objectives. You will be able to Use CSS (Cascading Style Sheets) to control the appearance of your web page. 2. Using CSS. Modern websites use CSS to specify layout and appearance of HTML pages Rather than HTML markup. There are three ways to add CSS
E N D
Objectives You will be able to • Use CSS (Cascading Style Sheets) to control the appearance of your web page. 2
Using CSS • Modern websites use CSS to specify layout and appearance of HTML pages • Rather than HTML markup. • There are three ways to add CSS • Directly inside an HTML start tag • Embedded in the <head> section • In a separate file • Sharable by many HTML files
Style Rules in <body> Tag • Apply to everything inside the body. • Additional rules can be added in enclosed HTML tags. • Higher level rules can be overridden with additional CSS rules in enclosed elements. • When there are differences the applicable rule is the one closest to the element. • This is the meaning of cascading.
Embedded Style Rules • CSS rules inside the HTML tags tend to clutter the page. • Obscure the structure. • Generally better to embed the style rules in the page head.
Embedded Style Rules Selector Declarations Property Value
Page with Embedded CSS Effect is the same.
Style Sheet File • We can clean up the HTML file even more by moving the CSS out to a separate file. • CSS file can be used by many pages.
Page in Chrome Effect is the same.
More Content <div> Hello, World! </div> <div> Call me Ishmael. Some years ago--never mind how long precisely-- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off--then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me. </div>
CSS Classes • Allow us to divide elements of a given kind into groups and specify different styling for each group.
Dividing Text into Columns • Easy in HTML5. • column-count:3 • Currently requires vendor prefix for most browsers • -webkit- Chrome and Safari • -moz- Firefox • -ms- Internet Explorer • -o- Opera
Specifying Columns .Content { color:Black; text-align:justify; font-size:small; -webkit-column-count:3; -moz-column-count:3; -ms-column-count:3; column-count:3 }
Page in IE8 Looks the same in IE9