One of the most common style changes made to lists is a change in the indentation distance—that is, how far the list items are pushed over to the right. This often leads to frustration, because what works in one browser often doesn't have the same effect in another. For example, if you declare that lists have no left margin, they move over in Internet Explorer, but sit stubbornly in place in Gecko-based browsers.This article will help you understand the problems that can occur and how to avoid them.
CSS3 is the latest evolution of the Cascading Style Sheets language and aims at extending CSS2.1. It brings a lot of long-awaited novelties, like rounded corners, shadows, gradients, transitions or animations, as well as new layouts like multi-columns, flexible box or grid layouts.
Experimental parts are vendor-prefixed and should either be avoided in production environments, or used with extreme caution as both their syntax and semantics can change in the future.
The canvas rendering context provides two methods to render text:
object represents the underlying pixel data of an area of a canvas object. It contains the following read-only attributes:
The presence of whitespace in the DOM
can make manipulation of the content tree difficult in unforeseen ways. In Mozilla, all whitespace in the text content of the original document is represented in the DOM (this does not include whitespace within tags). (This is needed internally so that the editor can preserve formatting of documents and so that
will work.) This means that:
The geolocation API allows the user to provide their location to web applications if they so desire. For privacy reasons, the user is asked for permission to report location information.
The Page Visibility API lets you know when a webpage is visible or in focus.
With tabbed browsing, there is a reasonable chance that any given webpage is in the background and thus not visible to the user. When the user minimizes the webpage or moves to another tab, the API sends a
event regarding the visibility of the page. You can detect the event and perform some actions or behave differently. For example, if your web app is playing a video, it would pause the moment the user looks at another browser, and plays again when the user returns to the tab. The user does not lose their place in the video and can continue watching.
Closures are functions that refer to independent (free) variables (variables that are used locally, but defined in an enclosing scope). In other words, these functions 'remember' the environment in which they were created.
. Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of
class implementation per se (the
A CSS pseudo-class
is a keyword added to selectors that specifies a special state of the element to be selected. For example
will apply a style when the user hovers over the element specified by the selector.
At first sight a
looks like the
element, with the only clear difference being that it doesn't have the
attributes. Indeed, the
element has only two attributes,
. These are both optional and can also be set using DOM properties
. When no
attributes are specified, the canvas will initially be 300 pixels
wide and 150 pixels
high. The element can be sized arbitrarily by CSS
, but during rendering the image is scaled to fit its layout size: if the CSS sizing doesn't respect the ratio of the initial canvas, it will appear distorted.
An arrow function expression
has a shorter syntax compared to function expressions
and lexically binds the
value (does not bind its own
, or new.target
). Arrow functions are always anonymous
. These function expressions are best suited for non-method functions and they can not be used as constructors.
One addition of ECMAScript 2015 (ES6) is not new syntax or a new built-in, but a protocol. This protocol can be implemented by any object respecting some conventions.
With CSS3, you can apply multiple backgrounds to elements. These are layered atop one another with the first background you provide on top and the last background listed in the back.
Only the last background can include a background color.
The CSS visual formatting model is an algorithm that processes a document and displays it on visual media. This model is a basic concept of CSS. The visual formatting model transforms each element of the document and generates zero, one, or several boxes that conform to the CSS box model. The layout of each box is defined by:
Although it's not trivial (for security reasons), it's possible to draw DOM
content—such as HTML
—into a canvas
. This article, derived from this blog post
by Robert O'Callahan, covers how you can do it securely, safely, and in accordance with the specification.
Up until now we have only seen methods of the drawing context. If we want to apply colors to a shape, there are two important properties we can use: