On Github mariohernandez / html5-css3
I am Web Designer and Drupal Themer for Mediacurrent
Worked for the Federal Government as lead Front-end Developer
I conduct community-driven and private workshops
It is the practice of building a web site or application so it provides a good level of user experience in modern browsers. However, it will degrade gracefully for those using older browsers. The system may not be as pleasant or as pretty, but the basic functionality will work on older systems.
A simple example is the use of 24-bit alpha-transparent PNGs. Those images can be displayed on modern browsers without problems. IE5.5 and IE6 would show the image, but transparency effects would fail (it can be made to work if necessary). Older browsers that do not support PNG would show alt text or an empty space.
Developers adopting graceful degradation often specify their browser support level, e.g. level 1 browsers (best experience) and level 2 browsers (degraded experience).
Progressive enhancement is similar concept to graceful degradation but in reverse. The web site or application would establish a base-level of user experience for most browsers. More advanced functionality would then be added when a browser supports it.
Going back to our image example, we might decide that our application should be functional in all graphical browsers. We could use a lower-quality GIF images by default but replace them with 24-bit PNGs when the browser supports them.
.selector { background-color: rgba(0,0,0,.5); } .lt-ie9 .selector { background-color: #999; }
.selector { background: url(images/image.png) 0 0 no-repeat; } .lt-ie9 .selector { background: url(images/image.gif) 0 0 no-repeat; }
Vs.
<picture> <source srcset="mobile.png"> <source media="(min-width: 480px)" srcset="tablet.png"> <source media="(min-width: 960px)" srcset="desktop.png"> <img src="default.png" alt="Alternate text is added in img tag"> </picture>View article for description Another great article
selector {property: value; property:value;}
body {background: white; color:blue;}
body { background: white; color: blue; }
<h1 style="color:red;font-size:24px;">Hello World!</h1>
<head> <style> h1 { color: red; font-size: 24px; } </style> </head>
<link rel="stylesheet" href="css/styles.css">
HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.
Static positioned elements are not affected by the top, bottom, left, and right properties.
An element with fixed position is positioned relative to the browser window. It will not move even if the window is scrolled:
h1 { position: fixed; top: 30px; right: 5px; }
A relative positioned element is positioned relative to its normal position.
h2 { position: relative; left: -20px; }
h2 { position: relative; right: 20px; }
The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.
DemoAn absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:
h2 { position: absolute; left: 100px; top: 150px; }
Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist. Absolutely positioned elements can overlap other elements.
When elements are positioned outside the normal flow, they can overlap other elements.
The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).
An element can have a positive or negative stack order:
img { position: absolute; left: 0px; top: 0px; z-index: -1; }
An element with greater stack order is always in front of an element with a lower stack order.
If two positioned elements overlap without a z-index specified, the element positioned last in the HTML code will be shown on top.
The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.
Demo&
Code Example Code provided by Paul Irish http://www.paulirish.com/2012/box-sizing-border-box-ftw/@media screen and (max-width: 300px) { body { background-color: lightblue; } }
With a @media query, you can write different CSS code for different media types.
This helps when you want different layout for different media types such as a screen or a printer, but also when you want different layout for different devices, which is very useful when making web pages with responsive design.
You can also have different layout when a user resizes the browser window up or down to a certain width, or height.
Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax.
Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly, particularly with the help of the Compass style library.
gem install sass
Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.
gem install sassGo
sass -v
gem install compass
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>HTML5 and CSS3</title> <link rel="stylesheet" href="css/styles.css?v=1.0"> <head> <body> Content goes here ... <script src="js/scripts.js"></script> </body> </html>