Search completed in 1.22 seconds.
<div>: The Content Division element - HTML: Hypertext Markup Language
It has no effect on the content or layout until styled using CSS. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. As a "pure" container, the <
div> element does not inherently represent anything. Instead, it's used to group content so it can be easily styled using the class or id attributes, marking a section of a document as being written in a different language (using the lang attribute), and so on. Content categories Flow content, palpable content. Permitted content Flow content. ...
...d by one or more <dd> elements, optionally intermixed with <script> and <template> elements. Tag omission None, both the starting and ending tag are mandatory. Permitted parents Any element that accepts flow content. Or (in WHATWG HTML): <dl> element. Implicit ARIA role No corresponding role Permitted ARIA roles Any DOM interface HTML
DivElement Attributes This element includes the global attributes. Note: The align attribute is obsolete; do not use it anymore. Instead, you should use CSS properties or techniques such as CSS Grid or CSS Flexbox to align and position <
div> elements on the page. Usage notes The <
div> element should be used only when no other semantic element (such as <article> or <nav>) is appropriate...
...lement includes the global attributes. Note: The align attribute is obsolete; do not use it anymore. Instead, you should use CSS properties or techniques such as CSS Grid or CSS Flexbox to align and position <
div> elements on the page. Usage notes The <
div> element should be used only when no other semantic element (such as <article> or <nav>) is appropriate. Examples A simple example <
div> <p>Any kind of content here. Such as <p>, <table>. ...
...And 5 more matches
CSSNumericValue.div() - Web APIs
Working Draft Initial definition. ...
... Working Draft Initial definition. ...
... Working Draft Initial definition. ...
...And 2 more matches
HTMLDivElement - Web APIs
The HTML
DivElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <
div> elements. <
div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 20%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 120" preserveAspectRatio="xMinYMin meet"><a xlink:href="/docs/Web/API/EventTarget" target="_top"><rect x="1" y="1" width="110" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="56" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">EventTarget</text></a><polyline ...
...aco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">HTMLElement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#D4DDE4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#D4DDE4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#D4DDE4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#D4DDE4"/><a xlink:href="/docs/Web/API/HTML
DivElement" target="_top"><rect x="351" y="65" width="140" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="421" y="94" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">HTML
DivElement</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} Properties Inherits pro...
...idth="140" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="421" y="94" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">HTML
DivElement</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} Properties Inherits properties from its parent, HTMLElement. HTML
DivElement.align Is a DOMString representing an enumerated property indicating alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", "justify", and "center". Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specification Status Comment HTML Living StandardThe defini...
...And 2 more matches
divisor - SVG: Scalable Vector Graphics
The
divisor attribute specifies the value by which the resulting number of applying the kernelMatrix of a <feConvolveMatrix> element to the input image color value is
divided to yield the destination color value. A
divisor that is the sum of all the matrix values tends to have an evening effect on the overall color intensity of the result. ...
...sum of all the matrix values tends to have an evening effect on the overall color intensity of the result. ...
...ConvolveMatrix> html, body, svg { height: 100%; } <svg viewBox="0 0 420 200" xmlns="http://www.w3.org/2000/svg"> <filter id="convolveMatrix1" x="0" y="0" width="100%" height="100%"> <feConvolveMatrix kernelMatrix="1 2 0 0 0 0 0 0 -1"
divisor="1"/> </filter> <filter id="convolveMatrix2" x="0" y="0" width="100%" height="100%"> <feConvolveMatrix kernelMatrix="1 2 0 0 0 0 0 0 -1"
divisor="8"/> </filter> <image xlink:href="//developer.mozilla.org/files/6457/mdn_logo_only_color.png" width="200" height="200" style="filter:url(#convolveMatrix1);"/> <image xlink:href="//developer.mozilla.org/files/6457/mdn_logo_only_color.png" width="200" height="200" style="filter:url(#convolveMatrix2); transform:translateX(220px);"/> </svg> Usage notes Value <...
...And 2 more matches
ANGLE_instanced_arrays.vertexAttribDivisorANGLE() - Web APIs
The ANGLE_instanced_arrays.vertexAttrib
DivisorANGLE() method of the WebGL API modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with ext.drawArraysInstancedANGLE() and ext.drawElementsInstancedANGLE(). Note: When using WebGL2, this method is available as gl.vertexAttrib
Divisor() by default. Syntax void ext.vertexAttrib
DivisorANGLE(index,
divisor); Parameters index A GLuint specifying the index of the generic vertex attributes.
divisor A GLuint specifying the number of instances that will pass between updates of the generic attribute. Return value None. ...
...s gl.vertexAttrib
Divisor() by default. Syntax void ext.vertexAttrib
DivisorANGLE(index,
divisor); Parameters index A GLuint specifying the index of the generic vertex attributes.
divisor A GLuint specifying the number of instances that will pass between updates of the generic attribute. Return value None. Examples var ext = gl.getExtension('ANGLE_instanced_arrays'); ext.vertexAttrib
DivisorANGLE(0, 2); Specifications Specification Status Comment ANGLE_instanced_arraysThe definition of 'ANGLE_instanced_arrays' in that specification. Recommendation Initial definition. ...
WebGL2RenderingContext.vertexAttribDivisor() - Web APIs
The WebGL2RenderingContext.vertexAttrib
Divisor() method of the WebGL 2 API modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with gl.drawArraysInstanced() and gl.drawElementsInstanced(). Note: When using WebGL 1, the ANGLE_instanced_arrays extension can provide this method, too. Syntax void gl.vertexAttrib
Divisor(index,
divisor); Parameters index A GLuint specifying the index of the generic vertex attributes.
divisor A GLuint specifying the number of instances that will pass between updates of the generic attribute. Return value None. ...
...(). Note: When using WebGL 1, the ANGLE_instanced_arrays extension can provide this method, too. Syntax void gl.vertexAttrib
Divisor(index,
divisor); Parameters index A GLuint specifying the index of the generic vertex attributes.
divisor A GLuint specifying the number of instances that will pass between updates of the generic attribute. Return value None. Examples gl.vertexAttrib
Divisor(0, 2); Specifications Specification Status Comment WebGL 2.0The definition of 'vertexAttrib
Divisor' in that specification. Editor's Draft Initial definition for WebGL. OpenGL ES 3.0The definition of 'glVertexAttrib
Divisor' in that specification. Standard Man page of the (similar) OpenGL API. ...
Division (/) - JavaScript
The
division operator (/) produces the quotient of its operands where the left operand is the
dividend and the right operand is the
divisor. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax Operator: x / y Examples Basic
division 1 / 2 // 0.5 Math.floor(3 / 2) // 1 1.0 / 2.0 // 0.5
Division by zero 2.0 / 0 // Infinity 2.0 / 0.0 // Infinity, because 0.0 === 0 2.0 / -0.0 // -Infinity Specifications Specification ECMAScript (ECMA-262)The definition of '
Division operator' in that specification. ...
Division assignment (/=) - JavaScript
The
division assignment operator (/=)
divides a variable by the value of the right operand and assigns the result to the variable. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax Operator: x /= y Meaning: x = x / y Examples Using
division assignment // Assuming the following variable // bar = 5 bar /= 2 // 2.5 bar /= 'foo' // NaN bar /= 0 // Infinity Specifications Specification ECMAScript (ECMA-262)The definition of 'Assignment operators' in that specification. ...
Basic Concepts of grid layout - CSS: Cascading Style Sheets
other parts of CSS such as flexbox, can help you create layouts that were previously impossible to build in CSS. It all starts by creating a grid in your grid container. The Grid container We create a grid container by declaring display: grid or display: inline-grid on an element. As soon as we do this, all direct children of that element become grid items. ...
...t were previously impossible to build in CSS. It all starts by creating a grid in your grid container. The Grid container We create a grid container by declaring display: grid or display: inline-grid on an element. As soon as we do this, all direct children of that element become grid items. In this example, I have a containing
div with a class of wrapper and, inside are five child elements. ...
...ible to build in CSS. It all starts by creating a grid in your grid container. The Grid container We create a grid container by declaring display: grid or display: inline-grid on an element. As soon as we do this, all direct children of that element become grid items. In this example, I have a containing
div with a class of wrapper and, inside are five child elements. ...
...And 92 more matches
appearance (-moz-appearance, -webkit-appearance) - CSS: Cascading Style Sheets
appearance: progress-bar; /* Partial list of available values in Gecko */ -moz-appearance: scrollbarbutton-up; -moz-appearance: button-bevel; /* Partial list of available values in WebKit/Blink (as well as Gecko and Edge) */ -webkit-appearance: media-mute-button; -webkit-appearance: caret; Values Standard keywords Value Demo Browser Description none
div{ color: black; -moz-appearance:none; -webkit-appearance:none; appearance:none; } <
div>Lorem</
div> Firefox Chrome Safari Edge No special styling is applied. This is the default. auto
div{ color: black; -moz-appearance: auto; -webkit-appearance: auto; appearance:auto; } <
div>Lorem</
div> None The user agent selects the appropriate ...
...hrome Safari Edge No special styling is applied. This is the default. auto
div{ color: black; -moz-appearance: auto; -webkit-appearance: auto; appearance:auto; } <
div>Lorem</
div> None The user agent selects the appropriate special styling based on the element. Acts as none on elements with no special styling. menulist-button
div { color: black; -moz-appearance: menulist-button; -webkit-appearance: menulist-button; } <
div>Lorem</
div> Firefox Chrome Safari Edge The element is styled as a button that would indicate a menulist can be opened. ...
... special styling based on the element. Acts as none on elements with no special styling. menulist-button
div { color: black; -moz-appearance: menulist-button; -webkit-appearance: menulist-button; } <
div>Lorem</
div> Firefox Chrome Safari Edge The element is styled as a button that would indicate a menulist can be opened. ...
...And 73 more matches
Legacy layout methods - Learn web development
ew index.html file on your computer, filling it with a simple HTML template, and inserting the below code into it at the appropriate places. At the bottom of the section you can see a live example of what the final code should look like. First of all, we need some content to put into our columns. Replace whatever is inside the body currently with the following: <h1>2 column layout example</h1> <
div> <h2>First column</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Curabitur...
...ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Curabitur vehicula tellus neque, ac ornare ex malesuada et. In vitae convallis lacus. Aliquam erat volutpat. Suspendisse ac imperdiet turpis. Aenean finibus sollicitudin eros pharetra congue. Duis ornare egestas augue ut luctus. Proin blandit quam nec lacus varius commodo et a urna. Ut id ornare felis, eget fermentum sapien.</p> </
div> <
div> <h2>Second column</h2> <p>Nam vulputate diam nec tempor bibendum. Donec luctus augue eget malesuada ultrices. Phasellus turpis est, posuere sit amet dapibus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit cursus viv...
...t dapibus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit cursus viverra quis vestibulum sem. Aliquam tincidunt eget purus in interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p> </
div> Each one of the columns needs an outer element to contain its content and let us manipulate all of it at once. In this example case we've chosen <
div>s, but you could choose something more semantically appropriate like <article>s, <section>s, and <aside>, or whatever. Now for the CSS. First, of all, apply the following to your HTML to provide some basic setup: body { width: 90%; max-width...
...And 68 more matches
Box alignment in CSS Grid Layout - CSS: Cascading Style Sheets
CSS Grid Layout implements the specification Box Alignment Level 3 which is the same standard flexbox uses for aligning items in its flex container. This specification details how alignment should work in all the different layout methods. Layout methods will conform to the specification where possible and implement in
dividual behavior based on their differences (features and constraints). While the specification currently specifies alignment details for all layout methods, browsers have not fully implemented all of the specification; however, the CSS Grid Layout method has been widely adopted. This guide presents demonstrations of how box alignment in grid layout works. You will see many similarities in how these properties and values work in flexbox. Due to grid being two-dimensiona...
...following example, I have four grid areas within my grid. ...
... padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(8, 1fr); grid-gap: 10px; grid-auto-rows: 100px; grid-template-areas: "a a a a b b b b" "a a a a b b b b" "c c c c d d d d" "c c c c d d d d"; align-items: start; } .item1 { grid-area: a; } .item2 { grid-area: b; } .item3 { grid-area: c; } .item4 { grid-area: d; } <
div class="wrapper"> <
div class="item1">Item 1</
div> <
div class="item2">Item 2</
div> <
div class="item3">Item 3</
div> <
div class="item4">Item 4</
div> </
div> Keep in mind that once you set align-items: start, the height of each child <
div> will be determined by the contents of the <
div>. This is in contrast to omitting align-items completely, in which case the height of each <
div> stretch...
...And 68 more matches
Auto-placement in CSS Grid Layout - CSS: Cascading Style Sheets
do not place some or all of the child items. You can see auto-placement in action in the simplest of ways by creating a grid on a set of items. If you give the items no placement information they will position themselves on the grid, one in each grid cell. ...
... grid, one in each grid cell. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 10px; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> </
div> Default rules for auto-placement As you can see with the above example, if you create a grid all child items will lay themselves out one into each grid cell. The default flow is to arrange items by row. Grid will lay an item out into each cell of row 1. If you have created additi...
...uto-sized. This means that they will contain the content added to them without causing an overflow. You can however control the size of these rows with the property grid-auto-rows. ...
...And 57 more matches
Using CSS gradients - CSS: Cascading Style Sheets
ng linear gradients as the example, then move on to radial, conic and repeating gradients Using linear gradients A linear gradient creates a band of colors that progress in a straight line. A basic linear gradient To create the most basic type of gradient, all you need is to specify two colors. These are called color stops. You must have at least two, but you can have as many as you want. ...
...xample, then move on to radial, conic and repeating gradients Using linear gradients A linear gradient creates a band of colors that progress in a straight line. A basic linear gradient To create the most basic type of gradient, all you need is to specify two colors. These are called color stops. You must have at least two, but you can have as many as you want. ...
..., then move on to radial, conic and repeating gradients Using linear gradients A linear gradient creates a band of colors that progress in a straight line. A basic linear gradient To create the most basic type of gradient, all you need is to specify two colors. These are called color stops. You must have at least two, but you can have as many as you want. ...
...And 56 more matches
Box-shadow generator - CSS: Cascading Style Sheets
This tool lets you construct CSS box-shadow effects, to add box shadow effects to your CSS objects. ...
... This tool lets you construct CSS box-shadow effects, to add box shadow effects to your CSS objects. ...
... This tool lets you construct CSS box-shadow effects, to add box shadow effects to your CSS objects. ...
...And 40 more matches
Relationship of grid layout to other layout methods - CSS: Cascading Style Sheets
ven the flex properties values so that they can grow and shrink from a flex-basis of 150 pixels. I have also set the flex-wrap property to wrap, so that if the space in the container becomes too narrow to maintain the flex basis, items will wrap onto a new row. ...
...p property to wrap, so that if the space in the container becomes too narrow to maintain the flex basis, items will wrap onto a new row. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> </
div> .wrapper { width: 500px; display: flex; flex-wrap: wrap; } .wrapper >
div { flex: 1 1 150px; } In the image, you can see that two items have wrapped onto a new line. These items are sharing the available space and not lining up underneath the items above. This is because...
...mn tracks. We do not need to set anything on the items themselves; they will lay themselves out one into each cell of the created grid. As you can see they stay in a strict grid, lining up in rows and columns. With five items, we get a gap on the end of row two. ...
...And 40 more matches
Using CSS transforms - CSS: Cascading Style Sheets
ick the cube shrinks is defined by the perspective property. The smaller its value is, the deeper the perspective is. HTML The HTML below creates four copies of the same box, with the perspective set at different values. ...
... the perspective property. The smaller its value is, the deeper the perspective is. HTML The HTML below creates four copies of the same box, with the perspective set at different values. ...
...its value is, the deeper the perspective is. HTML The HTML below creates four copies of the same box, with the perspective set at different values. ...
...And 39 more matches
CSS grids, logical values, and writing modes - CSS: Cascading Style Sheets
ical positioning keywords - left and right, top and bottom. If we position an item using absolute positioning, we use these physical keywords as offset values to push the item around. In the code snippet below, the item is placed 20 pixels from the top, and 30 pixels from the left of the container: .container { position: relative; } .item { position: absolute; top: 20px; left: 30px; } <
div class="container"> <
div class="item">Item</
div> </
div> Another place you might see physical keywords in use, is when using text-align: right to align text to the right. There are also physical properties in CSS. We add margins, padding, and borders using these physical properties of margin-left, padding-left, and so on. We call these keywords and properties physical because they relate to th...
... uses the default horizontal-tb, and the second uses vertical-rl. In the mode text still runs left to right, however the direction of the text is vertical - inline text now runs down the page, from top to bottom. ...
... border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; margin: 1em; color: #d9480f; max-width: 300px; } <
div class="wrapper"> <p style="writing-mode: horizontal-tb">I have writing mode set to the default <code>horizontal-tb</code></p> <p style="writing-mode: vertical-rl">I have writing mode set to <code>vertical-rl</code></p> </
div> Writing modes in grid layouts If we now take a look at a grid layout example, we can see how changing the writing mode means changing our idea of where the Block and Inline Axis are. The grid in my next example has three columns and two row tracks. This means there are three tracks running down the block axis. In default writing mode, grid auto-places items starting at the top left, movin...
...And 33 more matches
mix-blend-mode - CSS: Cascading Style Sheets
valuenormalApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscreteCreates stacking contextyes Formal syntax <blend-mode>where <blend-mode> = normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity Examples Effect of different mix-blend-mode values <
div class="grid"> <
div class="col"> <
div class="note">Blending in isolation (no blending with the background)</
div> <
div class="row isolate"> <
div class="cell"> normal <
div class="container normal"> <
div class="group"> <
div class="item firefox"></
div> <svg viewBox="0 0 150 150"> <defs> <linearGradient id="red"> ...
... <stop offset="100%" stop-color="hsl(240,0%,100%)" /> </linearGradient> </defs> <ellipse class="item R" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item G" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item B" cx="75" cy="75" rx="25" ry="70"></ellipse> </svg> </
div> </
div> </
div> <
div class="cell"> multiply <
div class="container multiply"> <
div class="group"> <
div class="item firefox"></
div> <svg viewBox="0 0 150 150"> <ellipse class="item R" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item G" cx="75" cy="75" rx="25" ry="70"></ellipse> <ell...
...multiply"> <
div class="group"> <
div class="item firefox"></
div> <svg viewBox="0 0 150 150"> <ellipse class="item R" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item G" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item B" cx="75" cy="75" rx="25" ry="70"></ellipse> </svg> </
div> </
div> </
div> <
div class="cell"> darken <
div class="container darken"> <
div class="group"> <
div class="item firefox"></
div> <svg viewBox="0 0 150 150"> <ellipse class="item R" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse class="item G" cx="75" cy="75" rx="25" ry="70"></ellipse> <ellipse...
...And 31 more matches
Using CSS transitions - CSS: Cascading Style Sheets
o may lead to unpredictable results, depending on the browser and its version, and should be avoided. Defining transitions CSS Transitions are controlled using the shorthand transition property. This is the best way to configure transitions, as it makes it easier to avoid out of sync parameters, which can be very frustrating to have to spend lots of time debugging in CSS. You can control the in
dividual components of the transition with the following sub-properties: (Note that these transitions loop infinitely only for the purpose of our examples; CSS transitions only visualize a property change from start to finish. If you need visualizations that loop, look into the CSS animation property.) transition-property Specifies the name or names of the CSS properties to which transitions sho...
...d here are animated during transitions; changes to all other properties occur instantaneously as usual. transition-duration Specifies the duration over which transitions should occur. You can specify a single duration that applies to all properties during the transition, or multiple values to allow each property to transition over a different period of time. ...
...ing transitions; changes to all other properties occur instantaneously as usual. transition-duration Specifies the duration over which transitions should occur. You can specify a single duration that applies to all properties during the transition, or multiple values to allow each property to transition over a different period of time. ...
...And 28 more matches
<blend-mode> - CSS: Cascading Style Sheets
data type describes how colors should appear when elements overlap. It is used in the background-blend-mode and mix-blend-mode properties. Syntax The <blend-mode> data type is defined using a keyword value chosen from the list below. Values normal The final color is the top color, regardless of what the bottom color is. The effect is like two opaque pieces of paper overlapping. <
div id="
div"></
div> #
div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: normal; } multiply The final color is the result of multiplying the top and bottom colors. A black layer leads to a black final layer, and a white layer leads to n...
...mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: normal; } multiply The final color is the result of multiplying the top and bottom colors. A black layer leads to a black final layer, and a white layer leads to no change. The effect is like two images printed on transparent film overlapping. <
div id="
div"></
div> #
div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: multiply; } screen The final color is the result of inverting the colors, multiplying them, and inverting that value. A black layer leads to no change, and a white...
...iles/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: multiply; } screen The final color is the result of inverting the colors, multiplying them, and inverting that value. A black layer leads to no change, and a white layer leads to a white final layer. The effect is like two images shone onto a projection screen. <
div id="
div"></
div> #
div { width: 300px; height: 300px; background: url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'); background-blend-mode: screen; } overlay The final color is the result of multiply if the bottom color is darker, or screen if the bottom color is lighter. This blend mode is equivalent to ...
...And 27 more matches
perspective-origin - CSS: Cascading Style Sheets
[ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]where <length-percentage> = <length> | <percentage> Examples Changing the perspective origin This example shows cubes with popular perspective-origin values. ...
...ngth-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]where <length-percentage> = <length> | <percentage> Examples Changing the perspective origin This example shows cubes with popular perspective-origin values. ...
... | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]where <length-percentage> = <length> | <percentage> Examples Changing the perspective origin This example shows cubes with popular perspective-origin values. ...
...And 25 more matches
Grids - Learn web development
cks. .container { display: grid; grid-template-columns: 200px 200px 200px; } Add the 2nd declaration to your CSS rule, then reload the page, and you should see that the items have rearranged themselves one into each cell of the created grid. ...
...reload the page, and you should see that the items have rearranged themselves one into each cell of the created grid. Simple Grid Example body { width: 90%; max-width: 900px; margin: 2em auto; font: .9em/1.2 Arial, Helvetica, sans-serif; } .container >
div { border-radius: 5px; padding: 10px; background-color: rgb(207,232,220); border: 2px solid rgb(79,185,227); } <
div class="container"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> <
div>Six</
div> <
div>Seven</
div> </
div> .container { display: grid; grid-template-columns: 200px 200px 200px; } Flexible grids with the fr unit In addition to creating grids using lengths and percentages, we can use the fr unit to flexibly size grid rows and columns. This unit repr...
...ou can mix fr units and fixed length tracks -- in such a case the space needed for the fixed tracks is taken away before the space is distributed to the other tracks. Simple Grid Example with fr units body { width: 90%; max-width: 900px; margin: 2em auto; font: .9em/1.2 Arial, Helvetica, sans-serif; } .container { display: grid; grid-template-columns: 2fr 1fr 1fr; } .container >
div { border-radius: 5px; padding: 10px; background-color: rgb(207,232,220); border: 2px solid rgb(79,185,227); } <
div class="container"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> <
div>Six</
div> <
div>Seven</
div> </
div> Note: The fr unit distributes available space, not all space. Therefore if on...
...And 24 more matches
Multiple-column layout - Learn web development
olumn layout, often referred to as multicol. You can follow along by downloading the multicol starting point file and adding the CSS into the appropriate places. At the bottom of the section you can see a live example of what the final code should look like. Our starting point contains some very simple HTML; a wrapper with a class of container inside which is a heading and some paragraphs. The <
div> with a class of container will become our multicol container. We switch on multicol by using one of two properties column-count or column-width. The column-count property will create as many columns as the value you give it, so if you add the following CSS to your stylesheet and reload the page, you will get three columns: .container { column-count: 3; } The columns that you create have fle...
...ive it, so if you add the following CSS to your stylesheet and reload the page, you will get three columns: .container { column-count: 3; } The columns that you create have flexible widths -- the browser works out how much space to assign each column. column-count example body { width: 90%; max-width: 900px; margin: 2em auto; font: .9em/1.2 Arial, Helvetica, sans-serif; } <
div class="container"> <h1>Simple multicol example</h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, v...
...bus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit cursus viverra quis vestibulum sem. Aliquam tincidunt eget purus in interdum. ...
...And 24 more matches
Realizing common layouts using CSS Grid Layout - CSS: Cascading Style Sheets
ertising. ...
... </nav> <article class="content"> <h1>Main article area</h1> <p>In this layout, we display the areas in source order for any screen less that 500 pixels wide. We go to a two column layout, and then to a three column layout by redefining the grid, and the placement of items on the grid.</p> </article> <aside class="side">Sidebar</aside> <
div class="ad">Advertising</
div> <footer class="main-footer">The footer</footer> </
div> As we are using grid-template-areas to create the layout. Outside of any media queries I need to name the areas. We name areas using the grid-area property. .main-head { grid-area: header; } .content { grid-area: content; } .main-nav { grid-area: nav; } .side { grid-area: sidebar; } .ad { grid...
...r { max-width: 1024px; margin: 0 auto; font: 1.2em Helvetica, arial, sans-serif; } .wrapper > * { border: 2px solid #f08c00; background-color: #ffec99; border-radius: 5px; padding: 10px; } .wrapper { display: grid; grid-template-columns: repeat(12, [col-start] 1fr); grid-gap: 20px; } To demonstrate how this grid system works I have four child elements inside my wrapper. ...
...And 24 more matches
scroll-snap-type - CSS: Cascading Style Sheets
ent's scroll parameters. If content is added, moved, deleted or resized the scroll offset may be adjusted to maintain the resting on that snap point. ...
...s. If content is added, moved, deleted or resized the scroll offset may be adjusted to maintain the resting on that snap point. ...
...set may be adjusted to maintain the resting on that snap point. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax none | [ x | y | block | inline | both ] [ mandatory | proximity ]? Examples Snapping in different axes HTML <
div class="holster"> <
div class="container x mandatory-scroll-snapping" dir="ltr"> <
div>X Mand. ...
...And 24 more matches
Block formatting context - Developer guides
cept layout. There's no floating children avaliable inside a flex/grid container, but exclude external floats and suppress margin collapsing still works. Examples Contain internal floats Make float content and alongside content the same height. Let's have a look at a couple of these in order to see the effect creating a new BFC. ...
...le inside a flex/grid container, but exclude external floats and suppress margin collapsing still works. Examples Contain internal floats Make float content and alongside content the same height. Let's have a look at a couple of these in order to see the effect creating a new BFC. In the following example, we have a floated element inside a <
div> with a border applied. The content of that <
div> has floated alongside the floated element. As the content of the float is taller than the content alongside it, the border of the <
div> now runs through the float. As explained in the guide to in-flow and out of flow elements, the float has been taken out of flow so the background and border of the <
div> only contain the content and not the float. using overflow: auto Setting overflow: auto or...
...Any child element will be contained inside it. The problem with using overflow to create a new BFC is that the overflow property is meant for telling the browser how you want to deal with overflowing content. ...
...And 23 more matches
Border-image generator - CSS: Cascading Style Sheets
This tool can be used to generate CSS3 border-image values. ...
... This tool can be used to generate CSS3 border-image values. ...
... This tool can be used to generate CSS3 border-image values. ...
...And 22 more matches
Line-based placement with CSS Grid - CSS: Cascading Style Sheets
elements. If we do not place these on to the grid in any way they will lay out according to the auto-placement rules, one item in each of the first four cells. If you use the Firefox Grid Highlighter you can see how the grid has defined columns and rows. ...
...ws. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 100px); } <
div class="wrapper"> <
div class="box1">One</
div> <
div class="box2">Two</
div> <
div class="box3">Three</
div> <
div class="box4">Four</
div> </
div> Positioning items by line number We can use line-based placement to control where these items sit on the grid. I would like the first item to start on the far left of the grid and span a single column track. It should also start on the first r...
... .box1 { grid-column-start: 1; grid-column-end: 2; grid-row-start: 1; grid-row-end: 4; } As you position some items, other items on the grid will continue to be laid out using the auto-placement rules. We will take a proper look at how these work in a later guide but you can see as you work that grid is laying out un-placed items into empty cells of the grid. Addressing each item in
dividually we can place all four items spanning row and column tracks. Note that we can leave cells empty if we wish. One of the very nice things about Grid Layout is this ability to have white space in our designs without having to push things around using margins to prevent floats from rising up into the space we have left. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; ...
...And 22 more matches
Advanced Example - XSLT: Extensible Stylesheet Language Transformations
The example allows sorting the content multiple times, alternating between ascending and descending order. The JavaScript loads the .xsl file only on the first sort and sets the xslloaded variable to true once it has finished loading the file. Using the XSLTProcessor.getParameter() method, the code can figure whether to sort in ascending or descending order. It defaults to ascending if the parameter is empty (the first time the sorting happens, as there is no value for it in the XSLT file). The sorting value is set using XSLTProcessor.setParameter(). ...
... change the sorting method. The xsl:sort element's order attribute can access the value of the parameter using $myOrder. However, the value needs to be an XPATH expression and not a string, so {$myOrder} is used. Using {} evaluates the content as an XPath expression. Once the transformation is complete, the result is appended to the document, as shown in this example. ...
...nt's order attribute can access the value of the parameter using $myOrder. However, the value needs to be an XPATH expression and not a string, so {$myOrder} is used. Using {} evaluates the content as an XPath expression. Once the transformation is complete, the result is appended to the document, as shown in this example. ...
...And 22 more matches
ARIA: gridcell role - Accessibility
The gridcell role is used to make a cell in a grid or treegrid. It is intended to mimic the functionality of the HTML td element for table-style grouping of information. <
div role="gridcell">Potato</
div> <
div role="gridcell">Cabbage</
div> <
div role="gridcell">Onion</
div> Elements that have role="gridcell" applied to them must be the child of an element with a role of row. <
div role="row"> <
div role="gridcell">Jane</
div> <
div role="gridcell">Smith</
div> <
div role="gridcell">496-619-5098</
div> ... </
div> The first rule of ARIA is if a native HTML element or attribute has the semantics and behavior you require, use it instead of re-purposing an element and adding ARIA. Instead use the native HTML td element in conjunction with the and contenteditable attribute: <td>Potato</td> <t...
...olcount and aria-rowcount on the parent element with role="grid" applied to it to set the total number of columns or rows. This sample code demonstrates a table-style grouping of information where the third and fourth columns have been removed. ...
...t element with role="grid" applied to it to set the total number of columns or rows. This sample code demonstrates a table-style grouping of information where the third and fourth columns have been removed. ...
...And 21 more matches
Migrate apps from Internet Explorer to Mozilla - Archive of obsolete content
ven through the element's name, which Internet Explorer does (also called global namespace polluting). Mozilla also does not support the Netscape 4 document.layers method and Internet Explorer's document.all. While document.getElementById lets you retrieve one element, you can also use document.layers and document.all to obtain a list of all document elements with a certain tag name, such as all <
div> elements. The W3C DOM Level 1 method gets references to all elements with the same tag name through getElementsByTagName(). The method returns an array in JavaScript, and can be called on the document element or other nodes to search only their subtree. To get an array of all elements in the DOM tree, you can use getElementsByTagName("*"). The DOM Level 1 methods, as shown in Table 1, are comm...
...array of all elements in the DOM tree, you can use getElementsByTagName("*"). The DOM Level 1 methods, as shown in Table 1, are commonly used to move an element to a certain position and toggle its visibility (menus, animations). Netscape 4 used the <layer> tag, which Mozilla does not support, as an HTML element that can be positioned anywhere. In Mozilla, you can position any element using the <
div> tag, which Internet Explorer uses as well and which you'll find in the HTML specification. Table 1. Methods used to access elements Method Description document.getElementById( aId ) Returns a reference to the element with the specified ID. document.getElementsByTagName( aTagName ) Returns an array of elements with the specified name in the document. T...
...e, by new line characters. Mozilla will not skip these, so sometimes you need to distinguish these nodes. Every node has a nodeType property specifying the node type. For example, an element node has type 1, while a text node has type 3 and a comment node is type 8. ...
...And 20 more matches
Linear-gradient Generator - CSS: Cascading Style Sheets
linear-gradient generator HTML Content <
div id="container"> <
div id="gradient-container" data-alpha="true"> </
div> <
div id="controls"> <
div class="section"> <
div class="title"> Active point </
div> <
div class="property"> <
div class="ui-input-slider" data-topic="point-position" data-info="position" data-unit="px" data-min="-1000" data-value="0" data-max="1000" data-sensivity="5"></
div> <
div id="delete-point" class="button"> delete point </
div> </
div> <
div class="ui-color-picker" data-topic="picker"></
div> </
div> <
div class="section"> <
div class="title"> Active axis </
div> ...
... data-unit="px" data-min="-1000" data-value="0" data-max="1000" data-sensivity="5"></
div> <
div id="delete-point" class="button"> delete point </
div> </
div> <
div class="ui-color-picker" data-topic="picker"></
div> </
div> <
div class="section"> <
div class="title"> Active axis </
div> <
div class="property"> <
div class="name"> axis unit </
div> <
div class="ui-dropdown" data-topic="axis-unit" data-selected="1"> <
div data-value='px'> pixels (px) </
div> <
div data-value='%'> percentage (%) </
div> </
div> <
div id="delete-axis" class="button"> delete line </
div> ...
..."> <
div class="name"> axis unit </
div> <
div class="ui-dropdown" data-topic="axis-unit" data-selected="1"> <
div data-value='px'> pixels (px) </
div> <
div data-value='%'> percentage (%) </
div> </
div> <
div id="delete-axis" class="button"> delete line </
div> </
div> <
div class="property"> <
div class="ui-slider" data-topic="axis-rotation" data-info="rotation" data-min="-180" data-value="0" data-max="180"></
div> </
div> </
div> <
div id="tool-section" class="section"> <
div class="title"> Tool settings </
div> <
div class="property"> ...
...And 20 more matches
flex - CSS: Cascading Style Sheets
omitted. <'flex-basis'> Defines the flex-basis of the flex item. A preferred size of 0 must have a unit to avoid being interpreted as a flexibility. Defaults to 0 when omitted. Description For most purposes, authors should set flex to one of the following values: auto, initial, none, or a positive unitless number. ...
...nes the flex-basis of the flex item. A preferred size of 0 must have a unit to avoid being interpreted as a flexibility. Defaults to 0 when omitted. Description For most purposes, authors should set flex to one of the following values: auto, initial, none, or a positive unitless number. ...
...ex item. A preferred size of 0 must have a unit to avoid being interpreted as a flexibility. Defaults to 0 when omitted. Description For most purposes, authors should set flex to one of the following values: auto, initial, none, or a positive unitless number. ...
...And 20 more matches
Componentizing our Svelte app - Learn web development
following components: Alert.svelte: A general notification box for communicating actions that have occurred. NewTodo.svelte: The text input and button that allow you to enter a new todo item. FilterButton.svelte: The All, Active, and Completed buttons that allow you to apply filters to the displayed todo items. TodosStatus.svelte: The "x out of y items completed" heading. Todo.svelte: An in
dividual todo item. Each visible todo item will be displayed in a separate copy of this component. MoreActions.svelte: The Check All and Remove Completed buttons at the bottom of the UI that allow you to perform mass actions on the todo items. In this article we will concentrate on creating the FilterButton and Todo components; we'll get to the others in future articles. Let's get started. No...
... and the pros and cons of each. Extracting our filter component We'll begin by creating our FilterButton.svelte. First of all, create a new file -- components/FilterButton.svelte. Inside this file we will declare a filter prop, and then copy the relevant markup over to it from Todos.svelte. ...
...visually-hidden">Show</span> <span>Active</span> <span class="visually-hidden">tasks</span> </button> <button class="btn toggle-btn" class:btn__primary={filter === 'completed'} aria-pressed={filter === 'completed'} on:click={()=> filter = 'completed'} > <span class="visually-hidden">Show</span> <span>Completed</span> <span class="visually-hidden">tasks</span> </button> </
div> Back in our Todos.svelte component, we want to make use of our FilterButton component. First of all, we need to import it -- add the following line at the top of the Todos.svelte <script> section: import FilterButton from './FilterButton.svelte' Now, replace the filters <
div> with a call to the FilterButton component, which takes the current filter as a prop -- the below line is a...
...And 19 more matches
Index - Web APIs
ANGLE_instanced_arrays.drawElementsInstancedANGLE() ANGLE_instanced_arrays, API, Method, Reference, WebGL, WebGL extension The ANGLE_instanced_arrays.drawElementsInstancedANGLE() method of the WebGL API renders primitives from array data like the gl.drawElements() method. In addition, it can execute multiple instances of a set of elements. 5 ANGLE_instanced_arrays.vertexAttrib
DivisorANGLE() ANGLE_instanced_arrays, API, Method, Reference, WebGL, WebGL extension The ANGLE_instanced_arrays.vertexAttrib
DivisorANGLE() method of the WebGL API modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with ext.drawArraysInstancedANGLE() and ext.drawElementsInstancedANGLE(). 6 AbortController API, AbortCo...
...dioContext.createDynamicsCompressor() API, AudioContext, BaseAudioContext, Method, Reference, Web Audio API, createDynamicsCompressor Compression lowers the volume of the loudest parts of the signal and raises the volume of the softest parts. Overall, a louder, richer, and fuller sound can be achieved. It is especially important in games and musical applications where large numbers of in
dividual sounds are played simultaneously, where you want to control the overall signal level and help avoid clipping (distorting) of the audio output. 238 BaseAudioContext.createGain() API, Audio, AudioContext, BaseAudioContext, Method, Reference, Volume Control, Web Audio API, createGain, sound A GainNode which takes as input one or more audio sources and outputs audio whose vo...
... The CSSNumericValue interface of the CSS Typed Object Model API represents operations that all numeric values can perform. 421 CSSNumericValue.add() API, CSS Typed Object Model API, CSSNumericValue, Experimental, Houdini, Method, Reference, add() The add() method of the CSSNumericValue interface adds a supplied number to the CSSNumericValue. 422 CSSNumericValue.
div() API, CSS Typed Object Model API, CSSNumericValue, Experimental, Houdini, Method, Reference,
div() The
div() method of the CSSNumericValue interface
divides the CSSNumericValue by the supplied value. 423 CSSNumericValue.equals() API, CSS Typed Object Model API, CSSNumericValue, Experimental, Houdini, Method, Reference, equals() The equals() method of the CSSNumeric...
...And 19 more matches
Introduction to CSS layout - Learn web development
ollows: Note here how the HTML is displayed in the exact order in which it appears in the source code, with elements stacked up on top of one another -- the first paragraph, followed by the unordered list, followed by the second paragraph. The elements that appear one below the other are described as block elements, in contrast to inline elements, which appear one beside the other, like the in
dividual words in a paragraph. Note: The direction in which block element contents are laid out is described as the Block Direction. The Block Direction runs vertically in a language such as English, which has a horizontal writing mode. It would run horizontally in any language with a Vertical Writing Mode, such as Japanese. The corresponding Inline Direction is the direction in which inline conten...
...ut Module, designed to make it easy for us to lay things out in one dimension -- either as a row or as a column. To use flexbox, you apply display: flex to the parent element of the elements you want to lay out; all its direct children then become flex items. We can see this in a simple example. The HTML markup below gives us a containing element, with a class of wrapper, inside which are three <
div> elements. By default these would display as block elements, below one another, in our English language document. However, if we add display: flex to the parent, the three items now arrange themselves into columns. This is due to them becoming flex items and being affected by some initial values that flexbox sets on the flex container. They are displayed in a row, because the initial value of fl...
...e height of the tallest item, because the initial value of the align-items property set on their parent is stretch. This means that the items stretch to the height of the flex container, which in this case is defined by the tallest item. The items all line up at the start of the container, leaving any extra space at the end of the row. Flexbox Example 1 * {box-sizing: border-box;} .wrapper >
div { border-radius: 5px; background-color: rgb(207,232,220); padding: 1em; } .wrapper { display: flex; } <
div class="wrapper"> <
div class="box1">One</
div> <
div class="box2">Two</
div> <
div class="box3">Three</
div> </
div> In addition to the above properties that can be applied to the flex container, there are properties that can be applied to the flex items. These pro...
...And 18 more matches
ARIA: row role - Accessibility
An element with role="row" is a row of cells within a tabular structure. A row contains one or more cells, grid cells or column headers, and possibly a row header, within a grid, table or treegrid, and optionally within a rowgroup. ...
... An element with role="row" is a row of cells within a tabular structure. A row contains one or more cells, grid cells or column headers, and possibly a row header, within a grid, table or treegrid, and optionally within a rowgroup. ...
... An element with role="row" is a row of cells within a tabular structure. A row contains one or more cells, grid cells or column headers, and possibly a row header, within a grid, table or treegrid, and optionally within a rowgroup. ...
...And 18 more matches
filter - CSS: Cascading Style Sheets
</th> <th style="text-align: left;" scope="col">Static example</th> </tr> </thead> <tbody> <tr> <td><img alt="Test_Form.jpg" id="img1" class="internal default" src="/files/3710/Test_Form_2.jpg" style="width: 100%;" /></td> <td><img alt="Test_Form.jpg" id="img2" class="internal default" src="/files/3710/Test_Form_2.jpg" style="width: 100%;" /></td> <td> <
div class="svg-container"> <svg id="img3" overflow="visible" viewbox="0 0 212 161" color-interpolation-filters="sRGB"> <filter id="svgBlur" x="-5%" y="-5%" width="110%" height="110%"> <feGaussianBlur in="SourceGraphic" stdDeviation="3.5"/> </filter> <image xlink:href="/files/3710/Test_Form_2.jpeg" filter="url(#svgBlur)" width="212px" height=...
...g id="img3" overflow="visible" viewbox="0 0 212 161" color-interpolation-filters="sRGB"> <filter id="svgBlur" x="-5%" y="-5%" width="110%" height="110%"> <feGaussianBlur in="SourceGraphic" stdDeviation="3.5"/> </filter> <image xlink:href="/files/3710/Test_Form_2.jpeg" filter="url(#svgBlur)" width="212px" height="161px"/> </svg> </
div> </td> <td><img alt="Test_Form_s.jpg" id="img4" class="internal default" src="/files/3711/Test_Form_2_s.jpg" style="width: 100%;" /></td> </tr> </tbody> </table> html { height:100%; } body { font: 14px/1.286 "Lucida Grande", "Lucida Sans Unicode", "DejaVu Sans", Lucida, Arial, Helvetica, sans-serif; color: rgb(51, 51, 51); height:100%; overflow:hidden; } #img2 { wid...
...VG Equivalent</th> <th style="text-align: left;" scope="col">Static example</th> </tr> </thead> <tbody> <tr> <td><img alt="Test_Form.jpg" id="img1" class="internal default" src="/files/3708/Test_Form.jpg" style="width: 100%;" /></td> <td><img alt="Test_Form.jpg" id="img2" class="internal default" src="/files/3708/Test_Form.jpg" style="width: 100%;" /></td> <td><
div class="svg-container"><svg xmlns="http://www.w3.org/2000/svg" id="img3" viewbox="0 0 286 217" color-interpolation-filters="sRGB"> <filter id="brightness"> <feComponentTransfer> <feFuncR type="linear" slope="2"/> <feFuncG type="linear" slope="2"/> <feFuncB type="linear" slope="2"/> </feComponentTransfer> </filter> <image xlink:href="/files/3708/Test_Form.jpg" f...
...And 18 more matches
Element.closest() - Web APIs
Syntax var closestElement = targetElement.closest(selectors); Parameters selectors is a DOMString containing a selector list. ex: p:hover, .toto + q Return value closestElement is the Element which is the closest ancestor of the selected element. It may be null. Exceptions SyntaxError is thrown if the selectors is not a valid selector list string. ...
... var closestElement = targetElement.closest(selectors); Parameters selectors is a DOMString containing a selector list. ex: p:hover, .toto + q Return value closestElement is the Element which is the closest ancestor of the selected element. It may be null. Exceptions SyntaxError is thrown if the selectors is not a valid selector list string. ...
...ment = targetElement.closest(selectors); Parameters selectors is a DOMString containing a selector list. ex: p:hover, .toto + q Return value closestElement is the Element which is the closest ancestor of the selected element. It may be null. Exceptions SyntaxError is thrown if the selectors is not a valid selector list string. ...
...And 17 more matches
ARIA: rowgroup role - Accessibility
An element with role="rowgroup" is a group of rows within a tabular structure. A rowgroup contains one or more rows of cells, grid cells, column headers, or row headers within a grid, table or treegrid. ...
... An element with role="rowgroup" is a group of rows within a tabular structure. A rowgroup contains one or more rows of cells, grid cells, column headers, or row headers within a grid, table or treegrid. ...
... An element with role="rowgroup" is a group of rows within a tabular structure. A rowgroup contains one or more rows of cells, grid cells, column headers, or row headers within a grid, table or treegrid. ...
...And 17 more matches
Color picker tool - CSS: Cascading Style Sheets
ColorPicker tool HTML <
div id="container"> <
div id="palette" class="block"> <
div id="color-palette"></
div> <
div id="color-info"> <
div class="title"> CSS Color </
div> </
div> </
div> <
div id="picker" class="block"> <
div class="ui-color-picker" data-topic="picker" data-mode="HSL"></
div> <
div id="picker-samples" sample-id="master"></
div> <
div id="controls"> <
div id="delete"> <
div id="trash-can"></
div> </
div> <
div id="void-sample" class="icon"></
div> </
div> </
div> <
div id="canvas" data-tutorial="drop"> <
div id="zindex" class="ui-input-slider" data-topic="z-index" da...
...ontrols"> <
div id="delete"> <
div id="trash-can"></
div> </
div> <
div id="void-sample" class="icon"></
div> </
div> </
div> <
div id="canvas" data-tutorial="drop"> <
div id="zindex" class="ui-input-slider" data-topic="z-index" data-info="z-index" data-max="20" data-sensivity="10"></
div> </
div> </
div> CSS /* * COLOR PICKER TOOL */ .ui-color-picker { width: 420px; margin: 0; border: 1px solid #DDD; background-color: #FFF; display: table; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } .ui-color-picker .picking-area { width: 198px; height: 198px; margin: 5px; border: 1px solid #DDD; position: relativ...
...putChangeHexa.bind(this)); this.setColor(this.color); pickers[topic] = this; } /*************************************************************************/ // Function for generating the color-picker /*************************************************************************/ ColorPicker.prototype.createPickingArea = function createPickingArea() { var area = document.createElement('
div'); var picker = document.createElement('
div'); area.className = 'picking-area'; picker.className = 'picker'; this.picking_area = area; this.color_picker = picker; setMouseTracking(area, this.updateColor.bind(this)); area.appendChild(picker); this.node.appendChild(area); }; ColorPicker.prototype.createHueArea = function createHueArea() { var area = document.createElement('d...
...And 17 more matches
Grid template areas - CSS: Cascading Style Sheets
9, 1fr); grid-auto-rows: minmax(100px, auto); grid-template-areas: "hd hd hd hd hd hd hd hd hd" "sd sd sd main main main main main main" "ft ft ft ft ft ft ft ft ft"; } * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; max-width: 940px; margin: 0 auto; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } <
div class="wrapper"> <
div class="header">Header</
div> <
div class="sidebar">Sidebar</
div> <
div class="content">Content</
div> <
div class="footer">Footer</
div> </
div> Using this method we do not need to specify anything at all on the in
dividual gri...
... the main content I would need to leave the three cells underneath the sidebar empty. .header { grid-area: hd; } .footer { grid-area: ft; } .content { grid-area: main; } .sidebar { grid-area: sd; } * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; max-width: 940px; margin: 0 auto; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(9, 1fr); grid-auto-rows: minmax(100px, auto); grid-template-areas: "hd hd hd hd hd hd hd hd hd" "sd sd sd main main main main main main" ". . . ft ft ft ft f...
... 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(9, 1fr); grid-auto-rows: minmax(100px, auto); grid-template-areas: "hd hd hd hd hd hd hd hd hd" "sd sd sd main main main main main main" ". . . ft ft ft ft ft ft"; } <
div class="wrapper"> <
div class="header">Header</
div> <
div class="sidebar">Sidebar</
div> <
div class="content">Content</
div> <
div class="footer">Footer</
div> </
div> In order to make the layout neater I can use multiple . characters. As long as there is no white space between the full stops it will be counted as one cell. For a complex layout there is a benefit to having the rows and...
...And 17 more matches
Stacking context example 1 - CSS: Cascading Style Sheets
<< CSS << Understanding CSS z-index Stacking context example 1 Let's start with a basic example. In the root stacking context we have two
DIVs (
DIV #1 and
DIV #3), both relatively positioned, but without z-index properties. Inside
DIV #1 there is an absolutely positioned
DIV #2, while in
DIV #3 there is an absolutely positioned
DIV #4, both without z-index properties. The only stacking context is the root context. Without z-indexes, elements are stacked in order of occurrence. If
DIV #2 is assigned a positive (non-zero and non-auto) z-index value, it is rendered above all the other
DIVs. ...
...x properties. Inside
DIV #1 there is an absolutely positioned
DIV #2, while in
DIV #3 there is an absolutely positioned
DIV #4, both without z-index properties. The only stacking context is the root context. Without z-indexes, elements are stacked in order of occurrence. If
DIV #2 is assigned a positive (non-zero and non-auto) z-index value, it is rendered above all the other
DIVs. Then if
DIV #4 is also assigned a positive z-index greater than
DIV #2's z-index, it is rendered above all the other
DIVs including
DIV #2. In this last example you can see that
DIV #2 and
DIV #4 are not siblings, because they belong to different parents in the HTML elements' hierarchy. Even so, stacking of
DIV #4 with respect of
DIV #2 can be controlled through z-index. ...
...Then if
DIV #4 is also assigned a positive z-index greater than
DIV #2's z-index, it is rendered above all the other
DIVs including
DIV #2. In this last example you can see that
DIV #2 and
DIV #4 are not siblings, because they belong to different parents in the HTML elements' hierarchy. Even so, stacking of
DIV #4 with respect of
DIV #2 can be controlled through z-index. It happens that, since
DIV #1 and
DIV #3 are not assigned any z-index value, they do not create a stacking context. This means that all their content, including
DIV #2 and
DIV #4, belongs to the same root stacking context. ...
...And 17 more matches
<input type="text"> - HTML: Hypertext Markup Language
, what label to put on the enter key. Using text inputs <input> elements of type text create basic, single-line inputs. You should use them anywhere you want the user to enter a single-line value and there isn't a more specific input type available for collecting that value (for example, if it's a date, URL, email, or search term, you've got better options available). Basic example <form> <
div> <label for="uname">Choose a username: </label> <input type="text" id="uname" name="name"> </
div> <
div> <button>Submit</button> </
div> </form> This renders like so: When submitted, the data name/value pair sent to the server will be uname=Chris (if "Chris" was entered as the input value before submission). You must remember to include name attribute on the <input> element, o...
...d as the input value before submission). You must remember to include name attribute on the <input> element, otherwise the text field's value won't be included with the submitted data. Setting placeholders You can provide a useful placeholder inside your text input that can provide a hint as to what to enter by including using the placeholder attribute. ...
...ed with the submitted data. Setting placeholders You can provide a useful placeholder inside your text input that can provide a hint as to what to enter by including using the placeholder attribute. Look at the following example: <form> <
div> <label for="uname">Choose a username: </label> <input type="text" id="uname" name="name" placeholder="Lower case, all one word"> </
div> <
div> <button>Submit</button> </
div> </form> You can see how the placeholder is rendered below: The placeholder is typically rendered in a lighter color than the element's foreground color, and automatically vanishes when the user begins to enter text into the field (or whenever the field has a value set programmatically by setting its value attribute. Physical input element size T...
...And 17 more matches
itemprop - HTML: Hypertext Markup Language
more properties forms an item. Property values are either a string or a URL and can be associated with a very wide range of elements including <audio>, <embed>, <iframe>, <img>, <link>, <object>, <source> , <track>, and <video>. Examples The example below shows the source for a set of elements marked up with itemprop attributes, followed by a table showing the resulting structured data. ...
...ibutes, followed by a table showing the resulting structured data. HTML <
div itemscope itemtype="http://schema.org/Movie"> <h1 itemprop="name">Avatar</h1> <span>Director: <span itemprop="director">James Cameron</span> (born August 16, 1954)</span> <span itemprop="genre">Science fiction</span> <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a> </
div> Structured data Item itemprop name itemprop value itemprop name Avatar itemprop director James Cameron itemprop genre Science fiction itemprop trailer ../movies/avatar-theatrical-trailer.html Properties Properties have values that are either a string or a URL. When a string value is a URL, it is expre...
...fiction itemprop trailer ../movies/avatar-theatrical-trailer.html Properties Properties have values that are either a string or a URL. When a string value is a URL, it is expressed using the <a> element and its href attribute, the <img> element and its src attribute, or other elements that link to or embed external resources. ...
...And 17 more matches
Advanced styling effects - Learn web development
(see source code), and on the <blend-mode> reference page. Note: Blend modes are also very new, and slightly less well supported than filters. There is no support as yet in Edge, and Safari only supports some of the blend mode options. background-blend-mode Again, let's look at some examples so we can understand this better. ...
...Blend modes are also very new, and slightly less well supported than filters. There is no support as yet in Edge, and Safari only supports some of the blend mode options. background-blend-mode Again, let's look at some examples so we can understand this better. ...
...odes are also very new, and slightly less well supported than filters. There is no support as yet in Edge, and Safari only supports some of the blend mode options. background-blend-mode Again, let's look at some examples so we can understand this better. ...
...And 16 more matches
SpiderMonkey Internals
ined in the source code, each of which has its own, nested script. The compiler consists of: a random-logic rather than table-driven lexical scanner, a recursive-descent parser that produces an AST, and a tree-walking code generator. Semantic and lexical feedback are used to disambiguate hard cases such as missing semicolons, assignable expressions ("lvalues" in C parlance), and whether / is the
division symbol or the start of a regular expression. The compiler attempts no error recovery; it bails out on the first error. The emitter does some constant folding and a few codegen optimizations; about the fanciest thing it does is to attach source notes to the script for the decompiler's benefit. The decompiler implements Function.toSource(), which reconstructs a function's source code. It tran...
... from a line greater than or equal to the input line, and may return the PC of a for-loop update part, if given the line number of the loop body's closing brace. Any line after the last one in a script or function maps to a PC one byte beyond the last bytecode in the script. ...
...turn the PC of a for-loop update part, if given the line number of the loop body's closing brace. Any line after the last one in a script or function maps to a PC one byte beyond the last bytecode in the script. ...
...And 16 more matches
Element.getClientRects() - Web APIs
es. The left, top, right, and bottom coordinates can still be meaningful. Fractional pixel offsets are possible. Examples These examples draw client rects in various colors. Note that the JavaScript function that paints the client rects is connected to the markup via the class withClientRectsOverlay. ...
...s three paragraphs with a <span> inside, each embedded in a <
div> block. Client rects are painted for the paragraph in the second block, and for the <span> element in the third block. <h3>A paragraph with a span inside</h3> <p>Both the span and the paragraph have a border set. The client rects are in red. ...
... the paragraph in the second block, and for the <span> element in the third block. <h3>A paragraph with a span inside</h3> <p>Both the span and the paragraph have a border set. The client rects are in red. Note that the p has onlyone border box, while the span has multiple border boxes.</p> <
div> <strong>Original</strong> <p> <span>Paragraph that spans multiple lines</span> </p> </
div> <
div> <strong>p's rect</strong> <p class="withClientRectsOverlay"> <span>Paragraph that spans multiple lines</span> </p> </
div> <
div> <strong>span's rect</strong> <p> <span class="withClientRectsOverlay">Paragraph that spans multiple lines</span> </p> </
div> Example 2: This HTML creates three ordered lists. Client rects are painted for the <ol> in the second block, and for...
...And 16 more matches
ARIA: table role - Accessibility
The table value of the ARIA role attribute identifies the element containing the role as having a non-interactive table structure containing data arranged in rows and columns, similar to the native <table> HTML element. ...
... The table value of the ARIA role attribute identifies the element containing the role as having a non-interactive table structure containing data arranged in rows and columns, similar to the native <table> HTML element. ...
...ole attribute identifies the element containing the role as having a non-interactive table structure containing data arranged in rows and columns, similar to the native <table> HTML element. ...
...And 16 more matches
grid - CSS: Cascading Style Sheets
to zero except on multi-column elementsrow-gap: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typediscrete Formal syntax <'grid-template'> | <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? | [ auto-flow && dense? ] <'grid-auto-rows'>? ...
...i-column elementsrow-gap: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typediscrete Formal syntax <'grid-template'> | <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? | [ auto-flow && dense? ] <'grid-auto-rows'>? ...
...mn elementsrow-gap: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typediscrete Formal syntax <'grid-template'> | <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? | [ auto-flow && dense? ] <'grid-auto-rows'>? ...
...And 16 more matches
<input type="tel"> - HTML: Hypertext Markup Language
r-side code fails to validate the data it receives, disaster could strike when improperly-formatted data (or data which is too large, is of the wrong type, and so forth) is entered into your database. Making telephone numbers required You can make it so that an empty input is invalid and won't be submitted to the server using the required attribute. ...
... is entered into your database. Making telephone numbers required You can make it so that an empty input is invalid and won't be submitted to the server using the required attribute. ...
...red into your database. Making telephone numbers required You can make it so that an empty input is invalid and won't be submitted to the server using the required attribute. ...
...And 16 more matches
UI pseudo-classes - Learn web development
ards to client-side form validation is whether a form input is required (it has to be filled in before the form can be submitted) or optional. <input>, <select>, and <textarea> elements have a required attribute available which, when set, means that you have to fill in that control before the form will successfully submit. ...
...be submitted) or optional. <input>, <select>, and <textarea> elements have a required attribute available which, when set, means that you have to fill in that control before the form will successfully submit. ...
...ed) or optional. <input>, <select>, and <textarea> elements have a required attribute available which, when set, means that you have to fill in that control before the form will successfully submit. ...
...And 15 more matches
HTML text fundamentals - Learn web development
ng: Giving our content structure Let's jump straight in with a live example. In the example below, add elements to the raw text in the Input field so that it appears as a heading and two paragraphs in the Output field. If you make a mistake, you can always reset it using the Reset button. If you get stuck, press the Show solution button to see the answer. ...
...aight in with a live example. In the example below, add elements to the raw text in the Input field so that it appears as a heading and two paragraphs in the Output field. If you make a mistake, you can always reset it using the Reset button. If you get stuck, press the Show solution button to see the answer. ...
...e output</h2> <
div class="output" style="min-height: 50px;"> </
div> <h2>Editable code</h2> <p class="a11y-label">Press Esc to move focus away from the code area (Tab inserts a tab character).</p> <textarea id="code" class="input" style="min-height: 100px; width: 95%">My short story I am a statistician and my name is Trish. ...
...And 15 more matches
Border-radius generator - CSS: Cascading Style Sheets
This tool can be used to generate CSS3 border-radius effects. ...
... This tool can be used to generate CSS3 border-radius effects. ...
... This tool can be used to generate CSS3 border-radius effects. ...
...And 15 more matches
Stacking with floated blocks - CSS: Cascading Style Sheets
different. Floating blocks are placed between non-positioned blocks and positioned blocks: The background and borders of the root element Descendant non-positioned blocks, in order of appearance in the HTML Floating blocks Descendant positioned elements, in order of appearance in the HTML Actually, as you can see in the example below, the background and border of the non-positioned block (
DIV #4) is completely unaffected by floating blocks, but the content is affected. This happens according to standard float behaviour. This behavior can be shown with an added rule to the above list: The background and borders of the root element Descendant non-positioned blocks, in order of appearance in the HTML Floating blocks Descendant non-positioned inline elements Descendant positioned e...
...loat behaviour. ...
... Note: If an opacity value is applied to the non-positioned block (
DIV #4), then something strange happens: the background and border of that block pops up above the floating blocks and the positioned blocks. This is due to a peculiar part of the specification: applying a opacity value creates a new stacking context (see What No One Told You About Z-Index). ...
...And 15 more matches
gap (grid-gap) - CSS: Cascading Style Sheets
solute, and normal computing to zero except on multi-column elementscolumn-gap: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typeas each of the properties of the shorthand:row-gap: a length, percentage or calc();column-gap: a length, percentage or calc(); Formal syntax <'row-gap'> <'column-gap'>? ...
...mputing to zero except on multi-column elementscolumn-gap: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typeas each of the properties of the shorthand:row-gap: a length, percentage or calc();column-gap: a length, percentage or calc(); Formal syntax <'row-gap'> <'column-gap'>? ...
...g to zero except on multi-column elementscolumn-gap: as specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typeas each of the properties of the shorthand:row-gap: a length, percentage or calc();column-gap: a length, percentage or calc(); Formal syntax <'row-gap'> <'column-gap'>? ...
...And 14 more matches
scroll-snap-stop - CSS: Cascading Style Sheets
r; justify-content: space-between; flex-flow: column nowrap; font-family: monospace; } .container { display: flex; overflow: auto; outline: 1px dashed lightgray; flex: none; } .container.x { width: 100%; height: 128px; flex-flow: row nowrap; } .container.y { width: 256px; height: 256px; flex-flow: column nowrap; } /* definite scroll snap */ .mandatory-scroll-snapping >
div { scroll-snap-stop: always; } .proximity-scroll-snapping >
div { scroll-snap-stop: normal; } /* scroll-snap */ .x.mandatory-scroll-snapping { scroll-snap-type: x mandatory; } .y.mandatory-scroll-snapping { scroll-snap-type: y mandatory; } .x.proximity-scroll-snapping { scroll-snap-type: x proximity; } .y.proximity-scroll-snapping { scroll-snap-type: y proximity; } .container >
div...
...: normal; } /* scroll-snap */ .x.mandatory-scroll-snapping { scroll-snap-type: x mandatory; } .y.mandatory-scroll-snapping { scroll-snap-type: y mandatory; } .x.proximity-scroll-snapping { scroll-snap-type: x proximity; } .y.proximity-scroll-snapping { scroll-snap-type: y proximity; } .container >
div { text-align: center; scroll-snap-align: center; flex: none; } .x.container >
div { line-height: 128px; font-size: 64px; width: 100%; height: 128px; } .y.container >
div { line-height: 256px; font-size: 128px; width: 256px; height: 256px; } /* appearance fixes */ .y.container >
div:first-child { line-height: 1.3; font-size: 64px; } /* coloration */ .container >
div:nth-child(even) { background-color: #87EA87; } .container >
div:nth-child(odd) { backgr...
...size: 64px; width: 100%; height: 128px; } .y.container >
div { line-height: 256px; font-size: 128px; width: 256px; height: 256px; } /* appearance fixes */ .y.container >
div:first-child { line-height: 1.3; font-size: 64px; } /* coloration */ .container >
div:nth-child(even) { background-color: #87EA87; } .container >
div:nth-child(odd) { background-color: #87CCEA; } HTML <
div class="container x mandatory-scroll-snapping" dir="ltr"> <
div>X Mand. ...
...And 14 more matches
perspective() - CSS: Cascading Style Sheets
mogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. This transformation is not a linear transformation in R3, and can't be represented using a Cartesian-coordinate matrix. ...
...tesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. This transformation is not a linear transformation in R3, and can't be represented using a Cartesian-coordinate matrix. ...
... Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. This transformation is not a linear transformation in R3, and can't be represented using a Cartesian-coordinate matrix. ...
...And 14 more matches
Element.querySelectorAll() - Web APIs
-live NodeList containing one Element object for each descendant node that matches at least one of the specified selectors. Note: If the specified selectors include a CSS pseudo-element, the returned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...t for each descendant node that matches at least one of the specified selectors. Note: If the specified selectors include a CSS pseudo-element, the returned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...ch descendant node that matches at least one of the specified selectors. Note: If the specified selectors include a CSS pseudo-element, the returned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...And 13 more matches
Example and tutorial: Simple synth keyboard - Web APIs
e makes use of the following Web API interfaces: AudioContext, OscillatorNode, PeriodicWave, and GainNode. Because OscillatorNode is based on AudioScheduledSourceNode, this is to some extent an example for that as well. The video keyboard HTML There are three primary components to the display for our virtual keyboard. The first is the musical keyboard itself. We draw this in a pair of nested <
div> elements so that we can make the keyboard horizontally scrollable if all the keys don't fit on the screen, without having them wrap around. The keyboard First, we create space to build the keyboard into. We will be programmatically constructing the keyboard, because doing so gives us the flexibility to configure each key as we determine the appropriate data for the corresponding note. In our c...
...screen, without having them wrap around. The keyboard First, we create space to build the keyboard into. We will be programmatically constructing the keyboard, because doing so gives us the flexibility to configure each key as we determine the appropriate data for the corresponding note. In our case, we get each key's frequency from a table, but it could be calculated algorithmically as well. <
div class="container"> <
div class="keyboard"></
div> </
div> The <
div> named "container" is the scrollable box that lets the keyboard be scrolled horiontally if it's too wide for the available space. The keys themselves will be inserted into the block of class "keyboard". The settings bar Beneath the keyboard, we'll put some controls for configuring the layer. For now, we will have two controls: ...
...oriontally if it's too wide for the available space. The keys themselves will be inserted into the block of class "keyboard". The settings bar Beneath the keyboard, we'll put some controls for configuring the layer. For now, we will have two controls: one to set the master volume and another to select what periodic waveform to use when generating notes. ...
...And 13 more matches
:only-child - CSS: Cascading Style Sheets
rst-child:last-child or :nth-child(1):nth-last-child(1), but with a lower specificity. /* Selects each <p>, but only if it is the */ /* only child of its parent */ p:only-child { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...d:last-child or :nth-child(1):nth-last-child(1), but with a lower specificity. /* Selects each <p>, but only if it is the */ /* only child of its parent */ p:only-child { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...d(1):nth-last-child(1), but with a lower specificity. /* Selects each <p>, but only if it is the */ /* only child of its parent */ p:only-child { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...And 13 more matches
place-content - CSS: Cascading Style Sheets
respecting the constraints imposed by max-height/max-width (or equivalent functionality), so that the combined size exactly fills the alignment container Formal definition Initial valuenormalApplies tomulti-line flex containersInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'align-content'> <'justify-content'>? ...
...nts imposed by max-height/max-width (or equivalent functionality), so that the combined size exactly fills the alignment container Formal definition Initial valuenormalApplies tomulti-line flex containersInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'align-content'> <'justify-content'>? ...
.../max-width (or equivalent functionality), so that the combined size exactly fills the alignment container Formal definition Initial valuenormalApplies tomulti-line flex containersInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'align-content'> <'justify-content'>? ...
...And 13 more matches
scroll-snap-destination - CSS: Cascading Style Sheets
position Formal syntax <position>where <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
... <position>where <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
...center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
...And 13 more matches
ChildNode.remove() - Web APIs
See Symbol.unscopables for more information. ...
...See Symbol.unscopables for more information. ...
...See Symbol.unscopables for more information. ...
...And 12 more matches
Element.outerHTML - Web APIs
th a new DOM tree constructed by parsing the specified htmlString. Exceptions SyntaxError An attempt was made to set outerHTML using an HTML string which is not valid. NoModificationAllowedError An attempt was made to set outerHTML on an element which is a direct child of a Document, such as Document.documentElement. ...
...String. Exceptions SyntaxError An attempt was made to set outerHTML using an HTML string which is not valid. NoModificationAllowedError An attempt was made to set outerHTML on an element which is a direct child of a Document, such as Document.documentElement. ...
... is not valid. NoModificationAllowedError An attempt was made to set outerHTML on an element which is a direct child of a Document, such as Document.documentElement. ...
...And 12 more matches
Intersection Observer API - Web APIs
resholds: The first box has a threshold for each percentage point of visibility; that is, the IntersectionObserver.thresholds array is [0.00, 0.01, 0.02, ..., 0.99, 1.00]. The second box has a single threshold, at the 50% mark. The third box has thresholds every 10% of visibility (0%, 10%, 20%, etc.). The last box has thresholds each 25%. ...
...as a threshold for each percentage point of visibility; that is, the IntersectionObserver.thresholds array is [0.00, 0.01, 0.02, ..., 0.99, 1.00]. The second box has a single threshold, at the 50% mark. The third box has thresholds every 10% of visibility (0%, 10%, 20%, etc.). The last box has thresholds each 25%. ...
...entage point of visibility; that is, the IntersectionObserver.thresholds array is [0.00, 0.01, 0.02, ..., 0.99, 1.00]. The second box has a single threshold, at the 50% mark. The third box has thresholds every 10% of visibility (0%, 10%, 20%, etc.). The last box has thresholds each 25%. ...
...And 12 more matches
ARIA: heading role - Accessibility
Description The heading role indicates to assistive technologies that this element should be treated like a heading. Screen readers would read the text and indicate that it is formatted like a heading. ...
... Description The heading role indicates to assistive technologies that this element should be treated like a heading. Screen readers would read the text and indicate that it is formatted like a heading. ...
... Description The heading role indicates to assistive technologies that this element should be treated like a heading. Screen readers would read the text and indicate that it is formatted like a heading. ...
...And 12 more matches
Stacking without the z-index property - CSS: Cascading Style Sheets
eep in mind, when the order property alters rendering from the "order of appearance in the HTML" within flex containers, it similarly affects the order for stacking context. In the example below, elements #1 through #4 are positioned elements. Element #5 is static, and so is drawn below the other four elements, even though it comes later in the HTML markup. ...
...alters rendering from the "order of appearance in the HTML" within flex containers, it similarly affects the order for stacking context. In the example below, elements #1 through #4 are positioned elements. Element #5 is static, and so is drawn below the other four elements, even though it comes later in the HTML markup. ...
...ppearance in the HTML" within flex containers, it similarly affects the order for stacking context. In the example below, elements #1 through #4 are positioned elements. Element #5 is static, and so is drawn below the other four elements, even though it comes later in the HTML markup. ...
...And 12 more matches
clip-path - CSS: Cascading Style Sheets
& [ [ top | bottom ] <length-percentage> ] ]<fill-rule> = nonzero | evenodd<box> = border-box | padding-box | content-box Examples Comparison of HTML and SVG <svg class="defs"> <defs> <clipPath id="myPath" clipPathUnits="objectBoundingBox"> <path d="M0.5,1 C0.5,1,0,0.7,0,0.3 A0.25,0.25,1,1,1,0.5,0.3 A0.25,0.25,1,1,1,1,0.3 C1,0.7,0.5,1,0.5,1 Z" /> </clipPath> </defs> </svg> <
div class="grid"> <
div class="col"> <
div class="note">clip-path: none</
div> <
div class="row"> <
div class="cell"> <span>HTML</span> <
div class="container"> <p class="none"> I LOVE<br><em>clipping</em> </p> </
div> </
div> <
div class="cell"> <span>SVG</span> <
div class="container viewbox"> <svg viewBox="0 0 192 ...
... </p> </
div> </
div> <
div class="cell"> <span>SVG</span> <
div class="container viewbox"> <svg viewBox="0 0 192 192"> <g class="none"> <rect x="24" y="24" width="144" height="144" /> <text x="96" y="91">I LOVE</text> <text x="96" y="109" class="em">clipping</text> </g> </svg> </
div> </
div> </
div> <
div class="note">clip-path: url(#myPath)<br><br> Assuming the following clipPath definition: <pre> <svg> <clipPath id="myPath" clipPathUnits="objectBoundingBox"> <path d="M0.5,1 C 0.5,1,0,0.7,0,0.3 A 0.25,0.25,1,1,1,0.5,0.3 A 0.25,0.25,1,1,1,1,0.3 C 1,0.7,0.5,1,0.5,1 Z" /> </clipPath> </svg></...
...iv> </
div> <
div class="note">clip-path: url(#myPath)<br><br> Assuming the following clipPath definition: <pre> <svg> <clipPath id="myPath" clipPathUnits="objectBoundingBox"> <path d="M0.5,1 C 0.5,1,0,0.7,0,0.3 A 0.25,0.25,1,1,1,0.5,0.3 A 0.25,0.25,1,1,1,1,0.3 C 1,0.7,0.5,1,0.5,1 Z" /> </clipPath> </svg></pre> </
div> <
div class="row"> <
div class="cell"> <span>HTML</span> <
div class="container"> <p class="svg"> I LOVE<br><em>clipping</em> </p> </
div> </
div> <
div class="cell"> <span>SVG</span> <
div class="container viewbox"> <svg viewBox="0 0 192 192"> <g class="svg"> <rect x="24" y="24" width="144...
...And 12 more matches
overflow-block - CSS: Cascading Style Sheets
toBlock-containers, flex containers, and grid containersInheritednoComputed valueas specified, except with visible/clip computing to auto/hidden respectively if one of overflow-x or overflow-y is neither visible nor clipAnimation typediscrete Formal syntax visible | hidden | clip | scroll | auto Examples HTML <ul> <li><code>overflow-block:hidden</code> -- hides the text outside the box <
div id="
div1"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </
div> </li> <li><code>overflow-block:s...
... consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ...
...etur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ...
...And 12 more matches
overflow-y - CSS: Cascading Style Sheets
x containers, and grid containersInheritednoComputed valueas specified, except with visible/clip computing to auto/hidden respectively if one of overflow-x or overflow-y is neither visible nor clipAnimation typediscrete Formal syntax visible | hidden | clip | scroll | auto Examples Setting overflow-y behavior HTML <ul> <li><code>overflow-y:hidden</code> -- hides the text outside the box <
div id="
div1"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </
div> </li> <li><code>overflow-y:scrol...
...met, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ...
...sectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ...
...And 12 more matches
perspective - CSS: Cascading Style Sheets
ick the cube shrinks is defined by the perspective property. The smaller its value is, the deeper the perspective is. HTML The HTML below creates four copies of the same box, with the perspective set at different values. ...
... the perspective property. The smaller its value is, the deeper the perspective is. HTML The HTML below creates four copies of the same box, with the perspective set at different values. ...
...its value is, the deeper the perspective is. HTML The HTML below creates four copies of the same box, with the perspective set at different values. ...
...And 12 more matches
position - CSS: Cascading Style Sheets
stacking contextyes Formal syntax static | relative | absolute | sticky | fixed Examples Relative positioning Relatively positioned elements are offset a given amount from their normal position within the document, but without the offset affecting other elements. In the example below, note how the other elements are placed as if "Two" were taking up the space of its normal location. ...
...yntax static | relative | absolute | sticky | fixed Examples Relative positioning Relatively positioned elements are offset a given amount from their normal position within the document, but without the offset affecting other elements. In the example below, note how the other elements are placed as if "Two" were taking up the space of its normal location. ...
... static | relative | absolute | sticky | fixed Examples Relative positioning Relatively positioned elements are offset a given amount from their normal position within the document, but without the offset affecting other elements. In the example below, note how the other elements are placed as if "Two" were taking up the space of its normal location. ...
...And 12 more matches
<input type="month"> - HTML: Hypertext Markup Language
ict the available dates (see Setting maximum and minimum dates), and in addition use the required attribute to make filling in the date mandatory. As a result, supporting browsers will display an error if you try to submit a date that is outside the set bounds, or an empty date field. ...
...tside the set bounds, or an empty date field. Let's look at an example; here we've set minimum and maximum dates, and also made the field required: <form> <
div> <label for="month">What month would you like to visit us (Summer months only, please)?</label> <input id="month" type="month" name="month" min="2017-06" max="2017-09" required> <span class="validity"></span> </
div> <
div> <input type="submit" value="Submit form"> </
div> </form> If you try to submit the form without both the month and year specified (or with a date outside the set bounds), the browser displays an error. Try playing with the example now: Here's a screenshot for those of you who aren't using a supporting browser: Here's the CSS used in the above example. Here we make use of th...
...sing a supporting browser: Here's the CSS used in the above example. Here we make use of the :valid and :invalid CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a <span> next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively. ...
...And 12 more matches
HTML: A good basis for accessibility - Learn web development
mes called POSH, or Plain Old Semantic HTML). This means using the correct HTML elements for their intended purpose as much as possible. You might wonder why this is so important. After all, you can use a combination of CSS and JavaScript to make just about any HTML element behave in whatever way you want. ...
... or Plain Old Semantic HTML). This means using the correct HTML elements for their intended purpose as much as possible. You might wonder why this is so important. After all, you can use a combination of CSS and JavaScript to make just about any HTML element behave in whatever way you want. ...
...ity: Easier to develop with -- as mentioned above, you get some functionality for free, plus it is arguably easier to understand. Better on mobile -- semantic HTML is arguably lighter in file size than non-semantic spaghetti code, and easier to make responsive. Good for SEO -- search engines give more importance to keywords inside headings, links, etc. than keywords included in non-semantic <
div>s, etc., so your documents will be more findable by customers. Let's get on and look at accessible HTML in more detail. Note: It is a good idea to have a screen reader set up on your local computer so that you can do some testing of the examples shown below. See our Screen readers guide for more details. Good semantics We've already talked about the importance of proper semantics, and why ...
...And 11 more matches
HTML: A good basis for accessibility - Learn web development
mes called POSH, or Plain Old Semantic HTML). This means using the correct HTML elements for their intended purpose as much as possible. You might wonder why this is so important. After all, you can use a combination of CSS and JavaScript to make just about any HTML element behave in whatever way you want. ...
... or Plain Old Semantic HTML). This means using the correct HTML elements for their intended purpose as much as possible. You might wonder why this is so important. After all, you can use a combination of CSS and JavaScript to make just about any HTML element behave in whatever way you want. ...
...ity: Easier to develop with -- as mentioned above, you get some functionality for free, plus it is arguably easier to understand. Better on mobile -- semantic HTML is arguably lighter in file size than non-semantic spaghetti code, and easier to make responsive. Good for SEO -- search engines give more importance to keywords inside headings, links, etc. than keywords included in non-semantic <
div>s, etc., so your documents will be more findable by customers. Let's get on and look at accessible HTML in more detail. Note: It is a good idea to have a screen reader set up on your local computer so that you can do some testing of the examples shown below. See our Screen readers guide for more details. Good semantics We've already talked about the importance of proper semantics, and why ...
...And 11 more matches
Floats - Learn web development
ex.html file on your computer, filling it with a simple HTML template, and inserting the below code into it at the appropriate places. At the bottom of the section, you can see a live example of what the final code should look like. First, we'll start off with some simple HTML -- add the following to your HTML body, removing anything that was inside there before: <h1>Simple float example</h1> <
div class="box">Float</
div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. </p> <p>Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Cur...
...g above the text, in normal flow. To float the text around it add the float and margin-right properties to the .box rule: .box { float: left; margin-right: 15px; width: 150px; height: 100px; border-radius: 5px; background-color: rgb(207,232,220); padding: 1em; } Now if you save and refresh you'll see something like the following: Float Example 1 <h1>Simple float example</h1> <
div class="box">Float</
div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla luctus aliquam dolor, eu lacinia lorem placerat vulputate. </p> <p>Duis felis orci, pulvinar id metus ut, rutrum luctus orci. Cras porttitor imperdiet nunc, at ultricies tellus laoreet sit amet. Sed auctor cursus massa at porta. Integer ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Cur...
...Any content that comes below the floated element in the normal layout flow will now wrap around it, filling up the space to the right-hand side of it as far up as the top of the floated element. There, it will stop. Floating the content to ...
...And 11 more matches
Introduction to events - Learn web development
do something to all of them when an event occurs on them. You might, for example, have a set of 16 tiles that disappear when selected. It is useful to always be able to just set the thing to disappear as e.target, rather than having to select it in some more difficult way. ...
...lect it in some more difficult way. In the following example (see useful-eventtarget.html for the full source code; also see it running live here), we create 16 <
div> elements using JavaScript. ...
.... In the following example (see useful-eventtarget.html for the full source code; also see it running live here), we create 16 <
div> elements using JavaScript. We then select all of them using document.querySelectorAll(), then loop through each one, adding an onclick handler to each that makes it so that a random color is applied to each one when selected: const
divs = document.querySelectorAll('
div'); for (let i = 0; i <
divs.length; i++) {
divs[i].onclick = function(e) { e.target.style.backgroundColor = bgChange(); } } The output is as follows (try clicking around on it -- have fun): Most event handlers you'll encounter have a standard set of properties and functions (methods) available on the event object; see the Event object reference for a full list. Some more advanced han...
...And 11 more matches
Element.classList - Web APIs
x const elementClasses = elementNodeReference.classList; Returns A DOMTokenList representing the contents of the element's class attribute. If the class attribute is not set or empty, it returns an empty DOMTokenList, i.e. a DOMTokenList with the length property equal to 0. The DOMTokenList itself is read-only, although you can modify it using the add() and remove() methods. ...
...entNodeReference.classList; Returns A DOMTokenList representing the contents of the element's class attribute. If the class attribute is not set or empty, it returns an empty DOMTokenList, i.e. a DOMTokenList with the length property equal to 0. The DOMTokenList itself is read-only, although you can modify it using the add() and remove() methods. ...
...Reference.classList; Returns A DOMTokenList representing the contents of the element's class attribute. If the class attribute is not set or empty, it returns an empty DOMTokenList, i.e. a DOMTokenList with the length property equal to 0. The DOMTokenList itself is read-only, although you can modify it using the add() and remove() methods. ...
...And 11 more matches
Event.eventPhase - Web APIs
This is known as bubbling, and occurs only if Event.bubbles is true. Event listeners registered for this phase are triggered during this process. For more details, see section 3.1, Event dispatch and DOM event flow, of the DOM Level 3 Events specification. ...
...spatch and DOM event flow, of the DOM Level 3 Events specification. ...
... flow, of the DOM Level 3 Events specification. ...
...And 11 more matches
Layout using named grid lines - CSS: Cascading Style Sheets
of the lines in your grid a name when you define your grid with the grid-template-rows and grid-template-columns properties. To demonstrate I'll use the simple layout created in the guide on line-based placement. This time I'll create the grid using named lines. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } When defining the grid, I name my lines inside square brackets. Those names can be anything you like. I have defined a name for the start and end of the container, both for rows and columns. Then defined the centre block of the grid as content-start and content-end again, both ...
... number. .box1 { grid-column-start: main-start; grid-row-start: main-start; grid-row-end: main-end; } .box2 { grid-column-start: content-end; grid-row-start: main-start; grid-row-end: content-end; } .box3 { grid-column-start: content-start; grid-row-start: main-start; } .box4 { grid-column-start: content-start; grid-column-end: main-end; grid-row-start: content-end; } <
div class="wrapper"> <
div class="box1">One</
div> <
div class="box2">Two</
div> <
div class="box3">Three</
div> <
div class="box4">Four</
div> </
div> Everything else about line-based placement still works in the same way and you can mix named lines and line numbers. Naming lines is useful when creating a responsive design where you redefine the grid, rather than then needing to redefine the con...
...ple above, grid will create you a named area of the main name used. Taking the above example, I have content-start and content-end both for rows and for columns. This means I get a grid area named content, and could place something in that area should I wish to. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } I'm using the same grid definitions as above, however this time I am going to place a single item into the named area content. .wrapper { display: grid; grid-template-columns: [main-start] 1fr [content-start] 1fr [content-end] 1fr [main-end]; grid-template-rows: [main-st...
...And 11 more matches
Using z-index - CSS: Cascading Style Sheets
ing layer 0 (zero). If several elements share the same z-index value (i.e., they are placed on the same layer), stacking rules explained in the section Stacking without the z-index property apply. In the following example, the layers' stacking order is rearranged using z-index. The z-index of element #5 has no effect since it is not a positioned element. ...
... If several elements share the same z-index value (i.e., they are placed on the same layer), stacking rules explained in the section Stacking without the z-index property apply. In the following example, the layers' stacking order is rearranged using z-index. The z-index of element #5 has no effect since it is not a positioned element. ...
... are placed on the same layer), stacking rules explained in the section Stacking without the z-index property apply. In the following example, the layers' stacking order is rearranged using z-index. The z-index of element #5 has no effect since it is not a positioned element. ...
...And 11 more matches
scroll-snap-coordinate - CSS: Cascading Style Sheets
Formal syntax none | <position>#where <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
... <position>#where <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
...center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
...And 11 more matches
matrix3d() - CSS: Cascading Style Sheets
ansformation can't be represented using a Cartesian-coordinate matrix, as translations are not linear transformations. a1a2a3a4b1b2b3b4c1c2c3c4d1d2d3d4 Examples Cube squashing example The following example shows a 3D cube created from DOM elements and transforms, which can be hovered/focused to apply a matrix3d() transform to it. ...
...esented using a Cartesian-coordinate matrix, as translations are not linear transformations. a1a2a3a4b1b2b3b4c1c2c3c4d1d2d3d4 Examples Cube squashing example The following example shows a 3D cube created from DOM elements and transforms, which can be hovered/focused to apply a matrix3d() transform to it. ...
...using a Cartesian-coordinate matrix, as translations are not linear transformations. a1a2a3a4b1b2b3b4c1c2c3c4d1d2d3d4 Examples Cube squashing example The following example shows a 3D cube created from DOM elements and transforms, which can be hovered/focused to apply a matrix3d() transform to it. ...
...And 11 more matches
<transform-function> - CSS: Cascading Style Sheets
rent transform functions to transform the cube with, so you can compare the effects of the different types. Choose one, and the transform is applied to the cube; after 2 seconds, the cube reverts back to its starting state. The cube's starting state is slightly rotated using transform3d(), to allow you to see the effect of all the transforms. ...
...o transform the cube with, so you can compare the effects of the different types. Choose one, and the transform is applied to the cube; after 2 seconds, the cube reverts back to its starting state. The cube's starting state is slightly rotated using transform3d(), to allow you to see the effect of all the transforms. ...
...the cube with, so you can compare the effects of the different types. Choose one, and the transform is applied to the cube; after 2 seconds, the cube reverts back to its starting state. The cube's starting state is slightly rotated using transform3d(), to allow you to see the effect of all the transforms. ...
...And 11 more matches
transform-style - CSS: Cascading Style Sheets
t on it by default, so it is transformed in the 3D space and you can see it as intended. We also provide a checkbox allowing you to toggle between this, and transform-style: flat. In this alternative state, the cube faces are all flattened onto the plane of their parent, and you might not be able to see them at all, depending on the browser you are using. ...
...is transformed in the 3D space and you can see it as intended. We also provide a checkbox allowing you to toggle between this, and transform-style: flat. In this alternative state, the cube faces are all flattened onto the plane of their parent, and you might not be able to see them at all, depending on the browser you are using. ...
...formed in the 3D space and you can see it as intended. We also provide a checkbox allowing you to toggle between this, and transform-style: flat. In this alternative state, the cube faces are all flattened onto the plane of their parent, and you might not be able to see them at all, depending on the browser you are using. ...
...And 11 more matches
<input type="radio"> - HTML: Hypertext Markup Language
.com/mdn/interactive-examples and send us a pull request. They are called radio buttons because they look and operate in a similar manner to the push buttons on old-fashioned radios, such as the one shown below. Note: Checkboxes are similar to radio buttons, but with an important distinction: radio buttons are designed for selecting one value out of a set, whereas checkboxes let you turn in
dividual values on and off. Where multiple controls exist, radio buttons allow one to be selected out of them all, whereas checkboxes allow multiple values to be selected. Value A DOMString representing the value of the radio button. Events change and input Supported common attributes checked and value IDL attributes checked and value Methods...
...e user for their preferred contact method, you might create three radio buttons, each with the name property set to contact but one with the value email, one with the value phone, and one with the value mail. The user never sees the value or the name (unless you expressly add code to display it). ...
...They each also have a unique id, which is used by the <label> element's for attribute to associate the labels with the radio buttons. ...
...And 11 more matches
Styling the Amazing Netscape Fish Cam Page - Archive of obsolete content
of it circulated around the Internet. You could see the actual fish in the mythical Netscape headquarters, any time of the day or night! (Assuming the lights were on.) It was cool, it was funny, it was pretty amazing. It's also a weird feeling when someone asks you to work on something that has near-legendary status in your mind. It's like a SCUBA enthusiast getting to join Jacques Cousteau on a
dive, even down to the required time travel. I dove right in and decided to have some fun with with the redesign, which is why I rather like the final result. To share the joy, I herein present a look into just one piece of the redesign, and how I accomplished certain effects using simple HTML and some CSS. Marking Up the Fish In the old Fish Cam page, there was a table that contained the pictures ...
...ed to break up the content so that there is a self-contained bit of markup for each fish, and then get down to styling. Here's what one of those bits looks like once all the CSS has been applied. In order to make the Fish Cam page as agile as the fish themselves, it was necessary to strip out all of the tables, font tags, and other non-validating stuff. ...
...e all the CSS has been applied. In order to make the Fish Cam page as agile as the fish themselves, it was necessary to strip out all of the tables, font tags, and other non-validating stuff. At the end of it, there were a series of
div elements that contained a picture of the fish, the name of the fish, and one or more paragraphs of text about the fish. Here's a typical (and short) example. <
div class="card"> <img src="thumb_clown_trigger.jpg" alt="Clown Trigger" border="0" width="150" height="115"> <h3>Clown Trigger</h3> <p> Our clown trigger is a bold little fish, though for a few weeks he slept a lot and didn't look well in general. He's much better now. </p> </
div> Basically, that's all that was needed. The reason for the class value being card is that the original idea was to sty...
...And 10 more matches
Getting started with HTML - Learn web development
g tag <em> at the start of the line. To close the element, put the closing tag </em> at the end of the line. Doing this should give the line italic text formatting! See your changes update live in the Output area. If you make a mistake, you can clear your work using the Reset button. If you get really stuck, press the Show solution button to see the answer. ...
...e element, put the closing tag </em> at the end of the line. Doing this should give the line italic text formatting! See your changes update live in the Output area. If you make a mistake, you can clear your work using the Reset button. If you get really stuck, press the Show solution button to see the answer. ...
... really stuck, press the Show solution button to see the answer. Playable code <h2>Live output</h2> <
div class="output" style="min-height: 50px;"> </
div> <h2>Editable code</h2> <p class="a11y-label">Press Esc to move focus away from the code area (Tab inserts a tab character).</p> <textarea id="code" class="playable-code" style="min-height: 100px;width: 95%"> This is my text. ...
...And 10 more matches
WebGL model view projection - Web APIs
owledge of basic matrix math using translation, scale, and rotation matrices. It explains the three core matrices that are typically used when composing a 3D scene: the model, view and projection matrices. Note: This article is also available as an MDN content kit. It also uses a collection of utility functions available under the MDN global object. The model, view, and projection matrices In
dividual transformations of points and polygons in space in WebGL are handled by the basic transformation matrices like translation, scale, and rotation. These matrices can be composed together and grouped in special ways to make them useful for rendering complicated 3D scenes. These composed matrices ultimately move the original model data around into a special coordinate space called clip space. Th...
...ld. The view matrix is responsible for moving the objects in the scene to simulate the position of the camera being changed, altering what the viewer is currently able to see. The sections below offer an in-depth look into the ideas behind and implementation of the model, view, and projection matrices. These matrices are core to moving data around on the screen, and are concepts that transcend in
dividual frameworks and engines. Clip space In a WebGL program, data is typically uploaded to the GPU with its own coordinate system and then the vertex shader transforms those points into a special coordinate system known as clip space. Any data which extends outside of the clip space is clipped off and not rendered. However, if a triangle straddles the border of this space then it is chopped up i...
...ebGL program. The function takes three parameters -- the context to render the program in, the ID of the <script> element containing the vertex shader, and the ID of the <script> element containing the fragment shader. The vertex shader positions the vertices, and the fragment shader colours each pixel. First take a look at the vertex shader that will move the vertices on the screen: // The in
dividual position vertex attribute vec3 position; void main() { // the gl_Position is the final position in clip space after the vertex shader modifies it gl_Position = vec4(position, 1.0); } Next, to actually rasterize the data into pixels, the fragment shader evaluates everything on a per pixel basis, setting a single color. The GPU calls the shader function for each pixel it needs to render...
...And 10 more matches
Color contrast - Accessibility
e trouble differentiating between similar colors. This is because they don't see bright and dark areas as readily as those without such conditions, and therefore have trouble seeing edges, borders, and other details. It is good to have a cool design on your website, but the design is worthless if your users can't read your content. ...
...n similar colors. This is because they don't see bright and dark areas as readily as those without such conditions, and therefore have trouble seeing edges, borders, and other details. It is good to have a cool design on your website, but the design is worthless if your users can't read your content. ...
...lar colors. This is because they don't see bright and dark areas as readily as those without such conditions, and therefore have trouble seeing edges, borders, and other details. It is good to have a cool design on your website, but the design is worthless if your users can't read your content. ...
...And 10 more matches
CSS Grid Layout - CSS: Cascading Style Sheets
Like tables, grid layout enables an author to align elements into columns and rows. However, many more layouts are either possible or easier with CSS grid than they were with tables. For example, a grid container's child elements could position themselves so they actually overlap and layer, similar to CSS positioned elements. Basic example The example below shows a three-column track grid with new rows created at a minimum of 100 pixels and a maximum of auto. Items have been placed onto the grid using line-based placement. ...
...ments could position themselves so they actually overlap and layer, similar to CSS positioned elements. Basic example The example below shows a three-column track grid with new rows created at a minimum of 100 pixels and a maximum of auto. Items have been placed onto the grid using line-based placement. ...
...-column track grid with new rows created at a minimum of 100 pixels and a maximum of auto. Items have been placed onto the grid using line-based placement. ...
...And 10 more matches
Stacking context example 2 - CSS: Cascading Style Sheets
<< CSS << Understanding CSS z-index Stacking context example 2 This is a very simple example, but it is the key for understanding the concept of stacking context. There are the same four
DIVs of the previous example, but now z-index properties are assigned on both levels of the hierarchy. You can see that
DIV #2 (z-index: 2) is above
DIV #3 (z-index: 1), because they both belong to the same stacking context (the root one), so z-index values rule how elements are stacked. What can be considered strange is that
DIV #2 (z-index: 2) is above
DIV #4 (z-index: 10), despite their z-index values. The reason is that they do not belong to the same stacking context.
DIV #4 belongs to the stacking context created by
DIV #3, and as explained previously
DIV #3 (and all its content) is under
DIV #2. ...
...In the stacking context hierarchy, elements that do not create a stacking context are collapsed on their parent. ...
...In the stacking context hierarchy, elements that do not create a stacking context are collapsed on their parent. ...
...And 10 more matches
The stacking context - CSS: Cascading Style Sheets
elements because only certain elements create stacking contexts. We can say that elements that do not create their own stacking contexts are assimilated by the parent stacking context. The example In this example, every positioned element creates its own stacking context, because of their positioning and z-index values. The hierarchy of stacking contexts is organized as follows: Root
DIV #1
DIV #2
DIV #3
DIV #4
DIV #5
DIV #6 It is important to note that
DIV #4,
DIV #5 and
DIV #6 are children of
DIV #3, so stacking of those elements is completely resolved within
DIV#3. Once stacking and rendering within
DIV #3 is completed, the whole
DIV #3 element is passed for stacking in the root element with respect to its sibling's
DIV. Notes: DI...
...
DIV #4
DIV #5
DIV #6 It is important to note that
DIV #4,
DIV #5 and
DIV #6 are children of
DIV #3, so stacking of those elements is completely resolved within
DIV#3. Once stacking and rendering within
DIV #3 is completed, the whole
DIV #3 element is passed for stacking in the root element with respect to its sibling's
DIV. Notes:
DIV #4 is rendered under
DIV #1 because
DIV #1's z-index (5) is valid within the stacking context of the root element, while
DIV #4's z-index (6) is valid within the stacking context of
DIV #3. So,
DIV #4 is under
DIV #1, because
DIV #4 belongs to
DIV #3, which has a lower z-index value. ...
...is passed for stacking in the root element with respect to its sibling's
DIV. Notes:
DIV #4 is rendered under
DIV #1 because
DIV #1's z-index (5) is valid within the stacking context of the root element, while
DIV #4's z-index (6) is valid within the stacking context of
DIV #3. So,
DIV #4 is under
DIV #1, because
DIV #4 belongs to
DIV #3, which has a lower z-index value. For the same reason
DIV #2 (z-index 2) is rendered under
DIV#5 (z-index 1) because
DIV #5 belongs to
DIV #3, which has an higher z-index value.
DIV #3's z-index is 4, but this value is independent from z-index of
DIV #4,
DIV #5 and
DIV #6, because it belongs to a different stacking context. An easy way to figure out the rendering order of stacked elements along the Z axis is to think of it as a "version number" of sor...
...And 10 more matches
conic-gradient() - CSS: Cascading Style Sheets
ore the image represented by the conic gradient will not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document. ...
...ient will not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document. ...
...ill not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document. ...
...And 10 more matches
flex-grow - CSS: Cascading Style Sheets
asis, and normally defined using the flex shorthand to ensure all values are set. Formal definition Initial value0Applies toflex items, including in-flow pseudo-elementsInheritednoComputed valueas specifiedAnimation typea number Formal syntax <number> Examples Setting flex item grow factor HTML <h4>This is a Flex-Grow</h4> <h5>A,B,C and F are flex-grow:1 . ...
...fined using the flex shorthand to ensure all values are set. Formal definition Initial value0Applies toflex items, including in-flow pseudo-elementsInheritednoComputed valueas specifiedAnimation typea number Formal syntax <number> Examples Setting flex item grow factor HTML <h4>This is a Flex-Grow</h4> <h5>A,B,C and F are flex-grow:1 . ...
...es are set. Formal definition Initial value0Applies toflex items, including in-flow pseudo-elementsInheritednoComputed valueas specifiedAnimation typea number Formal syntax <number> Examples Setting flex item grow factor HTML <h4>This is a Flex-Grow</h4> <h5>A,B,C and F are flex-grow:1 . ...
...And 10 more matches
flex-shrink - CSS: Cascading Style Sheets
lue1Applies toflex items, including in-flow pseudo-elementsInheritednoComputed valueas specifiedAnimation typea number Formal syntax <number> Examples Setting flex item shrink factor HTML <p>The width of content is 500px; the flex-basis of the flex items is 120px.</p> <p>A, B, C have flex-shrink:1 set. ...
...ems, including in-flow pseudo-elementsInheritednoComputed valueas specifiedAnimation typea number Formal syntax <number> Examples Setting flex item shrink factor HTML <p>The width of content is 500px; the flex-basis of the flex items is 120px.</p> <p>A, B, C have flex-shrink:1 set. ...
...Computed valueas specifiedAnimation typea number Formal syntax <number> Examples Setting flex item shrink factor HTML <p>The width of content is 500px; the flex-basis of the flex items is 120px.</p> <p>A, B, C have flex-shrink:1 set. ...
...And 10 more matches
grid-column-end - CSS: Cascading Style Sheets
. ...
... Initial valueautoApplies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...ies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 10 more matches
grid-column-start - CSS: Cascading Style Sheets
Formal definition Initial valueautoApplies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...nitial valueautoApplies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...s togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 10 more matches
grid-row-end - CSS: Cascading Style Sheets
lid. ...
...on Initial valueautoApplies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...pplies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 10 more matches
grid-row-start - CSS: Cascading Style Sheets
e. ...
... Initial valueautoApplies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...lies togrid items and absolutely-positioned boxes whose containing block is a grid containerInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <grid-line>where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 10 more matches
<input type="number"> - HTML: Hypertext Markup Language
s, the input must be filled in.) You can use the step attribute to constrain valid values to a certain set of steps (e.g., multiples of 10). You can use the min and max attributes to constrain valid values to lower and upper bounds. ...
...nd upper bounds. ...
... bounds. ...
...And 10 more matches
WAI-ARIA basics - Learn web development
A? Let's start by looking at what WAI-ARIA is, and what it can do for us. A whole new set of problems As web apps started to get more complex and dynamic, a new set of accessibility features and problems started to appear. For example, HTML5 introduced a number of semantic elements to define common page features (<nav>, <footer>, etc.) Before these were available, developers would simply use <
div>s with IDs or classes, e.g. <
div class="nav">, but these were problematic, as there was no easy way to easily find a specific page feature such as the main navigation programmatically. The initial solution was to add one or more hidden links at the top of the page to link to the navigation (or whatever else), for example: <a href="#hidden" class="hidden">Skip to navigation</a> But this is stil...
...rs for choosing values, etc. HTML5 provides special input types to render such controls: <input type="date"> <input type="range"> These are not well-supported across browsers, and it is also difficult to style them, making them not very useful for integrating with website designs. As a result, developers quite often rely on JavaScript libraries that generate such controls as a series of nested <
div>s or table elements with classnames, which are then styled using CSS and controlled using JavaScript. The problem here is that visually they work, but screenreaders can't make any sense of what they are at all, and their users just get told that they can see a jumble of elements with no semantics to describe what they mean. Enter WAI-ARIA WAI-ARIA (Web Accessibility Initiative - Accessible Ric...
...le, aria-required="true" specifies that a form input needs to be filled in to be valid, whereas aria-labelledby="label" allows you to put an ID on an element, then reference it as being the label for anything else on the page, including multiple elements, which is not possible using <label for="input">. As an example, you could use aria-labelledby to specify that a key description contained in a <
div> is the label for multiple table cells, or you could use it as an alternative to image alt text -- specify existing information on the page as an image's alt text, rather than having to repeat it inside the alt attribute. You can see an example of this at Text alternatives. States -- Special properties that define the current conditions of elements, such as aria-disabled="true", which specifies ...
...And 9 more matches
Video and Audio APIs - Learn web development
into a new directory on your hard drive. If you downloaded our examples repo, you'll find it in javascript/apis/video-audio/start/ At this point, if you load the HTML you should see a perfectly normal HTML5 video player, with the native controls rendered. Exploring the HTML Open the HTML index file. ...
... video player, with the native controls rendered. Exploring the HTML Open the HTML index file. ...
...d its controls: <
div class="player"> <video controls> <source src="video/sintel-short.mp4" type="video/mp4"> <source src="video/sintel-short.webm" type="video/webm"> <!-- fallback content here --> </video> <
div class="controls"> <button class="play" data-icon="P" aria-label="play pause toggle"></button> <button class="stop" data-icon="S" aria-label="stop"></button> <
div class="timer"> <
div></
div> <span aria-label="timer">00:00</span> </
div> <button class="rwd" data-icon="B" aria-label="rewind"></button> <button class="fwd" data-icon="F" aria-label="fast forward"></button> </
div> </
div> The whole player is wrapped in a <
div> element, so it can all be styled as one unit if needed. The <video> element contains two <source> elements so...
...And 9 more matches
Vue conditional rendering: editing existing todos - Learn web development
installed. Objective: To learn how to do conditional rendering in Vue. Creating an editing component We can start by creating a separate component to handle the editing functionality. In your components directory, create a new file called ToDoItemEditForm.vue. ...
...to handle the editing functionality. In your components directory, create a new file called ToDoItemEditForm.vue. ...
...the editing functionality. In your components directory, create a new file called ToDoItemEditForm.vue. ...
...And 9 more matches
Using IndexedDB - Web APIs
gle call to createObjectStore(). The method takes a name of the store, and a parameter object. Even though the parameter object is optional, it is very important, because it lets you define important optional properties and refine the type of object store you want to create. In our case, we've asked for an object store named "customers" and defined a keyPath, which is the property that makes an in
dividual object in the store unique. That property in this example is "ssn" since a social security number is guaranteed to be unique. "ssn" must be present on every object that is stored in the objectStore. We've also asked for an index named "name" that looks at the name property of the stored objects. As with createObjectStore(), createIndex() takes an optional options object that refines the ...
...to the database if fine-grained error handling is too cumbersome. If you don't handle an error event or if you call abort() on the transaction, then the transaction is rolled back and an abort event is fired on the transaction. Otherwise, after all pending requests have completed, you'll get a complete event. If you're doing lots of database operations, then tracking the transaction rather than in
dividual requests can certainly aid your sanity. Now that you have a transaction, you'll need to get the object store from it. Transactions only let you have an object store that you specified when creating the transaction. Then you can add all the data you need. // Do something when all the data is added to the database. transaction.oncomplete = function(event) { console.log("All done!"); }; tr...
...xample, the browser must create all the objects at once. If you're just interested in looking at each of the keys, for instance, it is much more efficient to use a cursor than to use getAll(). If you're trying to get an array of all the objects in an object store, though, use getAll(). Using an index Storing customer data using the SSN as a key is logical since the SSN uniquely identifies an in
dividual. (Whether this is a good idea for privacy is a different question, and outside the scope of this article.) If you need to look up a customer by name, however, you'll need to iterate over every SSN in the database until you find the right one. Searching in this fashion would be very slow, so instead you can use an index. // First, make sure you created index in request.onupgradeneeded: // ob...
...And 9 more matches
NonDocumentTypeChildNode.previousElementSibling - Web APIs
The NonDocumentTypeChildNode.previousElementSibling read-only property returns the Element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list. ...
... The NonDocumentTypeChildNode.previousElementSibling read-only property returns the Element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list. ...
... The NonDocumentTypeChildNode.previousElementSibling read-only property returns the Element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list. ...
...And 9 more matches
ARIA annotations - Accessibility
-- aria-describedby is for textual descriptions, whereas aria-details is for more complex sets of details. But what does this actually mean? aria-describedby is appropriate for associating an element with a simple text description, where you don't have much in the way of meaningful semantics contained within. ...
...t does this actually mean? aria-describedby is appropriate for associating an element with a simple text description, where you don't have much in the way of meaningful semantics contained within. ...
... example: <p id="description-id">An extended text description of some kind...</p> <
div aria-describedby="description-id"> <!-- Some kind of UI feature that needs an accessible description --> </
div> aria-details is appropriate when linking to descriptions or annotations that are a bit more complex -- rather than a simple text string, it might contain multiple bits of semantic information: <
div id="detail-id"> <h2>A heading</h2> <p>An extended text description of some kind...</p> <p><time datetime="...">A timestamp</time></p> </
div> <
div aria-details="detail-id"> <!-- Some kind of UI feature that needs an accessible description --> </
div> This difference really becomes apparent when you get to how the content is actually interpreted in the accessibility layer, and read out by...
...And 9 more matches
prefers-color-scheme - CSS: Cascading Style Sheets
light Indicates that user has notified the system that they prefer an interface that has a light theme, or has not expressed an active preference. dark Indicates that user has notified the system that they prefer an interface that has a dark theme. Examples The elements below have an initial color theme. They can be further themed according to the user's color scheme preference. ...
...has notified the system that they prefer an interface that has a light theme, or has not expressed an active preference. dark Indicates that user has notified the system that they prefer an interface that has a dark theme. Examples The elements below have an initial color theme. They can be further themed according to the user's color scheme preference. ...
...tified the system that they prefer an interface that has a light theme, or has not expressed an active preference. dark Indicates that user has notified the system that they prefer an interface that has a dark theme. Examples The elements below have an initial color theme. They can be further themed according to the user's color scheme preference. ...
...And 9 more matches
Using CSS custom properties (variables) - CSS: Cascading Style Sheets
which leads us to this: Notice the repetition in the CSS. The background color is set to brown in several places. For some CSS declarations, it is possible to declare this higher in the cascade and let CSS ...
...which leads us to this: Notice the repetition in the CSS. The background color is set to brown in several places. For some CSS declarations, it is possible to declare this higher in the cascade and let CSS inherita...
...which leads us to this: Notice the repetition in the CSS. The background color is set to brown in several places. For some CSS declarations, it is possible to declare this higher in the cascade and let CSS inheritance solve this probl...
...And 9 more matches
<color> - CSS: Cascading Style Sheets
ow be used wherever a <color> value can be used. currentcolor keyword The currentcolor keyword represents the value of an element's color property. This lets you use the color value on properties that do not receive it by default. If currentcolor is used as the value of the color property, it instead takes its value from the inherited value of the color property. currentcolor example HTML <
div style="color:blue; border: 1px dashed currentcolor;"> The color of this text is blue. <
div style="background:currentcolor; height:9px;"></
div> This block is surrounded by a blue border. </
div> Result RGB colors The RGB color model defines a given color according to its red, green, and blue components. An optional alpha component represents the color's transparency. Syntax RGB colors ...
...tions, the interpolation's speed is determined by the timing function. Accessibility considerations Some people have difficulty distinguishing colors. The WCAG 2.0 recommendation strongly advises against using color as the only means of conveying a specific message, action, or result. See Color and color contrast for more information. ...
...ccessibility considerations Some people have difficulty distinguishing colors. The WCAG 2.0 recommendation strongly advises against using color as the only means of conveying a specific message, action, or result. See Color and color contrast for more information. Examples Color value tester In this example we provide a <
div> and a text input. Entering a valid color into the input causes the <
div> to adopt that color, allowing you to test our color values. ...
...And 9 more matches
font - CSS: Cascading Style Sheets
shorthand property sets all the different properties of an element's font. Alternatively, it sets an element's font to a system font. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. As with any shorthand property, any in
dividual value that is not specified is set to its corresponding initial value (possibly overriding values previously set using non-shorthand properties). Though not directly settable by font, the longhands font-size-adjust and font-kerning are also reset to their initial values. Constituent properties This property is a shorthand for the following CSS properties: font-family font-size font-st...
...rif } /* Set the font weight to bold, the font-style to italic, the font size to large, and the font family to serif. */ p { font: bold italic large serif } /* Use the same font as the status bar of the window */ p { font: status-bar } Live sample HTML <p> Change the radio buttons below to see the generated shorthand and it's effect. ...
...ight to bold, the font-style to italic, the font size to large, and the font family to serif. */ p { font: bold italic large serif } /* Use the same font as the status bar of the window */ p { font: status-bar } Live sample HTML <p> Change the radio buttons below to see the generated shorthand and it's effect. ...
...And 9 more matches
grid-auto-flow - CSS: Cascading Style Sheets
en placing items, never backtracking to fill holes. This ensures that all of the auto-placed items appear "in order", even if this leaves holes that could have been filled by later items. ...
...never backtracking to fill holes. This ensures that all of the auto-placed items appear "in order", even if this leaves holes that could have been filled by later items. ...
...g to fill holes. This ensures that all of the auto-placed items appear "in order", even if this leaves holes that could have been filled by later items. ...
...And 9 more matches
<input type="datetime-local"> - HTML: Hypertext Markup Language
ble dates (see Setting maximum and minimum dates), and you can use the required attribute to make filling in the date/time mandatory. As a result, supporting browsers will display an error if you try to submit a date that is outside the set bounds, or an empty date field. ...
...e; here we've set minimum and maximum date/time values, and also made the field required: <form> <
div> <label for="party">Choose your preferred party date and time (required, June 1st 8.30am to June 30th 4.30pm):</label> <input id="party" type="datetime-local" name="partydate" min="2017-06-01T08:30" max="2017-06-30T16:30" required> <span class="validity"></span> </
div> <
div> <input type="submit" value="Book party!"> </
div> </form> If you try to submit the form with an incomplete date (or with a date outside the set bounds), the browser displays an error. Try playing with the example now: Here's a screenshot for those of you who aren't using a supporting browser: Here's the CSS used in the above example. Here we make use of the :valid and...
...sing a supporting browser: Here's the CSS used in the above example. Here we make use of the :valid and :invalid CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a <span> next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively.
div { margin-bottom: 10px; display: flex; align-items: center; } label { display: inline-block; width: 300px; } input:invalid+span:after { content: '?'; padding-left: 5px; } input:valid+span:after { content: '?'; padding-left: 5px; } Important: HTML form validation is not a substitute for scripts that ensure that the entered data is in the proper format. It's far...
...And 9 more matches
<input type="file"> - HTML: Hypertext Markup Language
takes as its value a string containing one or more of these unique file type specifiers, separated by commas. For example, a file picker that needs content that can be presented as an image, including both standard image formats and PDF files, might look like this: <input type="file" accept="image/*,.pdf"> Using file inputs A basic example <form method="post" enctype="multipart/form-data"> <
div> <label for="file">Choose file to upload</label> <input type="file" id="file" name="file" multiple> </
div> <
div> <button>Submit</button> </
div> </form>
div { margin-bottom: 10px; } This produces the following output: Note: You can find this example on GitHub too -- see the source code, and also see it running live. Regardless of the user's device or operating system, the f...
...ept any file with an image/* MIME type. (Many mobile devices also let the user take a picture with the camera when this is used.) accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" -- accept anything that smells like an MS Word document. ...
...n/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" -- accept anything that smells like an MS Word document. Let's look at a more complete example: <form method="post" enctype="multipart/form-data"> <
div> <label for="profile_pic">Choose file to upload</label> <input type="file" id="profile_pic" name="profile_pic" accept=".jpg, .jpeg, .png"> </
div> <
div> <button>Submit</button> </
div> </form>
div { margin-bottom: 10px; } This produces a similar-looking output to the previous example: Note: You can find this example on GitHub too -- see the source code, and also see it running live. It may look similar, but if you try selecting a file with this input, you'll see that the file picker only lets you select the file types sp...
...And 9 more matches
<input type="image"> - HTML: Hypertext Markup Language
you to specify a frame for the image using the width and height attributes to set aside space in the layout, then adjust where within that space the image is located and how (or if) it is scaled to occupy that space. Examples A login form The following example shows the same button as before, but included in the context of a typical login form. ...
...e layout, then adjust where within that space the image is located and how (or if) it is scaled to occupy that space. Examples A login form The following example shows the same button as before, but included in the context of a typical login form. ...
..., then adjust where within that space the image is located and how (or if) it is scaled to occupy that space. Examples A login form The following example shows the same button as before, but included in the context of a typical login form. ...
...And 9 more matches
Microformats - HTML: Hypertext Markup Language
-email email address u-photo a photo of the person or organization u-url home page or other URL representing the person or organization u-uid universally unique identifier, preferably canonical URL p-street-address street number + name p-locality city/town/village p-country-name country name Nested h-card example <
div class="h-card"> <a class="p-name u-url" href="http://blog.lizardwrangler.com/" >Mitchell Baker</a> (<a class="p-org h-card" href="http://mozilla.org/" >Mozilla Foundation</a>) </
div> Parsed JSON: { "items": [{ "type": ["h-card"], "properties": { "name": ["Mitchell Baker"], "url": ["http://blog.lizardwrangler.com/"], "org": [{ "value": "Mozilla Foundation"...
...blog posts. Example h-entry as a blog post: <article class="h-entry"> <h1 class="p-name">Microformats are amazing</h1> <p>Published by <a class="p-author h-card" href="http://example.com">W. ...
...icle class="h-entry"> <h1 class="p-name">Microformats are amazing</h1> <p>Published by <a class="p-author h-card" href="http://example.com">W. ...
...And 9 more matches
Image gallery - Learn web development
nside the HTML page. Note: If you get stuck, then ask us for help -- see the Assessment or further help section at the bottom of this page. Project brief You have been provided with some HTML, CSS and image assets and a few lines of JavaScript code; you need to write the necessary JavaScript to turn this into a working program. ...
...e Assessment or further help section at the bottom of this page. Project brief You have been provided with some HTML, CSS and image assets and a few lines of JavaScript code; you need to write the necessary JavaScript to turn this into a working program. ...
...r help section at the bottom of this page. Project brief You have been provided with some HTML, CSS and image assets and a few lines of JavaScript code; you need to write the necessary JavaScript to turn this into a working program. ...
...And 8 more matches
Document: drag event - Web APIs
The drag event is fired every few hundred milliseconds as an element or text selection is being dragged by the user. Bubbles Yes Cancelable Yes Default action Continue the drag & drop operation. Interface DragEvent Event handler property ondrag Examples See this code in a JSFiddle demo or interact with it below. ...
...s fired every few hundred milliseconds as an element or text selection is being dragged by the user. Bubbles Yes Cancelable Yes Default action Continue the drag & drop operation. Interface DragEvent Event handler property ondrag Examples See this code in a JSFiddle demo or interact with it below. ...
... Bubbles Yes Cancelable Yes Default action Continue the drag & drop operation. Interface DragEvent Event handler property ondrag Examples See this code in a JSFiddle demo or interact with it below. ...
...And 8 more matches
Document.querySelectorAll() - Web APIs
n case of no matches. Note: If the specified selectors include a CSS pseudo-element, the returned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
... empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...And 8 more matches
EffectTiming.fill - Web APIs
leted playing, in spite of and during any endDelay, delay and/or pending or finished playState. "auto" If the animation effect the fill mode is being applied to is a keyframe effect (KeyframeEffect or KeyframeEffectReadOnly), "auto" is equivalent to "none". Otherwise, the result is "both". Examples Here are a few examples. Fill mode: none HTML content The HTML is pretty simple. ...
...ayState. "auto" If the animation effect the fill mode is being applied to is a keyframe effect (KeyframeEffect or KeyframeEffectReadOnly), "auto" is equivalent to "none". Otherwise, the result is "both". Examples Here are a few examples. Fill mode: none HTML content The HTML is pretty simple. We have a <
div> named "main" which is a container for the element we'll be animating, which is a <
div> with the ID "box". ...
... fill mode is being applied to is a keyframe effect (KeyframeEffect or KeyframeEffectReadOnly), "auto" is equivalent to "none". Otherwise, the result is "both". Examples Here are a few examples. Fill mode: none HTML content The HTML is pretty simple. We have a <
div> named "main" which is a container for the element we'll be animating, which is a <
div> with the ID "box". Below that, another <
div> serves as a button that will trigger the animation to begin. ...
...And 8 more matches
Timing element visibility with the Intersection Observer API - Web APIs
site. There's a good reason why the notion of tracking visibility of ads is being used in this example. It turns out that one of the most common uses of Flash or other script in advertising on the Web is to record how long each ad is visible, for the purpose of billing and payment of revenues. ...
...vals and timeouts for each in
dividual ad, or other techniques that tend to slow the page down. Using this API lets everything get streamlined by the browser to reduce the impact on performance substantially. Let's get started! Site structure: The HTML The site's structure is not too complicated. We'll be using CSS Grid to style and lay out the site, so we can be pretty straightforward here: <
div class="wrapper"> <header> <h1>A Fake Blog</h1> <h2>Showing Intersection Observer in action!</h2> </header> <aside> <nav> <ul> <li><a href="#link1">A link</a></li> <li><a href="#link2">Another link</a></li> <li><a href="#link3">One more link</a></li> </ul> </nav> </aside> <main> </main> </
div> This is the framework for the entire s...
...tained within a <header> block. Below that, we define the site's sidebar as a list of links within an <aside> block. Finally comes the main body. We start with an empty <main> element here. This box will be populated using script later. Styling the site with CSS With the structure of the site defined, we turn to the styling for the site. Let's look at the style for each component of the page in
dividually. The basics We provide styles for the <body> and <main> elements to define the site's background as well as the grid the various parts of the site will be placed in. body { font-family: "Open Sans", "Arial", "Helvetica", sans-serif; background-color: aliceblue; } .wrapper { display: grid; grid-template-columns: auto minmax(min-content, 1fr); grid-template-rows: auto minmax(mi...
...And 8 more matches
Node.isEqualNode() - Web APIs
they have the same type, defining characteristics (for elements, this would be their ID, number of children, and so forth), its attributes match, and so on. The specific set of data points that must match varies depending on the types of the nodes. Syntax var isEqualNode = node.isEqualNode(otherNode); otherNode: The Node to compare equality with. ...
... varies depending on the types of the nodes. Syntax var isEqualNode = node.isEqualNode(otherNode); otherNode: The Node to compare equality with. Example In this example, we create three <
div> blocks. The first and third have the same contents and attributes, while the second is different. Then we run some JavaScript to compare the nodes using isEqualNode() and output the results. ...
...f the nodes. Syntax var isEqualNode = node.isEqualNode(otherNode); otherNode: The Node to compare equality with. Example In this example, we create three <
div> blocks. The first and third have the same contents and attributes, while the second is different. Then we run some JavaScript to compare the nodes using isEqualNode() and output the results. ...
...And 8 more matches
Node.isSameNode() - Web APIs
The isSameNode() method for Node objects tests whether two nodes are the same (that is, whether they reference the same object). Syntax const isSameNode = node.isSameNode(otherNode) Parameters otherNode The Node to test against. Example In this example, we create three <
div> blocks. The first and third have the same contents and attributes, while the second is different. Then we run some JavaScript to compare the nodes using isSameNode() and output the results. ...
...is, whether they reference the same object). Syntax const isSameNode = node.isSameNode(otherNode) Parameters otherNode The Node to test against. Example In this example, we create three <
div> blocks. The first and third have the same contents and attributes, while the second is different. Then we run some JavaScript to compare the nodes using isSameNode() and output the results. ...
...ame object). Syntax const isSameNode = node.isSameNode(otherNode) Parameters otherNode The Node to test against. Example In this example, we create three <
div> blocks. The first and third have the same contents and attributes, while the second is different. Then we run some JavaScript to compare the nodes using isSameNode() and output the results. ...
...And 8 more matches
NonDocumentTypeChildNode.nextElementSibling - Web APIs
The NonDocumentTypeChildNode.nextElementSibling read-only property returns the element immediately following the specified one in its parent's children list, or null if the specified element is the last one in the list. ...
... The NonDocumentTypeChildNode.nextElementSibling read-only property returns the element immediately following the specified one in its parent's children list, or null if the specified element is the last one in the list. ...
... The NonDocumentTypeChildNode.nextElementSibling read-only property returns the element immediately following the specified one in its parent's children list, or null if the specified element is the last one in the list. ...
...And 8 more matches
ParentNode.querySelectorAll() - Web APIs
t matches at least one of the specified selectors. Note: If the specified selectors include a CSS pseudo-element, the returned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
..., the returned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...rned list is always empty. Exceptions SyntaxError The syntax of the specified selectors string is not valid. ...
...And 8 more matches
rotate() - CSS: Cascading Style Sheets
er-clockwise one. ...
... one. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 cos(a)-sin(a) sin(a)cos(a) cos(a)-sin(a)0sin(a)cos(a)0001 cos(a)-sin(a)0sin(a)cos(a)0001 cos(a)-sin(a)00sin(a)cos(a)0000100001 [cos(a) sin(a) -sin(a) cos(a) 0 0] Examples Basic example HTML <
div>Normal</
div> <
div class="rotated">Rotated</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .rotated { transform: rotate(45deg); /* Equal to rotateZ(45deg) */ background-color: pink; } Result Combining rotation with another transformation If you want apply multiple transformations to an element, be careful about the order in which you specify your transformations. For...
... } .rotated { transform: rotate(45deg); /* Equal to rotateZ(45deg) */ background-color: pink; } Result Combining rotation with another transformation If you want apply multiple transformations to an element, be careful about the order in which you specify your transformations. ...
...And 8 more matches
translate() - CSS: Cascading Style Sheets
oordinates on R3 Homogeneous coordinates on RP3 A translation is not a linear transformation in R2 and can't be represented using a Cartesian-coordinate matrix. ...
...n R3 Homogeneous coordinates on RP3 A translation is not a linear transformation in R2 and can't be represented using a Cartesian-coordinate matrix. ...
... Homogeneous coordinates on RP3 A translation is not a linear transformation in R2 and can't be represented using a Cartesian-coordinate matrix. ...
...And 8 more matches
<input type="checkbox"> - HTML: Hypertext Markup Language
Events change and input Supported common attributes checked IDL attributes checked, indeterminate and value Methods select() Value A DOMString representing the value of the checkbox. This is never seen on the client-side, but on the server this is the value given to the data submitted with the checkbox's name. Take the following example: <form> <
div> <input type="checkbox" id="subscribeNews" name="subscribe" value="newsletter"> <label for="subscribeNews">Subscribe to newsletter?</label> </
div> <
div> <button type="submit">Subscribe</button> </
div> </form> In this example, we've got a name of subscribe, and a value of newsletter. When the form is submitted, the data name/value pair will be subscribe=newsletter. If the val...
...multiple checkboxes. If they are completely unrelated, then you can just deal with them all separately, as shown above. However, if they're all related, things are not quite so simple. For example, in the following demo we include multiple checkboxes to allow the user to select their interests (see the full version in the Examples section). <fieldset> <legend>Choose your interests</legend> <
div> <input type="checkbox" id="coding" name="interest" value="coding"> <label for="coding">Coding</label> </
div> <
div> <input type="checkbox" id="music" name="interest" value="music"> <label for="music">Music</label> </
div> </fieldset> In this example you will see that we've given each checkbox the same name. If both checkboxes are checked and then the form is submitted, you...
...her than as an associative array, so all values, not only the last value, of interest are captured. For one technique used with PHP, see Handle Multiple Checkboxes with a Single Serverside Variable, for example. Checking boxes by default To make a checkbox checked by default, you simply give it the checked attribute. ...
...And 8 more matches
<input type="search"> - HTML: Hypertext Markup Language
umber of entries is used. Using search inputs <input> elements of type search are very similar to those of type text, except that they are specifically intended for handling search terms. They are basically equivalent in behavior, but user agents may choose to style them differently by default (and, of course, sites may use stylesheets to apply custom styles to them). Basic example <form> <
div> <input type="search" id="mySearch" name="q"> <button>Search</button> </
div> </form> This renders like so: q is the most common name given to search inputs, although it's not mandatory. When submitted, the data name/value pair sent to the server will be q=searchterm. You must remember to set a name for your input, otherwise nothing will be submitted. Differences between search a...
...s users who tend to do searches on the same or similar search queries over time. This screenshot is from Firefox: At this point, let's look at some useful techniques you can apply to your search forms. Setting placeholders You can provide a useful placeholder inside your search input that could give a hint on what to do using the placeholder attribute. ...
...oint, let's look at some useful techniques you can apply to your search forms. Setting placeholders You can provide a useful placeholder inside your search input that could give a hint on what to do using the placeholder attribute. ...
...And 8 more matches
Grid Lines - MDN Web Docs Glossary: Definitions of Web-related terms
CSS Grid Layout. In the following example there is a grid with three column tracks and two row tracks. This gives us 4 column lines and 3 row lines. ...
... 3 row lines. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 100px); } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> </
div> .wrapper { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 100px 100px; } Lines can be addressed using their line number. In a left-to-right language such as English, column line 1 will be on the left of the grid, row line 1 on the top. Lines ...
...onto the grid by line number. In the following example the item is positioned from column line 1 to column line 3, and from row line 1 to row line 3. ...
...And 7 more matches
Advanced text formatting - Learn web development
o try your hand at description lists; add elements to the raw text in the Input field so that it appears as a description list in the Output field. You could try using your own terms and descriptions if you like. If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see the answer. Playable code <h2>Live output</h2> <
div class="output" style="min-height: 50px;"> </
div> <h2>Editable code</h2> <p class="a11y-label">Press Esc to move focus away from the code area (Tab inserts a tab character).</p> <textarea id="code" class="input" style="min-height: 100px; width: 95%"> Bacon The glue that binds the world together. Eggs The glue that binds the cake together. Coffee The drink that gets the world running in the morni...
...x;"> </
div> <h2>Editable code</h2> <p class="a11y-label">Press Esc to move focus away from the code area (Tab inserts a tab character).</p> <textarea id="code" class="input" style="min-height: 100px; width: 95%"> Bacon The glue that binds the world together. Eggs The glue that binds the cake together. Coffee The drink that gets the world running in the morning. ...
... <textarea id="code" class="input" style="min-height: 100px; width: 95%"> Bacon The glue that binds the world together. Eggs The glue that binds the cake together. Coffee The drink that gets the world running in the morning. ...
...And 7 more matches
Componentizing our React app - Learn web development
his code, we define the function and export it on the same line: export default function Todo() { return ( ); } This is OK so far, but our component has to return something! ...
...If at any point in th...
...If at any point in the future you...
...And 7 more matches
Getting started with React - Learn web development
that renders a part of our app. These parts can be big or small, but they are usually clearly defined: they serve a single, obvious purpose. Let's open src/App.js, since our browser is prompting us to edit it. This file contains our first component, App, and a few other lines of code: import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return ( <
div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <p> Edit <code>src/App.js</code> and save to reload. </p> <a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer" > Learn React </a> </header>...
...ame="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <p> Edit <code>src/App.js</code> and save to reload. </p> <a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer" > Learn React </a> </header> </
div> ); } export default App; The App.js file consists of three main parts: some import statements at the top, the App component in the middle, and an export statement at the bottom. Most React components follow this pattern. Import statements The import statements at the top of the file allow App.js to use code that has been defined elsewhere. Let's look at these statements more closely. impor...
...d App. Whereas most of the JavaScript community prefers camel-case names like helloWorld, React components use pascal-case variable names, like HelloWorld, to make it clear that a given JSX element is a React component, and not a regular HTML tag. If you were to rename the App function to app, your browser would show you an error. Let's look at App more closely. function App() { return ( <
div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <p> Edit <code>src/App.js</code> and save to reload. </p> <a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer" > Learn React </a> </header>...
...And 7 more matches
Working with Svelte stores - Learn web development
component and see how we can read values from the store. Create another new file named src/components/Alert.svelte. ...
...te another new file named src/components/Alert.svelte. ...
...named src/components/Alert.svelte. ...
...And 7 more matches
Creating our first Vue component - Learn web development
Along the way, we'll learn about a few important concepts such as calling components inside other components, passing data to them via props, and saving data state. Note: If you need to check your code against our version, you can find a finished version of the sample Vue app code in our todo-vue repository. For a running live version, see https://mdn.github.io/todo-vue/dist/. ...
...ect export default {}, which is your component object. Your file should now look like this: <template> </template> <script> export default {}; </script> We can now begin to add actual content to our ToDoItem. Vue templates are currently only allowed a single root element -- one element needs to wrap everything inside the template section (this will change when Vue 3 comes out). ...
...bject. Your file should now look like this: <template> </template> <script> export default {}; </script> We can now begin to add actual content to our ToDoItem. Vue templates are currently only allowed a single root element -- one element needs to wrap everything inside the template section (this will change when Vue 3 comes out). We'll use a <
div> for that root element. Add an empty <
div> inside your component template now. ...
...And 7 more matches
Index
you safely keep your own secret keys that belong to your own certificates. You might want to protect the storage of your secret keys with PBE. You might decide to modify the default trust provided by NSS. All of this requires storing, looking up, and retrieving data. NSS simplifies performing these operations by offering storage and management APIs. NSS doesn't require the programmer to manage in
dividual files containing in
dividual certificates or keys. Instead, NSS offers to use its own database(s). Once you have imported certificates and keys into the NSS database, you can easily look them up and use them again. Because of NSS's expectation to operate with an NSS database, it's mandatory that you perform an initialization call, where you tell NSS which database you will be using. In the...
... store such an untyped block is SECItem, which contains a size and an untyped C pointer variable. When dealing with memory, NSS makes use of arenas, which are an attempt to simplify management with the limited offerings of C (because there are no destructors). The idea is to group multiple memory allocations in order to simplify cleanup. Performing an operation often involves allocating many in
dividual data items, and the code might be required to abort a task at many positions in the logic. An arena is requested once processing of a task starts, and all memory allocations that are logically associated to that task are requested from the associated arena. The implementation of arenas makes sure that all in
dividual memory blocks are tracked. Once a task is done, regardless whether it comple...
...ns in the logic. An arena is requested once processing of a task starts, and all memory allocations that are logically associated to that task are requested from the associated arena. The implementation of arenas makes sure that all in
dividual memory blocks are tracked. Once a task is done, regardless whether it completed or was aborted, the programmer simply needs to release the arena, and all in
dividually allocated blocks will be released automatically. Often freeing is combined with immediately erasing (zeroing, zfree) the memory associated to the arena, in order to make it more difficult for attackers to extract keys from a memory dump. NSS uses many C data structures. Often NSS has multiple implementations for the same or similar concepts. For example, there are multiple presentations...
...And 7 more matches
Using files from web applications - Web APIs
ndleFiles() { const fileList = this.files; /* now you can work with the file list */ } Getting information about selected file(s) The FileList object provided by the DOM lists all of the files selected by the user, each specified as a File object. You can determine how many files the user selected by checking the value of the file list's length attribute: const numFiles = fileList.length; In
dividual File objects can be retrieved by simply accessing the list as an array: for (let i = 0, numFiles = fileList.length; i < numFiles; i++) { const file = fileList[i]; // ... } This loop iterates over all the files in the file list. There are three attributes provided by the File object that contain useful information about the file. name The file's name as a read-only string. This is...
...n. size The size of the file in bytes as a read-only 64-bit integer. type The MIME type of the file as a read-only string or "" if the type couldn't be determined. ...
...e: Showing file(s) size The following example shows a possible use of the size property: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>File(s) size</title> </head> <body> <form name="uploadForm"> <
div> <input id="uploadInput" type="file" name="myFiles" multiple> selected files: <span id="fileNum">0</span>; total size: <span id="fileSize">0</span> </
div> <
div><input type="submit" value="Send file"></
div> </form> <script> function updateSize() { let nBytes = 0, oFiles = this.files, nFiles = oFiles.length; for (let nFileId = 0; nFileId < nFiles; nFileId++) { nBytes += oFiles[nFileId].size; } let sOutput = nBytes + " bytes"; // optional code for multiples approximation const aMultiples = ["Ki...
...And 7 more matches
Capabilities, constraints, and settings - Web APIs
supported["frameRate"]; In this example, the supported constraints are fetched, and a control that lets the user configure the frame rate is disabled if the frameRate constraint isn't supported. How constraints are defined A single constraint is an object whose name matches the constrainable property whose desired value or range of values is being specified. This object contains zero or more in
dividual constraints, as well as an optional sub-object named advanced, which contains another set of zero or more constraints which the user agent must satisfy if at all possible. The user agent attempts to satisfy constraints in the order specified in the constraint set. The most important thing to understand is that most constraints aren't requirements; instead, they're requests. There are excep...
...r the video and audio tracks in the edit boxes on the left, then click the "Apply Constraints" button to try them out. The actual settings the browser selected and is using are shown in the boxes on the right. ...
...es on the left, then click the "Apply Constraints" button to try them out. The actual settings the browser selected and is using are shown in the boxes on the right. ...
...And 7 more matches
ARIA live regions - Accessibility
a-live=POLITENESS_SETTING is used to set the priority with which screen reader should treat updates to live regions - the possible settings are: off, polite or assertive. The default setting is off. This attribute is by far the most important. aria-controls: The aria-controls=[IDLIST] is used to associate a control with the regions that it controls. Regions are identified just like an id in a
div, and multiple regions can be associated with a control using a space, e.g. aria-controls="myRegionID1 myRegionsID2". Not known if the aria-controls aspect of live regions is implemented in current ATs, or which. Needs research. Normally, only aria-live="polite" is used. Any region which receives updates that are important for the user to receive, but not so rapid as to be annoying, should ...
...> <label for="planetsSelect">Planet:</label> <select id="planetsSelect" aria-controls="planetInfo"> <option value="">Select a planet…</option> <option value="mercury">Mercury</option> <option value="venus">Venus</option> <option value="earth">Earth</option> <option value="mars">Mars</option> </select> <button id="renderPlanetInfoButton">Go</button> </fieldset> <
div role="region" id="planetInfo" aria-live="polite"> <h2 id="planetTitle">No planet selected</h2> <p id="planetDescription">Select a planet to view its description</p> </
div> <p><small>Information courtesy <a href="https://en.wikipedia.org/wiki/Solar_System#Inner_Solar_System">Wikipedia</a></small></p> JavaScript const PLANETS_INFO = { mercury: { title: 'Mercury', description: 'Mer...
... A hybrid between a widget and a live region. Use this with aria-valuemin, aria-valuenow and aria-valuemax. (TBD: add more info here). marquee for text which scrolls, such as a stock ticker. timer or any kind of timer or clock, such as a countdown timer or stopwatch readout. Advanced live regions (TBD: more granular information on the support of the in
dividual attributes with combinations of OS/Browser/AT). General support for Live Regions was added to JAWS on version 10.0. In Windows Eyes supports Live Regions since version 8.0 "for use outside of Browse Mode for Microsoft Internet Explorer and Mozilla Firefox". NVDA added some basic support for Live Regions for Mozilla Firefox back in 2008 and was improved in 2010 and 2014. In 2015, basic suppo...
...And 7 more matches
ARIA: cell role - Accessibility
The cell value of the ARIA role attribute identifies an element as being a cell in a tabular container that does not contain column or row header information. To be supported, the cell must be nested in an element with the role of row. <
div role="row"> <span role="cell">France</span> <span role="cell">67 million</span> </
div> A better, more semantic way of writing the cells above would be to use the semantic <td> element. <tr role="row"> <td role="cell">France</td> <td role="cell">67 million</td> </tr> Description The element with role="cell" is a cell within a row, optionally within a rowgroup, within a grid, table or treegrid within a static tabular structure. Using native HTML <td> elements, whenever possible, is strongly encouraged. Each element with role="cell" MUST be ...
...s. Keyboard interactions None Required JavaScript features The first rule of ARIA use is if you can use a native feature with the semantics and behavior you require already built in, instead of repurposing an element and adding an ARIA role, state or property to make it accessible, then do so. Employ the HTML <td> element instead of the ARIA role of cell whenever possible. ...
...ative feature with the semantics and behavior you require already built in, instead of repurposing an element and adding an ARIA role, state or property to make it accessible, then do so. Employ the HTML <td> element instead of the ARIA role of cell whenever possible. ...
...And 7 more matches
Using multi-column layouts - CSS: Cascading Style Sheets
markup allowed in the text, or using heroic scripting. This limitation is solved by adding new CSS properties to extend the traditional block layout mode. Using columns Column count and width Two CSS properties control whether and how many columns will appear: column-count and column-width. The column-count property sets the number of columns to a particular number. E.g., Example 1 HTML <
div id="col"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p> <p> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> <p> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla par...
...iqua. </p> <p> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> <p> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> <p> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ...
...Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ...
...And 7 more matches
flex-wrap - CSS: Cascading Style Sheets
the opposite of the specified cross-start. wrap-reverse Behaves the same as wrap but cross-start and cross-end are permuted. ...
...ified cross-start. wrap-reverse Behaves the same as wrap but cross-start and cross-end are permuted. ...
... wrap-reverse Behaves the same as wrap but cross-start and cross-end are permuted. ...
...And 7 more matches
isolation - CSS: Cascading Style Sheets
applied to the element requires it. isolate A new stacking context must be created. Formal definition Initial valueautoApplies toAll elements. ...
...equires it. isolate A new stacking context must be created. Formal definition Initial valueautoApplies toAll elements. ...
...ate A new stacking context must be created. Formal definition Initial valueautoApplies toAll elements. ...
...And 7 more matches
<length> - CSS: Cascading Style Sheets
lation is determined by the timing function associated with the animation. Examples Length unit comparison The following demo provides you with an input field in which you can enter a <length> value (e.g. 300px, 50%, 30vw) to set the width of a result bar that will appear below it once you've pressed Return. This allows you to compare and contrast the effect of different length units. ...
...y the timing function associated with the animation. Examples Length unit comparison The following demo provides you with an input field in which you can enter a <length> value (e.g. 300px, 50%, 30vw) to set the width of a result bar that will appear below it once you've pressed Return. This allows you to compare and contrast the effect of different length units. ...
... demo provides you with an input field in which you can enter a <length> value (e.g. 300px, 50%, 30vw) to set the width of a result bar that will appear below it once you've pressed Return. This allows you to compare and contrast the effect of different length units. ...
...And 7 more matches
offset-anchor - CSS: Cascading Style Sheets
e <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
... | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? | [ [ left | right ] <length-percentage> ] && [ [ top | bottom ] <length-percentage> ] ]where <length-percentage> = <length> | <percentage> Examples Setting various offset-anchor values In the following example, we have three <
div> elements nested in <section> elements. Each <
div> is given the same offset-path (a horizontal line 200 pixels long) and animated to move along it. The three are then given different background-color and offset-anchor values. Each <section> has been styled with a linear gradient to give it a horizontal line running through its center, to give you a visual display of where the <
div>'s offset paths are running. This allows you to see what effec...
...ed to move along it. The three are then given different background-color and offset-anchor values. Each <section> has been styled with a linear gradient to give it a horizontal line running through its center, to give you a visual display of where the <
div>'s offset paths are running. This allows you to see what effect the different offset-anchor values have -- the first one, auto, causes the <
div>'s center point to move along the path. The other two cause the <
div>'s top-right and bottom-left points to move along the path, respectively. ...
...And 7 more matches
offset-rotate - CSS: Cascading Style Sheets
nt is rotated similar to auto, except it faces the opposite direction. It is the same as specifying a value of auto 180deg. ...
...rotated similar to auto, except it faces the opposite direction. It is the same as specifying a value of auto 180deg. ...
...d similar to auto, except it faces the opposite direction. It is the same as specifying a value of auto 180deg. ...
...And 7 more matches
<input type="time"> - HTML: Hypertext Markup Language
"validity"></span> </form> Here's the CSS used in the above example. Here we make use of the :valid and :invalid CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a <span> next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively. ...
...time> reversed range unsupported } Making times required In addition, you can use the required attribute to make filling in the time mandatory. As a result, supporting browsers will display an error if you try to submit a time that is outside the set bounds, or an empty time field. ...
...utside the set bounds, or an empty time field. Let's look at an example; here we've set minimum and maximum times, and also made the field required: <form> <
div> <label for="appt-time">Choose an appointment time (opening hours 12:00 to 18:00): </label> <input id="appt-time" type="time" name="appt-time" min="12:00" max="18:00" required> <span class="validity"></span> </
div> <
div> <input type="submit" value="Submit form"> </
div> </form> If you try to submit the form with an incomplete time (or with a time outside the set bounds), the browser displays an error. Try playing with the example now: Here's a screenshot for those of you who aren't using a browser that supports time inputs: Important: HTML form validation is not a substitute for scripts th...
...And 7 more matches
Sending form data - Learn web development
he GET method The GET method is the method used by the browser to ask the server to send back a given resource: "Hey server, I want to get this resource." In this case, the browser sends an empty body. Because the body is empty, if a form is sent using this method the data sent to the server is appended to the URL. ...
...ey server, I want to get this resource." In this case, the browser sends an empty body. Because the body is empty, if a form is sent using this method the data sent to the server is appended to the URL. Consider the following form: <form action="http://www.foo.com" method="GET"> <
div> <label for="say">What greeting do you want to say?</label> <input name="say" id="say" value="Hi"> </
div> <
div> <label for="to">Who do you want to say it to?</label> <input name="to" id="to" value="Mom"> </
div> <
div> <button>Send my greetings</button> </
div> </form> Since the GET method has been used, you'll see the URL www.foo.com/?say=Hi&to=Mom appear in the browser address bar when you submit the form. The data is appended to the URL as a series of name/value pairs. After th...
... provided in the body of the HTTP request: "Hey server, take a look at this data and send me back an appropriate result." If a form is sent using this method, the data is appended to the body of the HTTP request. Let's look at an example -- this is the same form we looked at in the GET section above, but with the method attribute set to POST. ...
...And 6 more matches
Images in HTML - Learn web development
at it works by misspelling the image URL. Set the image's correct width and height (hint: it is 200px wide and 171px high), then experiment with other values to see what the effect is. Set a title on the image. If you make a mistake, you can always reset it using the Reset button. ...
...he image's correct width and height (hint: it is 200px wide and 171px high), then experiment with other values to see what the effect is. Set a title on the image. If you make a mistake, you can always reset it using the Reset button. ...
...t button. ...
...And 6 more matches
Client-side storage - Learn web development
nload a batch of music files (perhaps used by a web game or music player application), store them inside a client-side database, and play them as needed. The user would only have to download the music files once -- on subsequent visits they would be retrieved from the database instead. Note: There are limits to the amount of data you can store using client-side storage APIs (possibly both per in
dividual API and cumulatively); the exact limit varies depending on the browser and possibly based on user settings. See Browser storage limits and eviction criteria for more information. Old school: Cookies The concept of client-side storage has been around for a long time. Since the early days of the web, sites have used cookies to store information to personalize user experience on websites. Th...
...vaScript code into it. Create an index.js file in the same directory as your HTML file. We'll start off by creating references to all the HTML features we need to manipulate in this example -- we'll create them all as constants, as these references do not need to change in the lifecycle of the app. ...
...ame directory as your HTML file. We'll start off by creating references to all the HTML features we need to manipulate in this example -- we'll create them all as constants, as these references do not need to change in the lifecycle of the app. ...
...And 6 more matches
Useful string methods - Learn web development
ether it is present? You'll then need to write a conditional test of the form operand1 operator operand2. Is the thing on the left equal to the thing on the right? Or in this case, does the method call on the left return the result on the right? Hint: In this case it is probably more useful to test whether the method call isn't equal to a certain result. ...
...est of the form operand1 operator operand2. Is the thing on the left equal to the thing on the right? Or in this case, does the method call on the left return the result on the right? Hint: In this case it is probably more useful to test whether the method call isn't equal to a certain result. ...
...or Christmas', 'Get well soon']; for (let i = 0; i < greetings.length; i++) { let input = greetings[i]; // Your conditional test needs to go inside the parentheses // in the line below, replacing what's currently there if (greetings[i]) { let listItem = document.createElement('li'); listItem.textContent = input; list.appendChild(listItem); } } </textarea> <
div class="playable-buttons"> <input id="reset" type="button" value="Reset"> <input id="solution" type="button" value="Show solution"> </
div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.getElementById('code'); const ...
...And 6 more matches
Beginning our React todo list - Learn web development
Previous Overview: Client-side JavaScript frameworks Next Let's say that we've been tasked with creating a proof-of-concept in React - an app that allows users to add, edit, and delete tasks they want to work on, and also mark tasks as complete without deleting them. This article will walk you through putting the basic App component structure and styling in place, ready for in
dividual component definition and interactivity, which we'll add later. Note: If you need to check your code against our version, you can find a finished version of the sample React app code in our todo-react repository. For a running live version, see https://mdn.github.io/todo-react-build/. Prerequisites: Familiarity with the core HTML, CSS, and JavaScript languages, knowledge of the term...
...e, you'll have to start it again using npm start. Project starter code As a starting point for this project, we're going to provide two things: An App() function to replace the one you have now, and some CSS to style your app. ...
...For="new-todo-input" className="label__lg"> What needs to be done? ...
...And 6 more matches
Creating localizable web applications
eeds more work. <?printf("<a href=\"%s\">" . _("Step 3: Testing your Persona Images") . "</a> »", $locale_conf->url('/demo_create_3'));?> <?printf("<a href=\"%s\">" . _("Step 2: Creating a Persona Footer Image") . "</a> »", $locale_conf->url('/demo_create_2'));?> <?printf("<a href=\"%s\">" . _("Step 4: Submit your Persona!") . ...
...te_3'));?> <?printf("<a href=\"%s\">" . _("Step 2: Creating a Persona Footer Image") . "</a> »", $locale_conf->url('/demo_create_2'));?> <?printf("<a href=\"%s\">" . _("Step 4: Submit your Persona!") . "</a> »", $locale_conf->url('/demo_create_4'));?> <
div class="tut_left"><?printf("<b>« <a href=\"%s\">" . _("Back to Step 1") . "</a></b>", $locale_conf->url('/demo_create'));?></
div> <
div class="tut_right"><?printf("<b><a href=\"%s\">" . _("Continue to Step 3") . "</a> »</b>", $locale_conf->url('/demo_create_3'));?></
div> Using « and » should be OK here for RTL languages (they are flipped correctly if there are no Latin characters next to them, which there aren't any), so let's leave it as it is. In general though, we should consider implementing such deco...
...ition to which you'd concatenate the "Firefox" part. That's because some languages might require changing the word order, and others might require putting the word Firefox in the correct grammatical case. Image 4. Bad: Image 5 & Snippet 1. ...
...And 6 more matches
Scroll-linked effects
the user sees the scroll position to be. This can cause the effect to be laggy, janky, or jittery -- in short, something we want to avoid. ...
...would not work well with asynchronous scrolling, along with equivalent versions that would work well: Example 1: Sticky positioning Here is an implementation of a sticky-positioning effect, where the "toolbar"
div will stick to the top of the screen as you scroll down. <body style="height: 5000px" onscroll="document.getElementById('toolbar').style.top = Math.max(100, window.scrollY) + 'px'"> <
div id="toolbar" style="position: absolute; top: 100px; width: 100px; height: 20px; background-color: green"></
div> </body> This implementation of sticky positioning relies on the scroll event listener to reposition the "toolbar"
div. As the scroll event listener runs in the JavaScript on the browser's main thread, it will be asynchronous relative to the user-visible scrolling. Therefore, with async...
...een"></
div> </body> This implementation of sticky positioning relies on the scroll event listener to reposition the "toolbar"
div. As the scroll event listener runs in the JavaScript on the browser's main thread, it will be asynchronous relative to the user-visible scrolling. Therefore, with asynchronous scrolling, the event handler will be delayed relative to the user-visible scroll, and so the
div will not stay visually fixed as intended. Instead, it will move with the user's scrolling, and then "snap" back into position when the scroll event handler runs. This constant moving and snapping will result in a jittery visual effect. ...
...And 6 more matches
Component; nsIPrefBranch
rences referenced by this branch. Note: This method can be called on either a default or user branch but, in effect, always operates on both. void deleteBranch( in string aStartingAt ); Parameters aStartingAt The point on the branch at which to start the deleting preferences. Pass in "" to remove all preferences referenced by this branch. getBoolPref() Called to get the state of an in
dividual boolean preference. boolean getBoolPref( in string aPrefName, [optional] in boolean aDefaultValue ); Parameters aPrefName The boolean preference to get the state of. aDefaultValue Requires Gecko 54 Optional - a default value to use if the preference does not exist (instead of throwing an exception). Return value The value of the requested boolean preference. getCharPref() C...
...ean getBoolPref( in string aPrefName, [optional] in boolean aDefaultValue ); Parameters aPrefName The boolean preference to get the state of. aDefaultValue Requires Gecko 54 Optional - a default value to use if the preference does not exist (instead of throwing an exception). Return value The value of the requested boolean preference. getCharPref() Called to get the state of an in
dividual string preference. string getCharPref( in string aPrefName, [optional] in string aDefaultValue ); Parameters aPrefName The string preference to retrieve. aDefaultValue Requires Gecko 54 Optional - a default value to use if the preference does not exist (instead of throwing an exception). Return value Returns string - The value of the requested string preference. getStr...
...ameters aPrefName The string preference to retrieve. aDefaultValue Requires Gecko 54 Optional - a default value to use if the preference does not exist (instead of throwing an exception). Return value Returns string - The value of the requested string preference. getStringPref() Requires Gecko 58 (Firefox 58 / Thunderbird 58 / SeaMonkey 2.55) Called to get the state of an in
dividual UTF-8 string preference. utf8string getStringPref( in string aPrefName, [optional] in utf8string aDefaultValue ); Parameters aPrefName The string preference to retrieve. aDefaultValue Optional - a default value to use if the preference does not exist (instead of throwing an exception). Return value Returns utf8tring - The value of the requested string preference. getChildLis...
...And 6 more matches
Document.createElement() - Web APIs
refox, Opera, and Chrome, createElement(null) works like createElement("null"). options Optional An optional ElementCreationOptions object, containing a single property named is, whose value is the tag name of a custom element previously defined via customElements.define(). See Web component example for more details. Return value The new Element. ...
...like createElement("null"). options Optional An optional ElementCreationOptions object, containing a single property named is, whose value is the tag name of a custom element previously defined via customElements.define(). See Web component example for more details. Return value The new Element. Examples Basic example This creates a new <
div> and inserts it before the element with the ID "
div1". ...
...ngle property named is, whose value is the tag name of a custom element previously defined via customElements.define(). See Web component example for more details. Return value The new Element. Examples Basic example This creates a new <
div> and inserts it before the element with the ID "
div1". ...
...And 6 more matches
Multi-touch interaction - Web APIs
ithub. The source code is available on Github and pull requests and bug reports are welcome. Example This example demonstrates using the touchstart, touchmove, touchcancel, and touchend) touch events for the following gestures: single touch, two (simultaneous) touches, more than two simultaneous touches, 1-finger swipe, and 2-finger move/pinch/swipe. ...
...equests and bug reports are welcome. Example This example demonstrates using the touchstart, touchmove, touchcancel, and touchend) touch events for the following gestures: single touch, two (simultaneous) touches, more than two simultaneous touches, 1-finger swipe, and 2-finger move/pinch/swipe. Define touch targets The application uses <
div> elements to represent four touch areas. ...
...ler restores the event target's background color back to its original color. ...
...And 6 more matches
Using the aria-labelledby attribute - Accessibility
e A space-separated list of element IDs Possible effects on user agents and assistive technology When user agents compute the accessible name property of elements that have both an aria-labelledby attribute and an aria-label attribute, the user agents give precedence to aria-labelledby. ...
...e effects on user agents and assistive technology When user agents compute the accessible name property of elements that have both an aria-labelledby attribute and an aria-label attribute, the user agents give precedence to aria-labelledby. Examples Example 1: Multiple Labels In the example below, each input field is labelled by both its own in
dividual label and by the label for the group: <
div id="myBillingId">Billing</
div> <
div> <
div id="myNameId">Name</
div> <input type="text" aria-labelledby="myBillingId myNameId"/> </
div> <
div> <
div id="myAddressId">Address</
div> <input type="text" aria-labelledby="myBillingId myAddressId"/> </
div> Example 2: Associating Headings With Regions In the example below, header elements are associated with the content they head. Note th...
... <input type="text" aria-labelledby="myBillingId myNameId"/> </
div> <
div> <
div id="myAddressId">Address</
div> <input type="text" aria-labelledby="myBillingId myAddressId"/> </
div> Example 2: Associating Headings With Regions In the example below, header elements are associated with the content they head. Note that the region being referenced is the region that contains the header. <
div role="main" aria-labelledby="foo"> <h1 id="foo">Wild fires spread across the San Diego Hills</h1> Strong winds expand fires ignited by high temperatures ... ...
...And 6 more matches
Using the group role - Accessibility
used control may be announced. Screen magnifiers may enlarge the group. Note: Opinons may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Using the group role with a HTML tree view The snippet below shows how the group role is added directly into the html source code. ...
...iers may enlarge the group. Note: Opinons may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Using the group role with a HTML tree view The snippet below shows how the group role is added directly into the html source code. ...
...ole with a HTML tree view The snippet below shows how the group role is added directly into the html source code. ...
...And 6 more matches
An overview of accessible web applications and widgets - Accessibility
t JavaScript libraries offer a library of client-side widgets that mimic the behavior of familiar desktop interfaces. Sliders, menu bars, file list views, and more can be built with a combination of JavaScript, CSS, and HTML. Since the HTML4 specification doesn't provide built-in tags that semantically describe these kinds of widgets, developers typically resort to using generic elements such as <
div> and <span>. While this results in a widget that looks like its desktop counterpart, there usually isn't enough semantic information in the markup to be usable by an assistive technology. The problem Dynamic content on a web page can be particularly problematic for users who, for whatever reason, are unable to view the screen. Stock tickers, live twitter feed updates, progress indicators, and s...
...get built without ARIA labeling. There's no information in the markup to describe the widget's form and function. <!-- This is a tabs widget. How would you know, looking only at the markup? --> <ol> <li id="ch1Tab"> <a href="#ch1Panel">Chapter 1</a> </li> <li id="ch2Tab"> <a href="#ch2Panel">Chapter 2</a> </li> <li id="quizTab"> <a href="#quizPanel">Quiz</a> </li> </ol> <
div> <
div id="ch1Panel">Chapter 1 content goes here</
div> <
div id="ch2Panel">Chapter 2 content goes here</
div> <
div id="quizPanel">Quiz content goes here</
div> </
div> Example 2: How the tabs widget might be styled visually. Users might recognize it visually, but there are no machine-readable semantics for an assistive technology. ARIA ARIA enables developers to describe their widgets in mo...
...abs widget with ARIA attributes added. <!-- Now *these* are Tabs! --> <!-- We've added role attributes to describe the tab list and each tab. ...
...And 6 more matches
Stacking context example 3 - CSS: Cascading Style Sheets
<< CSS << Understanding CSS z-index Stacking context example 3 This last example shows problems that arise when mixing several positioned elements in a multi-level HTML hierarchy and when z-indexes are assigned using class selectors. Let's take as an example a three-level hierarchical menu made from several positioned
DIVs. Second-level and third-level
DIVs appear when hovering or clicking on their parents. Usually this kind of menu is script-generated either client-side or server-side, so style rules are assigned with a class selector instead of the id selector. If the three menu levels partially overlap, then managing stacking could become a problem. The first-level menu is only relatively positioned, so no stacking context is created. The second-level menu is absolutely positioned...
...nd the situation, here is the stacking context hierarchy: root stacking context LEVEL #1 LEVEL #2 (z-index: 1) LEVEL #3 ... LEVEL #3 LEVEL #2 (z-index: 1) ... LEVEL #2 (z-index: 1) LEVEL #1 ... LEVEL #1 This problem can be avoided by removing overlapping between different level menus, or by using in
dividual (and different) z-index values assigned through the id selector instead of class selector, or by flattening the HTML hierarchy. Note: In the source code you will see that second-level and third level menus are made of several
DIVs contained in an absolutely positioned container. This is useful to group and position all of them at once. Example source code <!DOCTYPE html PUBLIC "-//W3C//DT...
...archy. Note: In the source code you will see that second-level and third level menus are made of several
DIVs contained in an absolutely positioned container. This is useful to group and position all of them at once. ...
...And 6 more matches
backface-visibility - CSS: Cascading Style Sheets
rmable elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax visible | hidden Examples Cube with transparent and opaque faces This example shows a cube with transparent faces, and one with opaque faces. ...
...ed valueas specifiedAnimation typediscrete Formal syntax visible | hidden Examples Cube with transparent and opaque faces This example shows a cube with transparent faces, and one with opaque faces. ...
...screte Formal syntax visible | hidden Examples Cube with transparent and opaque faces This example shows a cube with transparent faces, and one with opaque faces. ...
...And 6 more matches
transition-delay - CSS: Cascading Style Sheets
nsition-delay: initial; transition-delay: unset; Values <time> Denotes the amount of time to wait between a property's value changing and the start of the transition effect. ...
... transition-delay: unset; Values <time> Denotes the amount of time to wait between a property's value changing and the start of the transition effect. ...
...t; Values <time> Denotes the amount of time to wait between a property's value changing and the start of the transition effect. ...
...And 6 more matches
transition-duration - CSS: Cascading Style Sheets
of 0s indicates that no transition will happen, that is the switch between the two states will be instantaneous. A negative value for the time renders the declaration invalid. ...
...o transition will happen, that is the switch between the two states will be instantaneous. A negative value for the time renders the declaration invalid. ...
...n, that is the switch between the two states will be instantaneous. A negative value for the time renders the declaration invalid. ...
...And 6 more matches
Index - Archive of obsolete content
he Inspector window displays a tree representation of the browser window's XUL file. When you select a node in the tree, a red border flashes for several seconds around the visual representation of that node in the browser window. 392 Finding the file to modify Add-ons, Extensions Now that we have a hackable Mozilla, it's time to find the file we want to hack. Mozilla's UI is
divided into three layers: the structure, the style, and the behavior. The structure layer identifies the widgets (menus, buttons, etc.) and their position in the UI relative to each other, the style layer defines how the widgets look (size, color, style, etc.) and their overall position (alignment), and the behavior layer specifies how the widgets behave and how users can use them to accomplish thei...
...talked about XUL, Mozilla's XML User Interface toolkit. 747 XTech 2006 Presentations Presentations No summary! 748 XUL Landing, Mozilla, XUL XUL (XML User Interface Language) is Mozilla's XML-based language for building user interfaces of applications like Firefox. 749 <statusbarpanel> Deprecated, XUL, XUL Elements, XUL Reference An in
dividual element of a statusbar. This is a special type of button which is drawn differently. Unlike normal buttons, a statusbarpanel can only have a label or an image but not both. This element is often used with a short label or icon to indicate status, for instance whether the user is online or whether there are new messages. 750 A XUL Bestiary Add-ons, Extensions, NeedsTechnicalRev...
...ibility is a new technology which enables developers to construct accessible controls within (X)HTML pages. Developers have been doing this for some time, but the resulting controls were never as accessible as similar controls in desktop applications. Assistive technologies could only see the generic HTML markup used to build the control; they had no way of knowing that a particular collection of
div and span elements should be treated as a single cohesive control (such as a tab bar or a treeview). 1153 Deprecated and defunct markup Reference, XUL {many elements on this page are wrongly marked as deprecated, this page needs review} 1154 Dynamically modifying XUL-based user interface Add-ons, DOM, Extensions, XUL This article discusses manipulating XUL...
...And 5 more matches
Inner-browsing extending the browser navigation paradigm - Archive of obsolete content
e, so the existing DHTML ticker application is able to handle it. Special Markup to support the model It's important to add special markup that fulfills the requirements of the application. This example uses an IFRAME element as the mechanism to establish the communication with the server side application. So the following piece of HTML defines an IFRAME element which is not visible to the user: <
div style="visibility:hidden; position:absolute; top:-1000px; left:-1000px"> <iframe id="bridgeFrame" src=""></iframe> </
div> The JavaScript code located in the Data Loader component will be interacting with this IFRAME element, requesting data from the server. Note that when the data is available (a web page is loaded into the IFRAME) this will not affect the web page context because the IFRAME is n...
...context of the parent document (the originator). Here, iframeCallback is considered the Data Binder, so it is responsible for getting the content from the IFRAME and putting it in the proper repository in the page's context. Note the following piece of code: function iframeCallback(doc) { /* Copies the data in the iframe to the main page */ myData = doc.getElementById("mydata"); ticker
Div.innerHTML = myData.innerHTML; } The callback is called with the parameter doc, which is a reference to the IFRAME's document). The code locates element with ID mydata then copies the content of mydata (myData.innerHTML) into the ticker
Div element (
DIV element that is the container of elements into the Ticker). The above example is a simplified version of the inner-browsing model, but it gives you...
...dge-temp.mozilla.org/central/css/catalog-new_en.xml http://web.archive.org/web/20090218052536/http://devedge-temp.mozilla.org/viewsource/catalog-new_en.xml Data Binder Component This procedure traverses the DOM that was returned via XMLHTTPRequest and generates markup based on the data provided in the DOM nodes. When the markup is ready, it copies the markup into the container element, which is a
DIV element. The following code snippet shows a simplified version of the logic that happens in the actual sample: // doc is the DOM to the document returned articles=doc.getElementsByTagName("article"); for(i=0;i<articles.length;i++) { // acquiring the data from the DOM... articleTitle=article.getElementsByTagName("article").item(0).firstChild.nodeValue; // inserting the content into the conta...
...And 5 more matches
Using Spacers - Archive of obsolete content
(Java uses layout managers for example.) XUL provides the capability for elements to position and resize automatically. As we've seen, the find files window has appeared in a size that will fit the elements inside it. Each time we add something, the window gets bigger. XUL uses a layout system called the 'Box Model'. We'll talk more about this in the next section but it essentially allows you to
divide a window into a series of boxes that hold elements. The boxes will be positioned and resized based on specifications that you can define. For now, just know that the window element is a type of box. Before we get into detail about boxes, we'll introduce another XUL element that is useful for layout, the spacer. A spacer is very simple and only requires one attribute, which will be explained in...
.... It works much the same way as a button except it does not draw on screen. You may have noticed something about the image above. Not only did the Find button grow in size but some space has appeared between the main label and the button. Of course, this is the spacer that we put in earlier. It has resized itself also. If you look closely enough, you should notice that the change in size has been
divided up equally between the spacer and the button. The spacer has received half of the free space and the button has received the other half. The reason we're seeing this effect is that both the spacer and the Find button have a flex attribute. Because both are flexible, both the button and the spacer resize equally. What if you want to set one element to grow twice as large an another? You can us...
...he flex attribute. The values of the flex element are a ratio. If one element has a flex of 1 and the next one has a flex of 2, the second one will grow at twice the rate of the first one. In effect, a flex of 2 says that this element has a flex that is two times the elements that have a flex of one. The flex attribute isn't used to specify an actual size. Instead, it specifies how empty space it
divided among the children of a container box. We'll look at boxes in the next section. Once the default sizes of the children of a box are determined, the flexibility values are used to
divide up the remaining empty space in the box. For example, if a box is 200 pixels wide and contains two flexible buttons, the first 50 pixels and the other 90 pixels, there will be 60 pixels of space left over. If ...
...And 5 more matches
Cooperative asynchronous JavaScript: Timeouts and intervals - Learn web development
ulate the number of hours, minutes, and seconds as separate values, and then show them together in a string after each loop iteration. From the second counter, you can work out each of these. How would you calculate them? Have a think about it: The number of seconds in an hour is 3600. The number of minutes will be the amount of seconds left over when all of the hours have been removed,
divided by 60. The number of seconds will be the amount of seconds left over when all of the minutes have been removed. You'll want to include a leading zero on your display values if the amount is less than 10, so it looks more like a traditional clock/watch. To pause the stopwatch, you'll want to clear the interval. To reset it, you'll want to set the counter back to 0, clear the interval...
...world example, you should probably use CSS animations to run this kind of simple animation. However, this kind of example is very useful to demonstrate requestAnimationFrame() usage, and you'd be more likely to use this kind of technique when doing something more complex such as updating the display of a game on each frame. Grab a basic HTML template (such as this one). Put an empty <
div> element inside the <body>, then add a ? character inside it. This circular arrow character will act as our spinner for this example. Apply the following CSS to the HTML template (in whatever way you prefer). This sets a red background on the page, sets the <body> height to 100% of the <html> height, and centers the <
div> inside the <body>, horizontally and vertically. html { backgroun...
...he HTML template (in whatever way you prefer). This sets a red background on the page, sets the <body> height to 100% of the <html> height, and centers the <
div> inside the <body>, horizontally and vertically. html { background-color: white; height: 100%; } body { height: inherit; background-color: red; margin: 0; display: flex; justify-content: center; align-items: center; }
div { display: inline-block; font-size: 10rem; } Insert a <script> element just above the closing </body> tag. Insert the following JavaScript inside your <script> element. ...
...And 5 more matches
A first splash into JavaScript - Learn web development
x-width: 800px; min-width: 480px; margin: 0 auto; } .lastResult { color: white; padding: 3px; } </style> </head> <body> <h1>Number guessing game</h1> <p>We have selected a random number between 1 and 100. See if you can guess it in 10 turns or fewer. ...
...ead> <body> <h1>Number guessing game</h1> <p>We have selected a random number between 1 and 100. See if you can guess it in 10 turns or fewer. ...
...y> <h1>Number guessing game</h1> <p>We have selected a random number between 1 and 100. See if you can guess it in 10 turns or fewer. ...
...And 5 more matches
Arrays - Learn web development
stand what arrays are and how to manipulate them in JavaScript. What is an array? Arrays are generally described as "list-like objects"; they are basically single objects that contain multiple values stored in a list. Array objects can be stored in variables and dealt with in much the same way as any other type of value, the difference being that we can access each value inside the list in
dividually, and do super useful and efficient things with the list, like loop through it and do the same thing to every value. Maybe we've got a series of product items and their prices stored in an array, and we want to loop through them all and print them out on an invoice, while totaling all the prices together and printing out the total price at the bottom. If we didn't have arrays, we'd have to...
...ngs, numbers, objects, and even other arrays. We can also mix data types in a single array -- we do not have to limit ourselves to storing only numbers in one array, and in another only strings. For example: let sequence = [1, 1, 2, 3, 5, 8, 13]; let random = ['tree', 795, [0, 1, 2]]; Before proceeding, create a few example arrays. Accessing and modifying array items You can then access in
dividual items in the array using bracket notation, in the same way that you accessed the letters in a string. Enter the following into your console: shopping[0]; // returns "bread" You can also modify an item in an array by simply giving a single array item a new value. Try this: shopping[0] = 'tahini'; shopping; // shopping will now return [ "tahini", "milk", "cheese", "hummus", "noodles"...
...ment operator to do this. We want you to change the line just below // number 5 so that the itemText variable is made equal to "current item name -- $current item price", for example "Shoes -- $23.99" in each case, so the correct information for each item is printed on the invoice. This is just simple string concatenation, which should be familiar to you. ...
...And 5 more matches
Basic math in JavaScript — numbers and operators - Learn web development
ulate numbers to do our bidding. Prerequisites: Basic computer literacy, a basic understanding of HTML and CSS, an understanding of what JavaScript is. Objective: To gain familiarity with the basics of math in JavaScript. Everybody loves math Okay, maybe not. Some of us like math, some of us have hated math ever since we had to learn multiplication tables and long
division in school, and some of us sit somewhere in between the two. But none of us can deny that math is a fundamental part of life that we can't get very far without. This is especially true when we are learning to program JavaScript (or any other language for that matter) -- so much of what we do relies on processing numerical data, calculating new values, and so on, that you won't be surprised to...
...er) + 3; Arithmetic operators Arithmetic operators are the basic operators that we use to do sums in JavaScript: Operator Name Purpose Example + Addition Adds two numbers together. 6 + 9 - Subtraction Subtracts the right number from the left. 20 - 15 * Multiplication Multiplies two numbers together. 3 * 7 /
Division
Divides the left number by the right. 10 / 5 % Remainder (sometimes called modulo) Returns the remainder left over after you've
divided the left number into a number of integer portions equal to the right number. 8 % 3 (returns 2, as three goes into 8 twice, leaving 2 left over). ** Exponent Raises a base number to the exponent power, ...
...ht not give you quite the result you were expecting; the section below might well give the answer as to why. ...
...And 5 more matches
Starting our Svelte Todo list app - Learn web development
document.body }) export default app Now if you check your testing server URL you'll see our Todos.svelte component being rendered: Adding static markup For the moment we will start with a static markup representation of our app, so you can see what it will look like. ...
...="todoapp stack-large"> <!-- NewTodo --> <form> <h2 class="label-wrapper"> <label for="todo-0" class="label__lg"> What needs to be done? ...
...ton> <button class="btn toggle-btn" aria-pressed="false"> <span class="visually-hidden">Show</span> <span>Active</span> <span class="visually-hidden">tasks</span> </button> <button class="btn toggle-btn" aria-pressed="false"> <span class="visually-hidden">Show</span> <span>Completed</span> <span class="visually-hidden">tasks</span> </button> </
div> <!-- TodosStatus --> <h2 id="list-heading">2 out of 3 items completed</h2> <!-- Todos --> <ul role="list" class="todo-list stack-large" aria-labelledby="list-heading"> <!-- todo-1 (editing mode) --> <li class="todo"> <
div class="stack-small"> <form class="stack-small"> <
div class="form-group"> <label for="todo-1" class="todo-label"> ...
...And 5 more matches
DataTransfer.getData() - Web APIs
ion has no data for the specified format, this method returns an empty string. Caveats Data availability The HTML5 Drag and Drop Specification dictates a drag data store mode. This may result in unexpected behavior, being DataTransfer.getData() not returning an expected value. Example This example shows the use of the DataTransfer object's getData() and setData() methods. ...
...no data for the specified format, this method returns an empty string. Caveats Data availability The HTML5 Drag and Drop Specification dictates a drag data store mode. This may result in unexpected behavior, being DataTransfer.getData() not returning an expected value. Example This example shows the use of the DataTransfer object's getData() and setData() methods. ...
...g data store mode. This may result in unexpected behavior, being DataTransfer.getData() not returning an expected value. Example This example shows the use of the DataTransfer object's getData() and setData() methods. ...
...And 5 more matches
Element.scrollWidth - Web APIs
hout a need for horizontal scrollbar, its scrollWidth is equal to clientWidth This property will round the value to an integer. If you need a fractional value, use element.getBoundingClientRect(). Syntax var xScrollWidth = element.scrollWidth; xScrollWidth is the width of the content of element in pixels. ...
...u need a fractional value, use element.getBoundingClientRect(). Syntax var xScrollWidth = element.scrollWidth; xScrollWidth is the width of the content of element in pixels. ...
...the content of element in pixels. ...
...And 5 more matches
GlobalEventHandlers.onanimationcancel - Web APIs
ancel; target.onanimationcancel = Function Value A Function to be called when an animationcancel event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...ationcancel = Function Value A Function to be called when an animationcancel event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...nimationcancel event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...And 5 more matches
GlobalEventHandlers.onanimationend - Web APIs
nd; target.onanimationend = Function Value A Function to be called when an animationend event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...onend = Function Value A Function to be called when an animationend event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...Value A Function to be called when an animationend event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...And 5 more matches
GlobalEventHandlers.onanimationiteration - Web APIs
indow (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. Example Let's create an animation which automatically pauses at the end of each iteration, allowing the user to choose whether or not to start the next iteration. Much of this code is the same as in other examples of animation events, so it may look familiar. ...
...unction receives as input a single parameter: an AnimationEvent object describing the event which occurred. Example Let's create an animation which automatically pauses at the end of each iteration, allowing the user to choose whether or not to start the next iteration. Much of this code is the same as in other examples of animation events, so it may look familiar. ...
... input a single parameter: an AnimationEvent object describing the event which occurred. Example Let's create an animation which automatically pauses at the end of each iteration, allowing the user to choose whether or not to start the next iteration. Much of this code is the same as in other examples of animation events, so it may look familiar. ...
...And 5 more matches
GlobalEventHandlers.onanimationstart - Web APIs
target.onanimationstart = Function Value A Function to be called when an animationstart event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...art = Function Value A Function to be called when an animationstart event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...lue A Function to be called when an animationstart event occurs indicating that a CSS animation has begun on the target, where the target object is an HTML element (HTMLElement), document (Document), or window (Window). The function receives as input a single parameter: an AnimationEvent object describing the event which occurred. ...
...And 5 more matches
Ajax navigation example - Web APIs
ew_as"]) && $_GET["view_as"] == "json") { $as_json = true; ob_start(); } else { ?> <!doctype html> <html> <head> <?php include "include/header.php"; echo "<title>" . $page_title . ...
.../head> <body> <?php include "include/before_content.php"; ?> <p>This paragraph is shown only when the navigation starts from <strong>first_page.php</strong>.</p> <
div id="ajax-content"> <?php } ?> <p>This is the content of <strong>first_page.php</strong>.</p> <?php if ($as_json) { echo json_encode(array("page" => $page_title, "content" => ob_get_clean())); } else { ?> </
div> <p>This paragraph is shown only when the navigation starts from <strong>first_page.php</strong>.</p> <?php include "include/after_content.php"; echo "</body>\n</html>"; } ?> second_page.php: <?php $page_title = "Second page"; $as_json = false; if (isset($_GET["view_as"]) && $_GET["view_as"] == "json") { $as_json = true; ob_start(); } el...
...w_as"]) && $_GET["view_as"] == "json") { $as_json = true; ob_start(); } else { ?> <!doctype html> <html> <head> <?php include "include/header.php"; echo "<title>" . $page_title . ...
...And 5 more matches
KeyboardEvent.key - Web APIs
quence generated when we interact with the Shift and the 2 key using a U.S keyboard layout as compared to when we do so using a UK keyboard layout. Try experimenting using the following two test cases: Press and hold the Shift key, then press 2 and release it. Next, release the Shift key. Press and hold the Shift key, then press and hold 2. Release the Shift key. Finally, release 2. ...
...en we interact with the Shift and the 2 key using a U.S keyboard layout as compared to when we do so using a UK keyboard layout. Try experimenting using the following two test cases: Press and hold the Shift key, then press 2 and release it. Next, release the Shift key. Press and hold the Shift key, then press and hold 2. Release the Shift key. Finally, release 2. ...
...cases: Press and hold the Shift key, then press 2 and release it. Next, release the Shift key. Press and hold the Shift key, then press and hold 2. Release the Shift key. Finally, release 2. ...
...And 5 more matches
MediaDevices.ondevicechange - Web APIs
ow two lists: one of audio devices and one of video devices, with both the device's label (name) and whether it's an input or an output device. Because the example provides a handler for the devicechange event, the list is refreshed any time a media device is attached to or removed from the device running the sample. ...
...ideo devices, with both the device's label (name) and whether it's an input or an output device. Because the example provides a handler for the devicechange event, the list is refreshed any time a media device is attached to or removed from the device running the sample. ...
...put or an output device. Because the example provides a handler for the devicechange event, the list is refreshed any time a media device is attached to or removed from the device running the sample. ...
...And 5 more matches
MediaStreamConstraints.audio - Web APIs
eature enabled. See Security in MediaDevices.getUserMedia() for details and examples on how to configure this. Using a Boolean value In this example, we provide a simple value of true for the audio property. This tells getUserMedia() that we require an audio track, but we don't care about any specifics beyond that. ...
...tUserMedia() for details and examples on how to configure this. Using a Boolean value In this example, we provide a simple value of true for the audio property. This tells getUserMedia() that we require an audio track, but we don't care about any specifics beyond that. ...
...re this. Using a Boolean value In this example, we provide a simple value of true for the audio property. This tells getUserMedia() that we require an audio track, but we don't care about any specifics beyond that. ...
...And 5 more matches
MediaStreamConstraints.video - Web APIs
ainable properties. If you specify constraints, a video track meeting these constraints is required. Examples Using a Boolean value In this example, we provide a simple value of true for the video property. This tells getUserMedia() that we require a video track, but we don't care about any specifics beyond that. ...
... a video track meeting these constraints is required. Examples Using a Boolean value In this example, we provide a simple value of true for the video property. This tells getUserMedia() that we require a video track, but we don't care about any specifics beyond that. ...
... a Boolean value In this example, we provide a simple value of true for the video property. This tells getUserMedia() that we require a video track, but we don't care about any specifics beyond that. ...
...And 5 more matches
Pointer events - Web APIs
<html> <script> var id = -1; function process_id(event) { // Process this event based on the event's identifier } function process_mouse(event) { // Process the mouse pointer event } function process_pen(event) { ...
...terdown = down_handler; el.onpointermove = move_handler; el.onpointerup = up_handler; el.onpointercancel = cancel_handler; el.onpointerout = out_handler; el.onpointerleave = leave_handler; el.gotpointercapture = gotcapture_handler; el.lostpointercapture = lostcapture_handler; } </script> <body onload="init();"> <
div id="target"> Touch me ... </
div> </body> </html> Event properties This example illustrates accessing all of a touch event's properties. <html> <script> var id = -1; function process_id(event) { // Process this event based on the event's identifier } function process_mouse(event) { // Process the mouse pointer event } function process_pen(event) { // Process the pen pointer even...
...The application can use the isPrimary property to identify a master pointer among the set of...
...And 5 more matches
ResizeObserver - Web APIs
ll observed Element targets of a particular observer. ResizeObserver.observe() Initiates the observing of a specified Element. ResizeObserver.unobserve() Ends the observing of a specified Element. Examples In the resize-observer-text.html (see source) example, we use the resize observer to change the font-size of a header and paragraph as a slider's value is changed causing the containing <
div> to change width. This shows that you can respond to changes in an element's size, even if they have nothing to do with the viewport. We also provide a checkbox to turn the observer off and on. If it is turned off, the text will not change in response to the <
div>'s width changing. The JavaScript looks like so: const h1Elem = document.querySelector('h1'); const pElem = document.querySelector('...
... width. This shows that you can respond to changes in an element's size, even if they have nothing to do with the viewport. We also provide a checkbox to turn the observer off and on. If it is turned off, the text will not change in response to the <
div>'s width changing. ...
...o changes in an element's size, even if they have nothing to do with the viewport. We also provide a checkbox to turn the observer off and on. If it is turned off, the text will not change in response to the <
div>'s width changing. ...
...And 5 more matches
Controlling multiple parameters with ConstantSourceNode - Web APIs
t this technique in action. In this simple example, we create three OscillatorNodes. Two of them have adjustable gain, controlled using a shared input control. The other oscillator has a fixed volume. HTML The HTML content for this example is primarily a button to toggle the oscillator tones on and off and an <input> element of type range to control the volume of two of the three oscillators. ...
...n. In this simple example, we create three OscillatorNodes. Two of them have adjustable gain, controlled using a shared input control. The other oscillator has a fixed volume. HTML The HTML content for this example is primarily a button to toggle the oscillator tones on and off and an <input> element of type range to control the volume of two of the three oscillators. ...
...le, we create three OscillatorNodes. Two of them have adjustable gain, controlled using a shared input control. The other oscillator has a fixed volume. HTML The HTML content for this example is primarily a button to toggle the oscillator tones on and off and an <input> element of type range to control the volume of two of the three oscillators. ...
...And 5 more matches
Basic form hints - Accessibility
WAI-ARIA, the Accessible Rich Internet Applications specification from the W3C's Web Accessibility Initiative, provides the aria-labelledby attribute for these cases. The example below shows a radio button group implemented using an unordered list. Note that on line 3, the <ul> element sets the aria-labelledby attribute to rg1_label, the id of the <h3> element on line 1, which is t...
...ed="true"> <img role="presentation" src="radio-checked.gif" /> Radio Maria </li> </ul> Describing with ARIA Form controls sometimes have a description associated with them, in addition to the label. ARIA provides the aria-describedby attribute to directly associate the description with the control. The example below shows a <button> element that is described by a sentence in a separate <
div> element. The aria-describedby attribute on the <button> references the id of the <
div>. <button aria-describedby="descriptionRevert">Revert</button> <
div id="descriptionRevert">Reverting will undo any changes that have been made since the last save.</
div> Note: The aria-describedby attribute is used for other purposes, in addition to form controls. Required and i...
...a-required attributes are set to true (in addition to the asterisks next to the labels), indicating that the name and email fields are required. The second part of the example, a snippet of JavaScript validates the email format, and sets the aria-invalid attribute of the email field (line 12 of the HTML) according to the result (in addition to changing the presentation of the element). ...
...And 5 more matches
Coordinate systems - CSS: Cascading Style Sheets
ents on) contains several paragraphs; one for each of the four coordinate systems we'll be reporting on. let inner = document.querySelector(".inner"); let log = document.querySelector(".log"); function setCoords(e, type) { let idX = type + "X"; let idY = type + "Y"; document.getElementById(idX).innerText = e[idX]; document.getElementById(idY).innerText = e[idY]; } A reference to the <
div> inside the inner box which contains the paragraphs that will show the coordinate information is fetched into log. The setCoords() function is designed to accept as input a MouseEvent and the name of the origin to use when obtaining the coordinates. The implementation is then quite simple. The variables idX and idY are set to strings with the names of the properties corresponding to the coordina...
...ventListener("mouseleave", update, false); The event handler is in the update() method. It simply calls setCoords() once for each coordinate system, passing in the event that occurred. Our main code sets up the event handlers on the inner box by calling addEventListener() for each of the types mouseenter, mousemove, and mouseleave. HTML The HTML for our example is below. ...
...nt that occurred. Our main code sets up the event handlers on the inner box by calling addEventListener() for each of the types mouseenter, mousemove, and mouseleave. HTML The HTML for our example is below. Note that within the <
div> with the ID "log", we have a paragraph for each coordinate system, with span used for each of the elements to receive and display the coordinates in each model. ...
...And 5 more matches
CSS Grid Layout and Progressive Enhancement - CSS: Cascading Style Sheets
der-radius: 5px; background-color: #fff4e6; max-width: 400px; display: grid; grid-template-columns: 1fr 2fr; grid-template-areas: "img content"; margin-bottom: 1em; } .media::after { content: ""; display: block; clear: both; } .media .image { float: left; width: 150px; margin-right: 20px; } .media .text { padding: 10px; align-self: end; } <
div class="media"> <
div class="image"><img src="https://udn.realityripple.com/samples/89/f993f273dd.png" alt="placeholder"></
div> <
div class="text">This is a media object example. I am using floats for older browsers and grid for new ones.</
div> </
div> The image below shows the media object in a non-supporting browser on the left, and a supporting one on the right: Using feature queri...
...lor: #fff4e6; max-width: 600px; margin: 0 auto; } .wrapper li { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper ul { overflow: hidden; margin: 0 -10px; padding: 0; list-style: none; } .wrapper li { float: left; width: calc(33.333333% - 20px); margin: 0 10px 20px 10px; } <
div class="wrapper"> <ul> <li class="card"><h2>One</h2> <p>We can use CSS Grid to overwrite older methods.</p> </li> <li class="card"><h2>Two</h2> <p>We can use CSS Grid to overwrite older methods.</p> </li> <li class="card"><h2>Three</h2> <p>We can use CSS Grid to overwrite older methods.</p> </li> <li cl...
... As a concession for older browsers, I have set a min-height on the items, and hope that my content editors won't add too much content and make a mess of the layout! I then enhance the layout using grid. I can turn my <ul> into a grid containe...
...And 5 more matches
animation - CSS: Cascading Style Sheets
ne https://github.com/mdn/interactive-examples and send us a pull request. ...
.../mdn/interactive-examples and send us a pull request. ...
...les and send us a pull request. ...
...And 5 more matches
background-position - CSS: Cascading Style Sheets
tage>? ] ]where <length-percentage> = <length> | <percentage> Examples Positioning background images Each of these three examples uses the background property to create a yellow, rectangular element containing a star image. In each example, the star is in a different position. The third example illustrates how to specify positions for two different background images within one element. ...
...= <length> | <percentage> Examples Positioning background images Each of these three examples uses the background property to create a yellow, rectangular element containing a star image. In each example, the star is in a different position. The third example illustrates how to specify positions for two different background images within one element. ...
...gth> | <percentage> Examples Positioning background images Each of these three examples uses the background property to create a yellow, rectangular element containing a star image. In each example, the star is in a different position. The third example illustrates how to specify positions for two different background images within one element. ...
...And 5 more matches
border-image-slice - CSS: Cascading Style Sheets
These regions form the components of an element's border image. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. The slicing process creates nine regions in total: four corners, four edges, and a middle region. Four slice lines, set a given distance from their respective sides, control the size of the regions. The above diagram illustrates the location of each region. Zones 1-4 are corner regions. Each one is used a single time to form the corners of the final border image. ...
...The source image for the borders is as follows: The diamonds are 30px across, therefore setting 30 pixels as the value for both border-width and border-image-slice will get you complete and fairly crisp diamonds in your border: border-width: 30px; border-image-slice: 30; These are the default values we have used in this example. However, we have also provided ...
...the fill keyword is used) -- varying this away from 30 causes the border to look somewhat irregular, but can have some interesting effects. border-width: Changes the width of the border. The sampled image size is scaled to fit inside the border, which means that if the width is bigger than the slice, the image can start to look somewhat pixellated (unless of course you use an SVG image). ...
...And 5 more matches
<easing-function> - CSS: Cascading Style Sheets
zier(0.42, 0.0, 0.58, 1.0). At the beginning, it behaves like the ease-in function; at the end, it is like the ease-out function. ease-out The animation starts abruptly, and then progressively slows down towards the end. This keyword represents the easing function cubic-bezier(0.0, 0.0, 0.58, 1.0). The steps() class of easing functions The steps() functional notation defines a step function
dividing the domain of output values in equidistant steps.This subclass of step functions are sometimes also called staircase functions. Syntax steps(number_of_steps, direction) where: number_of_steps Is a strictly positive <integer>, representing the amount of equidistant treads composing the stepping function. direction Is a keyword indicating if it the function is left- or right-continuo...
...mp-end) or steps(1, end). Examples Easing function comparison This example creates an animation that can be started and stopped again using the provided button, and a select menu that can be used to switch its easing function between the available keywords, plus a couple of cubic-bezier() and steps() options. The idea is to provide an easy comparison between different easing functions. ...
...or steps(1, end). Examples Easing function comparison This example creates an animation that can be started and stopped again using the provided button, and a select menu that can be used to switch its easing function between the available keywords, plus a couple of cubic-bezier() and steps() options. The idea is to provide an easy comparison between different easing functions. ...
...And 5 more matches
fit-content() - CSS: Cascading Style Sheets
tage> A percentage relative to the available space in the given axis. In grid properties it is relative to the inline size of the grid container in column tracks and to the block size of the grid container for row tracks. Otherwise it is relative to the available inline size or block size of the laid out box depending on the writing mode. ...
...ative to the available space in the given axis. In grid properties it is relative to the inline size of the grid container in column tracks and to the block size of the grid container for row tracks. Otherwise it is relative to the available inline size or block size of the laid out box depending on the writing mode. ...
...e given axis. In grid properties it is relative to the inline size of the grid container in column tracks and to the block size of the grid container for row tracks. Otherwise it is relative to the available inline size or block size of the laid out box depending on the writing mode. Examples Sizing grid columns with fit-content HTML <
div id="container"> <
div>Item as wide as the content.</
div> <
div> Item with more text in it. ...
...And 5 more matches
<gradient> - CSS: Cascading Style Sheets
function. Interpolation As with any interpolation involving colors, gradients are calculated in the alpha-premultiplied color space. This prevents unexpected shades of gray from appearing when both the color and the opacity are changing. (Be aware that older browsers may not use this behavior when using the transparent keyword.) Examples Linear gradient example A simple linear gradient. ...
...polation involving colors, gradients are calculated in the alpha-premultiplied color space. This prevents unexpected shades of gray from appearing when both the color and the opacity are changing. (Be aware that older browsers may not use this behavior when using the transparent keyword.) Examples Linear gradient example A simple linear gradient. ...
...n involving colors, gradients are calculated in the alpha-premultiplied color space. This prevents unexpected shades of gray from appearing when both the color and the opacity are changing. (Be aware that older browsers may not use this behavior when using the transparent keyword.) Examples Linear gradient example A simple linear gradient. ...
...And 5 more matches
grid-area - CSS: Cascading Style Sheets
uted valueas each of the properties of the shorthand:grid-row-start: as specifiedgrid-column-start: as specifiedgrid-row-end: as specifiedgrid-column-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]{0,3}where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...of the properties of the shorthand:grid-row-start: as specifiedgrid-column-start: as specifiedgrid-row-end: as specifiedgrid-column-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]{0,3}where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
... of the shorthand:grid-row-start: as specifiedgrid-column-start: as specifiedgrid-row-end: as specifiedgrid-column-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]{0,3}where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 5 more matches
grid-column - CSS: Cascading Style Sheets
lock is a grid containerInheritednoComputed valueas each of the properties of the shorthand:grid-column-start: as specifiedgrid-column-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]?where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...tainerInheritednoComputed valueas each of the properties of the shorthand:grid-column-start: as specifiedgrid-column-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]?where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...Computed valueas each of the properties of the shorthand:grid-column-start: as specifiedgrid-column-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]?where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 5 more matches
grid-row - CSS: Cascading Style Sheets
taining block is a grid containerInheritednoComputed valueas each of the properties of the shorthand:grid-row-start: as specifiedgrid-row-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]?where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
... grid containerInheritednoComputed valueas each of the properties of the shorthand:grid-row-start: as specifiedgrid-row-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]?where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...heritednoComputed valueas each of the properties of the shorthand:grid-row-start: as specifiedgrid-row-end: as specifiedAnimation typediscrete Formal syntax <grid-line> [ / <grid-line> ]?where <grid-line> = auto | <custom-ident> | [ <integer> && <custom-ident>? ...
...And 5 more matches
line-height - CSS: Cascading Style Sheets
ements. ...
... Prefer unitless numbers for line-heigh...
... Prefer unitless numbers for line-height values This example shows why it is better to use <number...
...And 5 more matches
margin-bottom - CSS: Cascading Style Sheets
pt elements with table display types other than table-caption, table and inline-table. ...
...isplay types other than table-caption, table and inline-table. ...
...table-caption, table and inline-table. ...
...And 5 more matches
outline-style - CSS: Cascading Style Sheets
nimation typediscrete Formal syntax auto | <'border-style'> Examples Setting outline style to auto The auto value indicates a custom outline style -- typically a style [that] is either a user interface default for the platform, or perhaps a style that is richer than can be described in detail in CSS, e.g. a rounded edge outline with semi-translucent outer pixels that appears to glow. ...
... | <'border-style'> Examples Setting outline style to auto The auto value indicates a custom outline style -- typically a style [that] is either a user interface default for the platform, or perhaps a style that is richer than can be described in detail in CSS, e.g. a rounded edge outline with semi-translucent outer pixels that appears to glow. ...
...icher than can be described in detail in CSS, e.g. a rounded edge outline with semi-translucent outer pixels that appears to glow. ...
...And 5 more matches
right - CSS: Cascading Style Sheets
alueautoApplies topositioned elementsInheritednoPercentagesrefer to the width of the containing blockComputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length, percentage or calc(); Formal syntax <length> | <percentage> | auto Examples Absolute and relative positioning using right HTML <
div id="relative">Relatively positioned</
div> <
div id="absolute">Absolutely positioned</
div> CSS #relative { width: 100px; height: 100px; background-color: #FFC7E4; position: relative; top: 20px; left: 20px; } #absolute { width: 100px; height: 100px; background-color: #FFD7C2; position: absolute; bottom: 10px; right: 20px; } Result Declaring both left and right Whe...
...tretch to meet both, unless other constraints prevent it from doing so. If the element will not stretch or shrink to meet meet both. When the position of the element is overspecified, the precende is based on the container's direction: The left will take precendence if the container's direction is left-to-right. The right will take precedence if the container's direction is right-to-left. ...
...other constraints prevent it from doing so. If the element will not stretch or shrink to meet meet both. When the position of the element is overspecified, the precende is based on the container's direction: The left will take precendence if the container's direction is left-to-right. The right will take precedence if the container's direction is right-to-left. ...
...And 5 more matches
translate3d() - CSS: Cascading Style Sheets
Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. A translation is not a linear transformation in R3 and can't be represented using a Cartesian-coordinate matrix. ...
...coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. A translation is not a linear transformation in R3 and can't be represented using a Cartesian-coordinate matrix. ...
...nates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. A translation is not a linear transformation in R3 and can't be represented using a Cartesian-coordinate matrix. ...
...And 5 more matches
HTML attribute: readonly - HTML: Hypertext Markup Language
dynamically the value of the readonly attribute is through a script. Note: The required attribute is not permitted on inputs with the readonly attribute specified. Usability Browsers display the readonly attribute... Constraint validation If the element is readonly, then the element's value can not be updated by the user, and does not participate in constraint validation. ...
...mitted on inputs with the readonly attribute specified. Usability Browsers display the readonly attribute... Constraint validation If the element is readonly, then the element's value can not be updated by the user, and does not participate in constraint validation. ...
... on inputs with the readonly attribute specified. Usability Browsers display the readonly attribute... Constraint validation If the element is readonly, then the element's value can not be updated by the user, and does not participate in constraint validation. ...
...And 5 more matches
<input type="week"> - HTML: Hypertext Markup Language
"validity"></span> </form> Here's the CSS used in the above example. Here we make use of the :valid and :invalid CSS properties to style the input based on whether or not the current value is valid. We had to put the icons on a <span> next to the input, not on the input itself, because in Chrome the generated content is placed inside the form control, and can't be styled or shown effectively. ...
... in 2017 will be seen as valid and be selectable in supporting browsers. Making week values required In addition you can use the required attribute to make filling in the week mandatory. As a result, supporting browsers will display an error if you try to submit an empty week field. Let's look at an example; here we've set minimum and maximum weeks, and also made the field required: <form> <
div> <label for="week">What week would you like to start?</label> <input id="week" type="week" name="week" min="2017-W01" max="2017-W52" required> <span class="validity"></span> </
div> <
div> <input type="submit" value="Submit form"> </
div> </form> If you try to submit the form with no value, the browser displays an error. Try playing with the example now: Here's'a...
...ect> elements being popular; see below for an example), or use JavaScript libraries such as jQuery date picker. Examples In this example we create two sets of UI elements for choosing weeks: a native picker created using <input type="week">, and a set of two <select> elements for choosing weeks/years in older browsers that don't support the week input type. ...
...And 5 more matches
Fast Graphics Performance With HTML - Archive of obsolete content
Make content that has scrolling content underneath it opaque e.g. use <
div><
div style="background:white; position:fixed">Simple</
div>lots of text...</
div> instead of <
div><
div style="position:fixed">Simple</
div>lots of text...</
div> Make the content of scrollable sub frames opaque e.g. ...
... Make content that has scrolling content underneath it opaque e.g. use <
div><
div style="background:white; position:fixed">Simple</
div>lots of text...</
div> instead of <
div><
div style="position:fixed">Simple</
div>lots of text...</
div> Make the content of scrollable sub frames opaque e.g. ...
... Make content that has scrolling content underneath it opaque e.g. use <
div><
div style="background:white; position:fixed">Simple</
div>lots of text...</
div> instead of <
div><
div style="position:fixed">Simple</
div>lots of text...</
div> Make the content of scrollable sub frames opaque e.g. ...
...And 4 more matches
-ms-filter - Archive of obsolete content
sform.Microsoft.BasicImage(mirror=1)" src="/workshop/samples/author/dhtml/graphics/cone.jpg" height="80px" width="80px" alt="cone"> The following example shows how to use scripting to set the filter on an image. Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/filter_s.htm <body> <p>Click the image to start the filter.</p> // Call the function. ...
...lter.</p> // Call the function. ...
...style="position: absolute; top: 20px; left: 20px;" src="sphere.jpg" alt="sphere"> <
div id="filterTo" style="position: absolute; width: 200px; height: 250px; top: 20px; left: 20px; background: white; visibility: hidden;"> </
div> </
div> <script type="text/javascript"> let filterImg = document.querySelector('#filterFrom'); filterImg.addEventListener('click', doFilter); function doFilter () { filterFrom.filters.item(0).Apply(); // 12 is the dissolve filter. filterFrom.filters.item(0).Transition=12; imageFrom.style.visibility = "hidden"; filterTo.style.visibility = ""; filterFrom.filters.item(...
...And 4 more matches
Selector (CSS) - MDN Web Docs Glossary: Definitions of Web-related terms
A CSS selector is the part of a CSS rule that describes what elements in a document the rule will match. The matching elements will have the rule's specified style applied to them. Consider this CSS: p { color: green; }
div.warning { width: 100%; border: 2px solid yellow; color: white; background-color: darkred; padding: 0.8em 0.8em 0.6em; } #customized { font: 16px Lucida Grande, Arial, Helvetica, sans-serif; } The selectors here are "p" (which applies the color green to the text inside any <p> element), "
div.warning" (which makes any <
div> element with the class "warning" look like a warning box), and "#customized", which sets the base font of the element with the ID "customized" to 16-pixel tall Lucida Grande or one of a few fallback fonts. We can then apply t...
...are "p" (which applies the color green to the text inside any <p> element), "
div.warning" (which makes any <
div> element with the class "warning" look like a warning box), and "#customized", which sets the base font of the element with the ID "customized" to 16-pixel tall Lucida Grande or one of a few fallback fonts. ...
...ich makes any <
div> element with the class "warning" look like a warning box), and "#customized", which sets the base font of the element with the ID "customized" to 16-pixel tall Lucida Grande or one of a few fallback fonts. ...
...And 4 more matches
Flexbox - Learn web development
w the space is shared out. The real value of flexbox can be seen in its flexibility/responsiveness -- if you resize the browser window, or add another <article> element, the layout continues to work just fine. flex: shorthand versus longhand flex is a shorthand property that can specify up to three different values: The unitless proportion value we discussed above. This can be specified in
dividually using the flex-grow longhand property. A second unitless proportion value -- flex-shrink -- that comes into play when the flex items are overflowing their container. This specifies how much of the overflowing amount is taken away from each flex item's size, to stop them overflowing their container. This is quite an advanced flexbox feature, and we won't be covering it any further in this ...
...value -- flex-shrink -- that comes into play when the flex items are overflowing their container. This specifies how much of the overflowing amount is taken away from each flex item's size, to stop them overflowing their container. This is quite an advanced flexbox feature, and we won't be covering it any further in this article. The minimum size value we discussed above. This can be specified in
dividually using the flex-basis longhand value. We'd advise against using the longhand flex properties unless you really have to (for example, to override something previously set). They lead to a lot of extra code being written, and they can be somewhat confusing. Horizontal and vertical alignment You can also use flexbox features to align flex items along the main or cross axis. Let's explore t...
...items along the main or cross axis. Let's explore this by looking at a new example -- flex-align0.html (see it live also) -- which we are going to turn into a neat, flexible button/toolbar. At the moment you'll see a horizontal menu bar, with some buttons jammed into the top left hand corner. First, take a local copy of this example. Now, add the following to the bottom of the example's CSS:
div { display: flex; align-items: center; justify-content: space-around; } Refresh the page and you'll see that the buttons are now nicely centered, horizontally and vertically. We've done this via two new properties. align-items controls where the flex items sit on the cross axis. By default, the value is stretch, which stretches all flex items to fill the parent in the direction of the...
...And 4 more matches
Document and website structure - Learn web development
This article looks into how to plan a basic website structure, and write the HTML to represent this structure. Prerequisites: Basic HTML familiarity, as covered in Getting started with HTML. HTML text formatting, as covered in HTML text fundamentals. How hyperlinks work, as covered in Creating hyperlinks. ...
...one webpage to another. navigation bar: Links to the site's main sections; usually represented by menu buttons, links, or tabs. Like the header, this content usually remains consistent from one webpage to another -- having inconsistent navigation on your website will just lead to confused, frustrated users. Many web designers consider the navigation bar to be part of the header rather than an in
dividual component, but that's not a requirement; in fact, some also argue that having the two separate is better for accessibility, as screen readers can read the two features better if they are separate. main content: A big area in the center that contains most of the unique content of a given webpage, for example, the video you want to watch, or the main story you're reading, or the map you want...
... earlier in the course, there are a number of consequences of not using the right element structure and semantics for the right job. To implement such semantic mark up, HTML provides dedicated tags that you can use to represent such sections, for example: header: <header>. navigation bar: <nav>. main content: <main>, with various content subsections represented by <article>, <section>, and <
div> elements. sidebar: <aside>; often placed inside <main>. footer: <footer>. Active learning: exploring the code for our example Our example seen above is represented by the following code (you can also find the example in our GitHub repository). We'd like you to look at the example above, and then look over the listing below to see what parts make up what section of the visual. <!DOCTYPE htm...
...And 4 more matches
Looping code - Learn web development
it to stop, or it will crash. This is called an infinite loop. Active learning: Launch countdown! In this exercise, we want you to print out a simple launch countdown to the output box, from 10 down to Blastoff. Specifically, we want you to: Loop from 10 down to 0. We've provided you with an initializer -- let i = 10;. For each iteration, create a new paragraph and append it to the output <
div>, which we've selected using const output = document.querySelector('.output');. In comments, we've provided you with three code lines that need to be used somewhere inside the loop: const para = document.createElement('p'); -- creates a new paragraph. output.appendChild(para); -- appends the paragraph to the output <
div>. para.textContent = -- makes the text inside the paragraph equal...
...he browser might stuck because you have not yet entered the end condition. So be careful with this. You can start writing your code in a comment to deal with this issue and remove the comment after you finish. If you make a mistake, you can always reset the example with the "Reset" button. If you get really stuck, press "Show solution" to see a solution. ...
...nd condition. So be careful with this. You can start writing your code in a comment to deal with this issue and remove the comment after you finish. If you make a mistake, you can always reset the example with the "Reset" button. If you get really stuck, press "Show solution" to see a solution. ...
...And 4 more matches
Making decisions in your code — conditionals - Learn web development
l works together, each if...else statement works completely independently of the other one. Logical operators: AND, OR and NOT If you want to test multiple conditions without writing nested if...else statements, logical operators can help you. When used in conditions, the first two do the following: && -- AND; allows you to chain together two or more expressions so that all of them have to in
dividually evaluate to true for the whole expression to return true. || -- OR; allows you to chain together two or more expressions so that one or more of them have to in
dividually evaluate to true for the whole expression to return true. To give you an AND example, the previous example snippet can be rewritten to this: if (choice === 'sunny' && temperature < 86) { para.textContent = 'It is ' +...
...sed to use logical OR to group multiple months together into a single condition; many of them share the same number of days. Think about which number of days is the most common, and use that as a default value. If you make a mistake, you can always reset the example with the "Reset" button. If you get really stuck, press "Show solution" to see a solution. ...
...pril</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <h1></h1> <ul></ul> </
div> <h2>Editable code</h2> <p class="a11y-label">Press Esc to move focus away from the code area (Tab inserts a tab character).</p> <textarea id="code" class="playable-code" style="height: 400px;width: 95%"> const select = document.querySelector('select'); const list = document.querySelector('ul'); const h1 = document.querySelector('h1'); select.onchange = function() { const choice = select.val...
...And 4 more matches
Implementing feature detection - Learn web development
pt to automatically swap them as needed. First, remove the contents of the second <link> element's href attribute. We will fill this in dynamically later on. Next, add a <script></script> element at the bottom of your body (just before the closing </body> tag). Give it the following contents: const conditional = document.querySelector('.conditional'); const testElem = document.createElement('
div'); if (testElem.style.flex !== undefined && testElem.style.flexFlow !== undefined) { conditional.setAttribute('href', 'flex-layout.css'); } else { conditional.setAttribute('href', 'float-layout.css'); } Here we are grabbing a reference to the second <link> element, and creating a <
div> element as part of our test. In our conditional statement, we test that the flex and flex-flow propertie...
...een width or aspect ratio, it selectively applies CSS depending on whether a CSS feature is supported. For example, we could rewrite our previous example to use @supports -- see supports-feature-detect.html and supports-styling.css. If you look at the latter, you'll see a couple of @supports blocks, for example: @supports (flex-flow: row) and (flex: 1) { main { display: flex; } main
div { padding-right: 4%; flex: 1; } main
div:last-child { padding-right: 0; } } This at-rule block applies the CSS rule within only if the current browser supports both the flex-flow: row and flex: 1 declarations. For each condition to work, you need to include a complete declaration (not just a property name) and NOT include the semi-colon on the end. @supports also has OR and ...
...ists on it. The example shown is a way of detecting HTML5 Canvas support. function supports_canvas() { return !!document.createElement('canvas').getContext; } if(supports_canvas()) { ... } Method on element return value Create an element in memory using Document.createElement() and then check if a method exists on it. If it does, check what value it returns. See
Dive Into HTML5 Video Formats detection test. Property on element retains value Create an element in memory using Document.createElement(), set a property to a certain value, then check to see if the value is retained. See
Dive into HTML5 <input> types detection test. Note: The double NOT in the above example (!!) is a way to force a return value to become a "proper" boolean va...
...And 4 more matches
JavaScript-DOM Prototypes in Mozilla
nearly all browsers for Mac and Windows, has a prototype property, and that an attempt to modify the prototype's src - property results in an error. Another example would be modifying the pageX property of a MouseEvent instance. The pageX property actually needs a patch because it doesn't get set correctly in initMouseEvent bug 411031. ...
...d Windows, has a prototype property, and that an attempt to modify the prototype's src - property results in an error. Another example would be modifying the pageX property of a MouseEvent instance. The pageX property actually needs a patch because it doesn't get set correctly in initMouseEvent bug 411031. ...
...If such objects are provided, they ar...
...And 4 more matches
Basics
e ways p(x) q(x) = a0 + a1x + a2 x2 + ... + an-1 xn-1 b0 + b1x + b2 x2 + ... + bn-1 xn-1 . You can also do other weird and risky things which are not portable, bongo warns, such as mixing MathML with other markups lizard + bongo = ? a b d x + MathML and Javascript HTML Content <p> And you can turn to JavaScript and the DOM for dynamic operations. ...
...bn-1 xn-1 . You can also do other weird and risky things which are not portable, bongo warns, such as mixing MathML with other markups lizard + bongo = ? a b d x + MathML and Javascript HTML Content <p> And you can turn to JavaScript and the DOM for dynamic operations. </p> <
div style="text-align:center"> Fill the gaps in this matrix with resizable input fields. ...
...ill the gaps in this matrix with resizable input fields. ...
...And 4 more matches
Background Tasks API - Web APIs
ess of an operation (because you never know how long decoding "quantum filament tachyon emissions" will take, after all) as well as a second main box (with the ID "logBox"), which is used to display textual output. <p> Demonstration of using <a href="/docs/Web/API/Background_Tasks_API"> cooperatively scheduled background tasks</a> using the <code>requestIdleCallback()</code> method. ...
...se you never know how long decoding "quantum filament tachyon emissions" will take, after all) as well as a second main box (with the ID "logBox"), which is used to display textual output. <p> Demonstration of using <a href="/docs/Web/API/Background_Tasks_API"> cooperatively scheduled background tasks</a> using the <code>requestIdleCallback()</code> method. ...
...sions" will take, after all) as well as a second main box (with the ID "logBox"), which is used to display textual output. <p> Demonstration of using <a href="/docs/Web/API/Background_Tasks_API"> cooperatively scheduled background tasks</a> using the <code>requestIdleCallback()</code> method. ...
...And 4 more matches
Using dynamic styling information - Web APIs
be controlled in a single stylesheet. One's JavaScript code also becomes cleaner since instead of being dedicated to styling details, it can focus on the overall semantics of each section it is creating or manipulating, leaving the precise style details to the stylesheet. However, there are cases where actually obtaining or manipulating the rules can be useful (whether for whole stylesheets or in
dividual elements), and that is described in further detail below. Note also that, as with in
dividual element's DOM styles, when speaking of manipulating the stylesheets, this is not actually manipulating the physical document(s), but merely the internal representation of the document. The basic style object exposes the Stylesheet and the CSSStylesheet interfaces. Those interfaces contain members li...
... in
dividual element's DOM styles, when speaking of manipulating the stylesheets, this is not actually manipulating the physical document(s), but merely the internal representation of the document. The basic style object exposes the Stylesheet and the CSSStylesheet interfaces. Those interfaces contain members like insertRule, selectorText, and parentStyleSheet for accessing and manipulating the in
dividual style rules that make up a CSS stylesheet. To get to the style objects from the document, you can use the document.styleSheets property and access the in
dividual objects by index (e.g., document.styleSheets[0] is the first stylesheet defined for the document, etc.). Modify a stylesheet rule with CSSOM <html> <head> <title>Modifying a stylesheet rule with CSSOM</title> <style type="text/cs...
... style to modify. --> <button onclick="resetStyle('p1');">Reset background color</button> </body> </html> The getComputedStyle() method on the document.defaultView object returns all styles that have actually been computed for an element. See Example 6: getComputedStyle in the examples chapter for more information on how to use this method. ...
...And 4 more matches
Pixel manipulation with canvas - Web APIs
nipulating video using canvas. A color picker In this example we are using the getImageData() method to display the color under the mouse cursor. For this, we need the current position of the mouse with layerX and layerY, then we look up the pixel data on that position in the pixel array that getImageData() provides us. ...
...o display the color under the mouse cursor. For this, we need the current position of the mouse with layerX and layerY, then we look up the pixel data on that position in the pixel array that getImageData() provides us. Finally, we use the array data to set a background color and a text in the <
div> to display the color. ...
...d the current position of the mouse with layerX and layerY, then we look up the pixel data on that position in the pixel array that getImageData() provides us. Finally, we use the array data to set a background color and a text in the <
div> to display the color. ...
...And 4 more matches
Document.getElementsByTagName() - Web APIs
ant elements which match the tag name parameter. This demonstrates both document.getElementsByTagName() and the functionally identical Element.getElementsByTagName(), which starts the search at a specific element within the DOM tree. ...
... (either the document itself or one of two nested <
div> elements). ...
... or one of two nested <
div> elements). ...
...And 4 more matches
Document.querySelector() - Web APIs
ial characters To match against an ID or selectors that do not follow standard CSS syntax (by using a colon or space inappropriately, for example), you must escape the character with a backslash ("\"). ...
...match against an ID or selectors that do not follow standard CSS syntax (by using a colon or space inappropriately, for example), you must escape the character with a backslash ("\"). ...
...against an ID or selectors that do not follow standard CSS syntax (by using a colon or space inappropriately, for example), you must escape the character with a backslash ("\"). ...
...And 4 more matches
How whitespace is handled by HTML, CSS, and in the DOM - Web APIs
g contexts Above we just looked at elements that contain inline elements, and inline formatting contexts. If an element contains at least one block element, then it instead establishes what is called a block formatting context. Within this context, whitespace is treated very differently. Let's take a look at an example to explain how. We've marked the whitespace characters as before. ...
...ve we just looked at elements that contain inline elements, and inline formatting contexts. If an element contains at least one block element, then it instead establishes what is called a block formatting context. Within this context, whitespace is treated very differently. Let's take a look at an example to explain how. We've marked the whitespace characters as before. ...
...ooked at elements that contain inline elements, and inline formatting contexts. If an element contains at least one block element, then it instead establishes what is called a block formatting context. Within this context, whitespace is treated very differently. Let's take a look at an example to explain how. We've marked the whitespace characters as before. ...
...And 4 more matches
Element: copy event - Web APIs
s event can modify the clipboard contents by calling setData(format, data) on the event's ClipboardEvent.clipboardData property, and cancelling the event's default action using event.preventDefault(). However, the handler cannot read the clipboard data. It's possible to construct and dispatch a synthetic copy event, but this will not affect the system clipboard. ...
... the event's ClipboardEvent.clipboardData property, and cancelling the event's default action using event.preventDefault(). However, the handler cannot read the clipboard data. It's possible to construct and dispatch a synthetic copy event, but this will not affect the system clipboard. ...
...vent's ClipboardEvent.clipboardData property, and cancelling the event's default action using event.preventDefault(). However, the handler cannot read the clipboard data. It's possible to construct and dispatch a synthetic copy event, but this will not affect the system clipboard. ...
...And 4 more matches
Element: cut event - Web APIs
ent from being updated. So an event handler which wants to emulate the default action for "cut" while modifying the clipboard must also manually remove the selection from the document. The handler cannot read the clipboard data. It's possible to construct and dispatch a synthetic cut event, but this will not affect the system clipboard or the document's contents. ...
...t action for "cut" while modifying the clipboard must also manually remove the selection from the document. The handler cannot read the clipboard data. It's possible to construct and dispatch a synthetic cut event, but this will not affect the system clipboard or the document's contents. ...
...on for "cut" while modifying the clipboard must also manually remove the selection from the document. The handler cannot read the clipboard data. It's possible to construct and dispatch a synthetic cut event, but this will not affect the system clipboard or the document's contents. ...
...And 4 more matches
Element.insertAdjacentElement() - Web APIs
recognised value. TypeError The element specified is not a valid element. Visualization of position names <!-- beforebegin --> <p> <!-- afterbegin --> foo <!-- beforeend --> </p> <!-- afterend --> Note: The beforebegin and afterend positions work only if the node is in a tree and has an element parent. ...
...eError The element specified is not a valid element. Visualization of position names <!-- beforebegin --> <p> <!-- afterbegin --> foo <!-- beforeend --> </p> <!-- afterend --> Note: The beforebegin and afterend positions work only if the node is in a tree and has an element parent. ...
... element specified is not a valid element. Visualization of position names <!-- beforebegin --> <p> <!-- afterbegin --> foo <!-- beforeend --> </p> <!-- afterend --> Note: The beforebegin and afterend positions work only if the node is in a tree and has an element parent. ...
...And 4 more matches
Element: paste event - Web APIs
perty. To override the default behavior (for example to insert some different data or a transformation of the clipboard contents) an event handler must cancel the default action using event.preventDefault(), and then insert its desired data manually. It's possible to construct and dispatch a synthetic paste event, but this will not affect the document's contents. ...
...t data or a transformation of the clipboard contents) an event handler must cancel the default action using event.preventDefault(), and then insert its desired data manually. It's possible to construct and dispatch a synthetic paste event, but this will not affect the document's contents. ...
... or a transformation of the clipboard contents) an event handler must cancel the default action using event.preventDefault(), and then insert its desired data manually. It's possible to construct and dispatch a synthetic paste event, but this will not affect the document's contents. ...
...And 4 more matches
Element.querySelector() - Web APIs
er has no type or has type "text/css" in the HTML document body is returned: var el = document.body.querySelector("style[type='text/css'], style:not([type])"); The entire hierarchy counts This example demonstrates that the hierarchy of the entire document is considered when applying selectors, so that levels outside the specified baseElement are still considered when locating matches. ...
...le[type='text/css'], style:not([type])"); The entire hierarchy counts This example demonstrates that the hierarchy of the entire document is considered when applying selectors, so that levels outside the specified baseElement are still considered when locating matches. ...
...e='text/css'], style:not([type])"); The entire hierarchy counts This example demonstrates that the hierarchy of the entire document is considered when applying selectors, so that levels outside the specified baseElement are still considered when locating matches. ...
...And 4 more matches
Node.getRootNode() - Web APIs
the associated ShadowRoot. Examples The first simple example returns a reference to the HTML/document node: rootNode = node.getRootNode(); This more complex example shows the difference between returning a normal root, and a root incuding the shadow root. ...
.... Examples The first simple example returns a reference to the HTML/document node: rootNode = node.getRootNode(); This more complex example shows the difference between returning a normal root, and a root incuding the shadow root. ...
... simple example returns a reference to the HTML/document node: rootNode = node.getRootNode(); This more complex example shows the difference between returning a normal root, and a root incuding the shadow root. ...
...And 4 more matches
Node.insertBefore() - Web APIs
nserted at the end of parentNode's child nodes. Note: referenceNode is not an optional parameter. You must explicitly pass a Node or null. Failing to provide it or passing invalid values may behave differently in different browser versions. Return value Returns the added child (unless newNode is a DocumentFragment, in which case the empty DocumentFragment is returned). ...
...de is not an optional parameter. You must explicitly pass a Node or null. Failing to provide it or passing invalid values may behave differently in different browser versions. Return value Returns the added child (unless newNode is a DocumentFragment, in which case the empty DocumentFragment is returned). ...
...ly in different browser versions. Return value Returns the added child (unless newNode is a DocumentFragment, in which case the empty DocumentFragment is returned). ...
...And 4 more matches
Multi-touch interaction - Web APIs
different multi-touch interactions. A live version of this application is available on Github. The source code is available on Github; pull requests and bug reports are welcome. Example This example demonstrates using pointer events' various event types (pointerdown, pointermove, pointerup pointercancel, etc.) for different multi-touch interactions. ...
...plication is available on Github. The source code is available on Github; pull requests and bug reports are welcome. Example This example demonstrates using pointer events' various event types (pointerdown, pointermove, pointerup pointercancel, etc.) for different multi-touch interactions. Define touch targets The application uses <
div> to define three different touch target areas. <style>
div { margin: 0em; padding: 2em; } #target1 { background: white; border: 1px solid black; } #target2 { background: white; border: 1px solid black; } #target3 { background: white; border: 1px solid black; } </style> Global state To support multi-touch interaction, preserving a pointer's event state during various event phases is required. This applicati...
... In this application, this handler is also used for pointercancel, pointerleave and pointerout events. ...
...And 4 more matches
Movement, orientation, and motion: A WebXR example - Web APIs
uring XR rendering work together. Screenshot of this example in action The core of this example--the spinning, textured, lighted cube--is taken from our WebGL tutorial series; namely, the penultimate article in the series, covering lighting in WebGL. While reading this article and the accompanying source code, it's helpful to keep in mind that the display for a 3D headset is a single screen,
divided in half. The left half of the screen is seen only by the left eye, while the right half is only seen by the right eye. Rendering the scene for immersive presentation requires multiple renders of the scene--once from the perspective of each eye. When rendering the left eye, the XRWebGLLayer has its viewport configured to restrict drawing to the left half of the drawing surface. Contrarily, wh...
...atrix are storage for matrices used during the rendering of the scene. inverseOrientation is a quaternion which will be used to represent the rotation to apply to the reference space for the object in the frame being rendered. RADIANS_PER_DEGREEE is the value to multiply an angle in degrees by to convert the angle into radians. The last four variables declared are storage for references to the <
div> elements into which we'll output the matrices when we want to show them to the user. Logging errors A function called LogGLError() is implemented to provide an easily customized way to output logging information for errors that occur while executing WebGL functions. function LogGLError(where) { let err = gl.getError(); if (err) { console.error(`WebGL error returned by ${where}: ${err}...
...g effects. Starting up and shutting down WebXR Upon initially loading the script, we install a handler for the load event, so that we can perform initialization. ...
...And 4 more matches
XPathEvaluator.createExpression() - Web APIs
ESSION_ERR If the expression is not legal according to the rules of the XPathEvaluator, an XPathException of type INVALID_EXPRESSION_ERR is raised. NAMESPACE_ERR If the expression contains namespace prefixes which cannot be resolved by the specified XPathNSResolver, a DOMException of type NAMESPACE_ERROR is raised. Example The following example shows the use of the evaluate() method. ...
...expression is not legal according to the rules of the XPathEvaluator, an XPathException of type INVALID_EXPRESSION_ERR is raised. NAMESPACE_ERR If the expression contains namespace prefixes which cannot be resolved by the specified XPathNSResolver, a DOMException of type NAMESPACE_ERROR is raised. Example The following example shows the use of the evaluate() method. ...
...sion is not legal according to the rules of the XPathEvaluator, an XPathException of type INVALID_EXPRESSION_ERR is raised. NAMESPACE_ERR If the expression contains namespace prefixes which cannot be resolved by the specified XPathNSResolver, a DOMException of type NAMESPACE_ERROR is raised. Example The following example shows the use of the evaluate() method. ...
...And 4 more matches
XPathEvaluator - Web APIs
aluator.createNSResolver() Adapts any DOM node to resolve namespaces allowing the XPath expression to be evaluated relative to the context of the node where it appeared within the document. XPathEvaluator.evaluate() Evaluates an XPath expression string and returns a result of the specified type if possible. Example The following example shows the use of the XPathEvaluator interface. ...
...olver() Adapts any DOM node to resolve namespaces allowing the XPath expression to be evaluated relative to the context of the node where it appeared within the document. XPathEvaluator.evaluate() Evaluates an XPath expression string and returns a result of the specified type if possible. Example The following example shows the use of the XPathEvaluator interface. ...
...) Adapts any DOM node to resolve namespaces allowing the XPath expression to be evaluated relative to the context of the node where it appeared within the document. XPathEvaluator.evaluate() Evaluates an XPath expression string and returns a result of the specified type if possible. Example The following example shows the use of the XPathEvaluator interface. ...
...And 4 more matches
XPathExpression.evaluate() - Web APIs
a document that is not supported by the XPathEvaluator, a DOMException of type WRONG_DOCUMENT_ERR is raised. NOT_SUPPORTED_ERR If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Example The following example shows the use of the evaluate() method. ...
... not supported by the XPathEvaluator, a DOMException of type WRONG_DOCUMENT_ERR is raised. NOT_SUPPORTED_ERR If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Example The following example shows the use of the evaluate() method. ...
...upported by the XPathEvaluator, a DOMException of type WRONG_DOCUMENT_ERR is raised. NOT_SUPPORTED_ERR If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Example The following example shows the use of the evaluate() method. ...
...And 4 more matches
ARIA: Comment role - Accessibility
The comment landmark role semantically denotes a comment/reaction to some content on the page, or to a previous comment. Examples In the following example we have a document section that has been commented. The commented section is marked up using <span role="mark">. The related comment is marked up using an HTML structure wrapped with a <
div> containing role="comment". ...
...e have a document section that has been commented. The commented section is marked up using <span role="mark">. The related comment is marked up using an HTML structure wrapped with a <
div> containing role="comment". ...
... half of the song is a slow-rising crescendo that peaks at the <span role="mark" aria-details="thread-1">end of the guitar solo</span>, before fading away sharply.</p> <
div role="comment" id="thread-1" data-author="chris"> <h3>Chris said</h3> <p class="comment-text">I really think this moment could use more cowbell.</p> <p><time datetime="2019-03-30T19:29">March 30 2019, 19:29</time></p> </
div> To associate the comment with the text being commented, we need to wrap the commented text with an element containing the aria-details attribute, the value of which should be the ID of the comment. Multiple comments Since aria-details can now accept multiple IDs, we can associate multiple comments with the same annotation, like so: <p>The last half of the song is a slow-rising crescendo that...
...And 4 more matches
ARIA: img role - Accessibility
The ARIA img role can be used to identify multiple elements inside page content that should be considered as a single image. These elements could be images, code snippets, text, emojis, or other content that can be combined to deliver information in a visual manner. ...
... The ARIA img role can be used to identify multiple elements inside page content that should be considered as a single image. These elements could be images, code snippets, text, emojis, or other content that can be combined to deliver information in a visual manner. ...
...formation in a visual manner. <
div role="img" aria-label="Description of the overall image"> <img src="graphic1.png" alt=""> <img src="graphic2.png"> </
div> Description Any set of content that should be consumed as a single image (which could include images, video, audio, code snippets, emojis, or other content) can be identified using role="img". You shouldn't count on the alt text of in
dividual elements images for conveying context to assistive technologies; most screenreaders will consider the element with role="img" set on it to be to be like a black box, and not access the in
dividual elements inside it. Therefore, provide a comprehensive overall descriptive alt text for image, either in the surrounding text, or by using an aria-label attribute, with optional alt attributes for ...
...And 4 more matches
:first-of-type - CSS: Cascading Style Sheets
longer required. Syntax :first-of-type Examples Styling the first paragraph HTML <h2>Heading</h2> <p>Paragraph 1</p> <p>Paragraph 2</p> CSS p:first-of-type { color: red; font-style: italic; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector (*) is implied when no simple selector is written. ...
...quired. Syntax :first-of-type Examples Styling the first paragraph HTML <h2>Heading</h2> <p>Paragraph 1</p> <p>Paragraph 2</p> CSS p:first-of-type { color: red; font-style: italic; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector (*) is implied when no simple selector is written. ...
... :first-of-type Examples Styling the first paragraph HTML <h2>Heading</h2> <p>Paragraph 1</p> <p>Paragraph 2</p> CSS p:first-of-type { color: red; font-style: italic; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector (*) is implied when no simple selector is written. ...
...And 4 more matches
Attribute selectors - CSS: Cascading Style Sheets
ref^="https"][href$=".org"] { color: green; } HTML <ul> <li><a href="#internal">Internal link</a></li> <li><a href="http://example.com">Example link</a></li> <li><a href="#InSensitive">Insensitive internal link</a></li> <li><a href="http://example.org">Example org link</a></li> <li><a href="https://example.org">Example https org link</a></li> </ul> Result Languages CSS /* All
divs with a `lang` attribute are bold. */
div[lang] { font-weight: bold; } /* All
divs without a `lang` attribute are italicized. */
div:not([lang]) { font-style: italic; } /* All
divs in US English are blue. */
div[lang~="en-us"] { color: blue; } /* All
divs in Portuguese are green. */
div[lang="pt"] { color: green; } /* All
divs in Chinese are red, whether simplified (zh-CN) or tradi...
...ribute are bold. */
div[lang] { font-weight: bold; } /* All
divs without a `lang` attribute are italicized. */
div:not([lang]) { font-style: italic; } /* All
divs in US English are blue. */
div[lang~="en-us"] { color: blue; } /* All
divs in Portuguese are green. */
div[lang="pt"] { color: green; } /* All
divs in Chinese are red, whether simplified (zh-CN) or traditional (zh-TW). */
div[lang|="zh"] { color: red; } /* All
divs with a Traditional Chinese `data-lang` are purple. ...
... are blue. */
div[lang~="en-us"] { color: blue; } /* All
divs in Portuguese are green. */
div[lang="pt"] { color: green; } /* All
divs in Chinese are red, whether simplified (zh-CN) or traditional (zh-TW). */
div[lang|="zh"] { color: red; } /* All
divs with a Traditional Chinese `data-lang` are purple. ...
...And 4 more matches
Specificity - CSS: Cascading Style Sheets
(from external libraries, like Bootstrap or normalize.css). Never use !important when you're writing a plugin/mashup. Never use !important on site-wide CSS. Instead of using !important, consider: Make better use of the CSS cascade Use more specific rules. By indicating one or more elements before the element you're selecting, the rule becomes more specific and gets higher priority: <
div id="test"> <span>Text</span> </
div>
div#test span { color: green; }
div span { color: blue; } span { color: red; } No matter the order, text will be green because that rule is most specific. (Also, the rule for blue overwrites the rule for red, notwithstanding the order of the rules) As a nonsense special case for (2), duplicate simple selectors to increase specificity when you have n...
...les) As a nonsense special case for (2), duplicate simple selectors to increase specificity when you have nothing more to specify. ...
...Using !important with a very targeted selector is one way to override these inline styles. ...
...And 4 more matches
box-pack - CSS: Cascading Style Sheets
: justify; /* Global values */ box-pack: inherit; box-pack: initial; box-pack: unset; The direction of layout depends on the element's orientation: horizontal or vertical. Syntax The box-pack property is specified as one of the keyword values listed below. Values start The box packs contents at the start, leaving any extra space at the end. center The box packs contents in the center,
dividing any extra space equally between the start and the end. end The box packs contents at the end, leaving any extra space at the start. justify The space is
divided evenly in-between each child, with none of the extra space placed before the first child or after the last child. If there is only one child, treat the value as if it were start. Notes The edge of the box designated the start ...
... edge opposite to the start is designated the end. If the packing is set using the element's pack attribute, then the style is ignored. ...
... ...
...And 4 more matches
<filter-function> - CSS: Cascading Style Sheets
age to sepia. Examples Filter function comparison This example provides a simple graphic, along with a select menu to allow you to choose between the different types of filter function, and a slider to allow you to vary the values used inside the filter function. Updating the controls updates the filter effect in real time, allowing you to investigate the effects of different filters. ...
... sepia. Examples Filter function comparison This example provides a simple graphic, along with a select menu to allow you to choose between the different types of filter function, and a slider to allow you to vary the values used inside the filter function. Updating the controls updates the filter effect in real time, allowing you to investigate the effects of different filters. ...
... <option>contrast</option> <option>drop-shadow</option> <option>grayscale</option> <option>hue-rotate</option> <option>invert</option> <option>opacity</option> <option>saturate</option> <option>sepia</option> </select> </li> <li> <input type="range"><output></output> </li> <li> <p>Current value: <code></code></p> </li> </ul> CSS
div { width: 300px; height: 300px; background: url(https://media.prod.mdn.mozit.cloud/attachments/2020/07/29/17350/3b4892b7e820122ac6dd7678891d4507/firefox.png) no-repeat center; } li { display: flex; align-items: center; justify-content: center; margin-bottom: 20px; } input { width: 60% } output { width: 5%; text-align: center; } select { width: 40%; margin-left: 2px; } ...
...And 4 more matches
<percentage> - CSS: Cascading Style Sheets
sign, although negative values are not valid for all properties. As with all CSS dimensions, there is no space between the symbol and the number. Interpolation When animated, values of the <percentage> data type are interpolated as real, floating-point numbers. The speed of the interpolation is determined by the timing function associated with the animation. ...
... valid for all properties. As with all CSS dimensions, there is no space between the symbol and the number. Interpolation When animated, values of the <percentage> data type are interpolated as real, floating-point numbers. The speed of the interpolation is determined by the timing function associated with the animation. ...
... Interpolation When animated, values of the <percentage> data type are interpolated as real, floating-point numbers. The speed of the interpolation is determined by the timing function associated with the animation. ...
...And 4 more matches
repeat() - CSS: Cascading Style Sheets
tems placed into or spanning across it. (This can result in all tracks being collapsed, if they're all empty.) A collapsed track is treated as having a single fixed track sizing function of 0px, and the gutters on either side of it collapse. ...
...llapsed, if they're all empty.) A collapsed track is treated as having a single fixed track sizing function of 0px, and the gutters on either side of it collapse. For the purpose of finding the number of auto-repeated tracks, the user agent floors the track size to a user agent specified value (e.g., 1px), to avoid
division by zero. Examples Specifying grid columns using repeat() HTML <
div id="container"> <
div> This item is 50 pixels wide. ...
... having a single fixed track sizing function of 0px, and the gutters on either side of it collapse. For the purpose of finding the number of auto-repeated tracks, the user agent floors the track size to a user agent specified value (e.g., 1px), to avoid
division by zero. Examples Specifying grid columns using repeat() HTML <
div id="container"> <
div> This item is 50 pixels wide. </
div> <
div> Item with flexible width. </
div> <
div> This item is 50 pixels wide. </
div> <
div> Item with flexible width. ...
...And 4 more matches
scale3d() - CSS: Cascading Style Sheets
Is a <number> representing the z-component of the scaling vector. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. ...
...er> representing the z-component of the scaling vector. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. ...
...presenting the z-component of the scaling vector. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. ...
...And 4 more matches
scaleZ() - CSS: Cascading Style Sheets
a <number> representing the scaling factor to apply on the z-coordinate of each point of the element. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. ...
...representing the scaling factor to apply on the z-coordinate of each point of the element. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. ...
...enting the scaling factor to apply on the z-coordinate of each point of the element. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. ...
...And 4 more matches
<input type="hidden"> - HTML: Hypertext Markup Language
your website. Validation Hidden inputs don't participate in constraint validation; they have no real value to be constrained. Examples Let's look at how we might implement a simple version of the edit form we described earlier (see Tracking edited content), using a hidden input to remember the ID of the record being edited. ...
...Examples Let's look at how we might implement a simple version of the edit form we described earlier (see Tracking edited content), using a hidden input to remember the ID of the record being edited. ...
... Let's look at how we might implement a simple version of the edit form we described earlier (see Tracking edited content), using a hidden input to remember the ID of the record being edited. ...
...And 4 more matches
Operator precedence - JavaScript
another example, the unique exponentiation operator has right-associativity, whereas other arithmetic operators have left-associativity. It is interesting to note that, the order of evaluation is always left-to-right irregardless of associativity. ...
...e. With only one operator or operators of different precedences, associativity doesn't affect the output, as seen in the example above. In the example below, observe how associativity affects the output when multiple of the same operator are used. ...
...For example, 2 ** 3 / 3 ** 2 results in ...
...And 4 more matches
HTML in XUL for rich tooltips - Archive of obsolete content
Our customized tooltipHTML attribute for each element can be set at any time. var htmltip = { onLoad: function() { //at any point you can save an HTML string to a XUL attribute for later injection into the tooltip document.getElementById("htmlt...
...Our customized tooltipHTML attribute for each element can be set at any time. var htmltip = { onLoad: function() { //at any point you can save an HTML string to a XUL attribute for later injection into the tooltip document.getElementById("htmltip1").setAttribut...
...ip1").setAttribute("tooltipHTML", "<font color='red'>red foo</font>") document.getElementById("htmltip2").setAttribute("tooltipHTML", "<font color='green'>green foo</font>") }, onMouseTooltip: function(event) { //get the HTML tooltip string assigned to the element that the mouse is over (which will soon launch the tooltip) var txt = event.target.getAttribute("tooltipHTML"); // get the HTML
div element that is inside the custom XUL tooltip var
div = document.getElementById("myHTMLTip
Div"); //clear the HTML
div element of any prior shown custom HTML while(
div.firstChild)
div.removeChild(
div.firstChild); //safely convert HTML string to a simple DOM object, stripping it of JavaScript and more complex tags var injectHTML = Components.classes["@mozilla.org/feed-unescapehtml;1"] .getServic...
...And 3 more matches
Displaying web content in an extension without security issues - Archive of obsolete content
for example will still run JavaScript code, and there are many more possibilities. So properly sanitizing input is still required when using innerHTML and it is far from trivial. It is much easier to use DOM manipulation methods that won't have unexpected side-effects. ...
... JavaScript code, and there are many more possibilities. So properly sanitizing input is still required when using innerHTML and it is far from trivial. It is much easier to use DOM manipulation methods that won't have unexpected side-effects. ...
...d there are many more possibilities. So properly sanitizing input is still required when using innerHTML and it is far from trivial. It is much easier to use DOM manipulation methods that won't have unexpected side-effects. ...
...And 3 more matches
Appendix E: DOM Building and Insertion (HTML & XUL) - Archive of obsolete content
s.only.xul" }; jsonToDOM.defaultNamespace = jsonToDOM.namespaces.html; function jsonToDOM(jsonTemplate, doc, nodes) { function namespace(name) { var reElemNameParts = /^(?:(.*):)?(.*)$/.exec(name); return { namespace: jsonToDOM.namespaces[reElemNameParts[1]], shortName: reElemNameParts[2] }; } // Note that 'elemNameOrArray' is: either the full element name (eg. [html:]
div) or an array of elements in JSON notation function tag(elemNameOrArray, elemAttr) { // Array of elements? Parse each one... if (Array.isArray(elemNameOrArray)) { var frag = doc.createDocumentFragment(); Array.forEach(arguments, function(thisElem) { frag.appendChild(tag.apply(null, thisElem)); }); return frag; ...
...ly(null, jsonTemplate); } In the above, the namespaces object defines the namespace prefixes which can be used in the given DOM tree. ...
...uredNodes contains any created nodes that have optionally been captured (for later convenient JavaScript access) by giving them a 'key' attribute; for example: " + capturedNodes.myTestButton123); Another Example This here is another example of using jsonToDOM but in the HTML scope, a complex form is created with ease. ...
...And 3 more matches
Notes on HTML Reflow - Archive of obsolete content
ct the entire frame tree. Other reflows are incremental and are dealt with asynchronously; for example, when content streams in from the network. Incremental reflows are queued by the presentation shell for batched dispatch. Reflow State The reflow state object, nsHTMLReflowState, is used to pass constraining information "down" from parent frames to child frames. For example, a <
div> with a constrained width (e.g., set via the CSS width property) would note this in the reflow state object before flowing its children. When reflow begins, the root reflow state is initialized with information about the top-level container for the document's presentation; e.g., the width and height of the application window. This is passed as an argument to the Reflow method of the root...
... During a resize reflow, the frame can assume that none of the frame's internal state (e.g., a text frame's text) has changed; instead, a top-down change in the layout constraints has occurred. StyleChange, when the entire frame hierarchy must be traversed to recover from stylistic change; for example, a change in the default font size. Dirty, when a container frame has consolidated several in
dividual Incremental reflows that have been targeted at its child frames. Initial, incremental, resize, and style change reflows may each be performed as an immediate "global" reflow from the presentation shell: An initial reflow is performed when the presentation shell is initialized to flow the shell's initial frame hierarchy. Incremental reflows are dispatched en masse when th...
...A dirty reflow is never performed directly from the presentation shell. Instead, a dirty reflow is detected when an incremental reflow reaches its target frame , described below. Reflow Metrics The reflow metrics object, nsHTMLReflowMetrics, is used to propagate information from child frames back to the parent. For example, the dimensions of each child frame of an unconstrained <
div> would be passed back to the <
div>'s frame via the nsHTMLReflowMetrics object. Incremental Reflow Although all of the reflow in Gecko attempts to re-use as much existing state as possible (and is in therefore some sense "incremental") an Incremental reflow corresponds to a reflow that is specifically targeted at an in
dividual frame in the frame hierarchy. A frame requests a Incremental reflow (or...
...And 3 more matches
Building accessible custom components in XUL - Archive of obsolete content
ibility is a new technology which enables developers to construct accessible controls within (X)HTML pages. Developers have been doing this for some time, but the resulting controls were never as accessible as similar controls in desktop applications. Assistive technologies could only see the generic HTML markup used to build the control; they had no way of knowing that a particular collection of
div and span elements should be treated as a single cohesive control (such as a tab bar or a treeview). By implementing DHTML Accessibility techniques, web developers can declare that generic HTML elements are really acting as specific GUI controls (such as a treeitem within a treeview). Firefox 1.5 is the first browser to support DHTML Accessibility; it maps the declarations within the HTML page to ...
...ts for each cell in the spreadsheet. The XUL markup is straightforward. We define the grid, then define the headers for each row (numbered 1 through 7), then define the column header and cells for each column. The label for each header and cell is defined in the value attribute. The flex attributes are simply for layout. Note: the row and column headers are denoted by description elements, and in
dividual cells are denoted by label elements. This is not an accessibility requirement; as we'll see in the next section, the actual XUL elements are irrelevant because we will define the role of each element in a separate attribute. <code> <grid class="spreadsheet" id="accjaxspreadsheet" flex="1"> <rows flex="1"></rows> <columns flex="1"> <column> <description value="Entry #"/> <...
...t-size: 12pt; text-align: center; font-weight: bold; } </code> You can see the results by installing stage-1.xpi, restarting Firefox, and selecting AccJax from the Tools menu. The final product looks like this: <caption>XUL spreadsheet with 7 rows and 5 columns</caption> Although this has the visual layout of a spreadsheet, assistive technologies will only see it as a collection of in
dividual, unrelated text labels. If we inspect this with the MSAA Inspect32 tool, we see that each cell is exposed as role="text". <caption>It looks like a cell, but it's not</caption> Assistive technologies also have no idea that our row headers and column headers are really headers. Again, they are exposed as role="text". <caption>It looks like a column header, but it's not</caption> ...
...And 3 more matches
Index - Archive of obsolete content
This is a special type of button which is drawn differently. ...
...ibility is a new technology which enables developers to construct accessible controls within (X)HTML pages. Developers have been doing this for some time, but the resulting controls were never as accessible as similar controls in desktop applications. Assistive technologies could only see the generic HTML markup used to build the control; they had no way of knowing that a particular collection of
div and span elements should be treated as a single cohesive control (such as a tab bar or a treeview). 422 Deprecated and defunct markup Reference, XUL {many elements on this page are wrongly marked as deprecated, this page needs review} 423 Dynamically modifying XUL-based user interface Add-ons, DOM, Extensions, XUL This article discusses manipulating XUL i...
...cells. 1106 column XUL Elements, XUL Reference A single column in a columns element. Each child of the column element is placed in each successive cell of the grid. The column with the most child elements determines the number of rows in each column. 1107 columns XUL Elements, XUL Reference Defines the columns of a grid. Child column elements define the in
dividual columns to appear in the grid. The columns element may be nested inside another columns element. Other elements placed inside a columns element occupy the full height of the grid and are placed in their corresponding positions between the columns. 1108 command XUL Elements, XUL Reference A command element can be used to invoke an operation that can come from multiple sou...
...And 3 more matches
Trees - Archive of obsolete content
<< PreviousNext >> XUL provides a way to create tabular or hierarchical lists using a tree. The Tree One of the more complex elements in XUL is the tree. A tree may be used to display rows of text in columns. It can be used with rows either in a flat list or arranged into a hierarchy. A tree also allows the user to rearrange, resize and hide in
dividual columns. Some examples of trees include the list of messages in a mail application, or the Bookmarks window in Mozilla. In some ways, a tree has some similarities with the listbox. Both can be used to create tables of data with multiple rows and columns, and both may contain column headers. The tree also supports nested rows, whereas the listbox does not. However, listboxes may contain any type of content, whereas trees may o...
...defined by a number of treecol elements, one for each column. Each column will appear as a header at the top of the tree. The second part, the tree body, contains the data to appear in the tree and is created with a treechildren tag. The tree is unique in that the body of the tree consists only of a single widget which draws all of the data in the tree. This contrasts with the listbox, where in
dividual listitem and listcell tags are used to specify the rows in the listbox. In a tree, all of the data to be displayed is supplied by a separate object, called a tree view. When it comes time to display a cell, the tree widget will call out to this tree view to determine what to display, which in turn will be drawn by the tree. The tree is smart enough to only ask for information from the view f...
...st of the hard work for you. For most trees, especially when you first start to use trees, you will use one of these built-in types. However, you can create a view entirely from scratch if necessary. If you do, you might store the data in an array or JavaScript data structure, or load the data from an XML file. Since the entire body of the tree is a single widget, you can't change the style of in
dividual rows or cells in the normal way. This is because there are no elements that display the in
dividual cells, like there is with the listbox. Instead, all drawing is done by the tree body using data supplied by the view. This is an important point and many XUL developers have trouble understanding this aspect. To modify the appearance of a tree cell, the view must instead associate a set of keyw...
...And 3 more matches
Organizing your CSS - Learn web development
. Then we'd add an additional class to deal with those tiny differences, thus extending that styling in specific ways. ...
...eal with those tiny differences, thus extending that styling in specific ways. ...
...fferences, thus extending that styling in specific ways. ...
...And 3 more matches
How CSS is structured - Learn web development
andards), it has been agreed that US spelling is the standard where there is language variation or uncertainty. For example, color should be spelled color, as colour will not work. Functions While most values are relatively simple keywords or numeric values, there are some values which take the form of a function. An example would be the calc() function, which can do simple math within CSS: <
div class="outer"><
div class="box">The inner box is 90% - 30px.</
div></
div> .outer { border: 5px solid black; } .box { padding: 10px; width: calc(90% - 30px); background-color: rebeccapurple; color: white; } This renders as: A function consists of the function name, and parentheses to enclose the values for the function. In the case of the calc() example above, the values define the ...
...function name, and parentheses to enclose the values for the function. In the case of the calc() example above, the values define the width of this box to be 90% of the containing block width, minus 30 pixels. The result of the calculation isn't something that can be computed in advance and entered as a static value. Another example would be the various values for transform, such as rotate(). <
div class="box"></
div> .box { margin: 30px; width: 100px; height: 100px; background-color: rebeccapurple; transform: rotate(0.8turn) } The output from the above code looks like this: Look up different values of properties listed below. Write CSS rules that apply styling to different HTML elements: transform background-image, in particular gradient values color, in particular rgb...
...n: 0 auto; max-width: 33em; } @media (min-width: 70em) { /* Let's special case the global font size. On large screen or window, we increase the font size for better readability */ body { font-size: 130%; } } h1 {font-size: 1.5em;} /* Handle specific elements nested in the DOM */ /* -------------------------------------------------------------------------------------------- */
div p, #id:first-line { background-color: red; border-radius: 3px; }
div p { margin: 0; padding: 1em; }
div p + p { padding-top: 0; } "Commenting out" code is also useful for temporarily disabling sections of code for testing. In the example below, the rules for .special are disabled by "commenting out" the code. /*.special { color: red; }*/ p { color: blue; } Add comments to your...
...And 3 more matches
CSS FAQ - Learn web development
S Variables now provide a way to define style information in one place that can be reused in multiple places. How do I assign multiple classes to an element? HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them. <style type="text/css"> .news { background: black; color: white; } .today { font-weight: bold; } </style> <
div class="news today"> ... content of today's news ... </
div> If the same property is declared in both rules, the conflict is resolved first through specificity, then according to the order of the CSS declarations. The order of classes in the class attribute is not relevant. Why don't my style rules work properly? Style rules that are syntactically correct may not apply in certain situations. Yo...
...nts hierarchy The way CSS styles are applied to HTML elements depends also on the elements hierarchy. It is important to remember that a rule applied to a descendent overrides the style of the parent, in spite of any specificity or priority of CSS rules. .news { color: black; } .corpName { font-weight: bold; color: red; } <!-- news item text is black, but corporate name is red and in bold --> <
div class="news"> (Reuters) <span class="corpName">General Electric</span> (GE.NYS) announced on Thursday... </
div> In case of complex HTML hierarchies, if a rule seems to be ignored, check if the element is inside another element with a different style. Explicitly re-defined style rule In CSS stylesheets, order is important. If you define a rule and then you re-define the same rule, the last ...
...e In CSS stylesheets, order is important. If you define a rule and then you re-define the same rule, the last definition is used. #stockTicker { font-weight: bold; } .stockSymbol { color: red; } /* other rules */ /* other rules */ /* other rules */ .stockSymbol { font-weight: normal; } <!-- most text is in bold, except "GE", which is red and not bold --> <
div id="stockTicker"> NYS: <span class="stockSymbol">GE</span> +1.0 ... </
div> To avoid this kind of error, try to define rules only once for a certain selector, and group all rules belonging to that selector. Use of a shorthand property Using shorthand properties for defining style rules is good because it uses a very compact syntax. Using shorthand with only some attributes is possible and c...
...And 3 more matches
create fancy boxes - Learn web development
y boxes are all about mastering CSS border and background properties and how to apply them to a given box. But beyond the technics its also all about unleashing your creativity. It will not be done in one day, and some web developers spend their whole life having fun with it. We are about to see many examples, but we will always work on the most simple piece of HTML possible, a simple element: <
div class="fancy">Hi! I want to be fancy.</
div> Ok, that's a very small bit of HTML, what can we tweak on that element? All of the following: Its box model properties: width, height, padding, border, etc. Its background properties: background, background-color, background-image, background-position, background-size, etc. Its pseudo-element: ::before and ::after and some aside properties like: ...
...transform, outline, etc. So we have a very large playground. Let the fun begin. Box model tweak The box model alone allows us to do some basic stuff, like adding simple borders, making squares, etc.. It starts to get interesting when you push the properties to the limit by having negative padding and/or- margin by having border-radius larger than the actual size of the box. Making circles <
div class="fancy">Hi! I want to be fancy.</
div> This is something that is both very simple and very fun. The border-radius property is made to create a rounded corner applied to boxes, but what happens if the radius size is equal or larger than the actual width of the box? .fancy { /* Within a circle, centered text looks prettier. */ text-align : center; /* Let's avoid our text touching the...
...ank canvas you'll fill. Before we jump to some practical examples, let's step back a bit as there are two things you should know about backgrounds. It's possible to set several backgrounds on a single box. They are stacked on top of each other like layers. Backgrounds can be either solid colors or images: solid color always fills the whole surface but images can be scaled and positioned. <
div class="fancy">Hi! I want to be fancy.</
div> Okay, let's have fun with backgrounds: .fancy { padding : 1em; width: 100%; height: 200px; box-sizing: border-box; /* At the bottom of our background stack, let's have a misty grey solid color */ background-color: #E4E4D9; /* We stack linear gradients on top of each other to create our color strip effect. As you will no...
...And 3 more matches
How to build custom form controls - Learn web development
nctionality has been decided upon, it's time to start building it. The first step is to define its HTML structure and to give it some basic semantics. Here is what we need to rebuild a <select> element: <!-- This is our main container for our control. The tabindex attribute is what allows the user to focus the control. We'll see later that it's better to set it through JavaScript. --> <
div class="select" tabindex="0"> <!-- This container will be used to display the current value of the control --> <span class="value">Cherry</span> <!-- This container will contain all the options available for our control. Because it's a list, it makes sense to use the ul element. --> <ul class="optList"> <!-- Each option only contains the value to be displayed, we'll see later ...
...ense to use the ul element. --> <ul class="optList"> <!-- Each option only contains the value to be displayed, we'll see later how to handle the real value that will be sent with the form data --> <li class="option">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> Note the use of class names; these identify each relevant part regardless of the actual underlying HTML elements used. This is important to make sure that we don't bind our CSS and JavaScript to a strong HTML structure, so that we can make implementation changes later without breaking code that uses the control. For example, what if you wish to implement the equivalent of the <optgroup> element...
...ript works as hoped: we will use this select to send data from our custom control along with the rest of our form data. We will discuss this in greater depth later. ...
...And 3 more matches
How to structure a web form - Learn web development
tiple labels Strictly speaking, you can put multiple labels on a single widget, but this is not a good idea as some assistive technologies can have trouble handling them. In the case of multiple labels, you should nest a widget and its labels inside a single <label> element. ...
... of multiple labels, you should nest a widget and its labels inside a single <label> element. ...
...d its labels inside a single <label> element. ...
...And 3 more matches
Example - Learn web development
This is the example code for the article Your first HTML form. ...
... This is the example code for the article Your first HTML form. ...
... This is the example code for the article Your first HTML form. ...
...And 3 more matches
Build your own function - Learn web development
followed by the name we want to give to our function, a set of parentheses, and a set of curly braces. Any parameters we want to give to our function go inside the parentheses, and the code that runs when we call the function goes inside the curly braces. ...
... lot of code to go through, so we'll walk you through it bit by bit. The first line uses a DOM API function called document.querySelector() to select the <html> element and store a reference to it in a constant called html, so we can do things to it later on: const html = document.querySelector('html'); The next section uses another DOM API function called document.createElement() to create a <
div> element and store a reference to it in a constant called panel. This element will be the outer container of our message box. We then use yet another DOM API function called Element.setAttribute() to set a class attribute on our panel with a value of msgBox. This is to make it easier to style the element -- if you look at the CSS on the page, you'll see that we are using a .msgBox class selector...
...on our panel with a value of msgBox. This is to make it easier to style the element -- if you look at the CSS on the page, you'll see that we are using a .msgBox class selector to style the message box and its contents. Finally, we call a DOM function called Node.appendChild() on the html constant we stored earlier, which nests one element inside the other as a child of it. ...
...And 3 more matches
Manipulating documents - Learn web development
ll solve a common problem -- making sure your application is as big as the window it is viewed in, whatever size it is. This is often useful in situations like games, where you want to use as much of the screen area as possible to play the game in. To start with, make a local copy of our window-resize-example.html and bgtile.png demo files. ...
...as much of the screen area as possible to play the game in. To start with, make a local copy of our window-resize-example.html and bgtile.png demo files. Open it and have a look -- you'll see that we've got a <
div> element covering a small part of the screen, which has got a background tile applied to it. We'll use that to represent our app UI area. ...
...e'll use that to represent our app UI area. First of all, let's grab a reference to the
div, and then grab the width and height of the viewport (the inner window, where your document is displayed) and store them in variables -- these two values are handily contained in the Window.innerWidth and Window.innerHeight properties. Add the following lines inside the existing <script> element: const
div = document.querySelector('
div'); let winWidth = window.innerWidth; let winHeight = window.innerHeight; Next, we'll dynamically alter the width and height of the
div to equal that of the viewport. ...
...And 3 more matches
Ember app structure and componentization - Learn web development
t looks like this: <section class="todoapp"> <h1>todos</h1> <input class="new-todo" aria-label="What needs to be done?" placeholder="What needs to be done?" autofocus > <section class="main"> <input id="mark-all-complete" class="toggle-all" type="checkbox"> <label for="mark-all-complete">Mark all as complete</label> <ul class="todo-list"> <li> <
div class="view"> <input aria-label="Toggle the completion of this todo" class="toggle" type="checkbox" > <label>Buy Movie Tickets</label> <button type="button" class="destroy" title="Remove this todo" ></button> </
div> <input autofocus class="edit" value="Todo Te...
... aria-label="Toggle the completion of this todo" class="toggle" type="checkbox" > <label>Buy Movie Tickets</label> <button type="button" class="destroy" title="Remove this todo" ></button> </
div> <input autofocus class="edit" value="Todo Text"> </li> <li> <
div class="view"> <input aria-label="Toggle the completion of this todo" class="toggle" type="checkbox" > <label>Go to Movie</label> <button type="button" class="destroy" title="Remove this todo" ></button> </
div> <input autofocus class="edit" value="Todo Text"> ...
...This is because the default CSS absolutely positions the checkbox + label with negative top and left values to move it next to the input, rather than it being inside the "m...
...And 3 more matches
Dynamic behavior in Svelte: working with variables and props - Learn web development
've seen that this is working, let's generate a complete todo item with each loop of the {#each} directive, and inside embed the information from the todos array: id, name, and completed. ...
...'s generate a complete todo item with each loop of the {#each} directive, and inside embed the information from the todos array: id, name, and completed. ...
... <!-- Todos --> <ul role="list" class="todo-list stack-large" aria-labelledby="list-heading"> {#each todos as todo (todo.id)} <li class="todo"> <
div class="stack-small"> <
div class="c-cb"> <input type="checkbox" id="todo-{todo.id}" checked={todo.completed}/> <label for="todo-{todo.id}" class="todo-label"> {todo.name} </label> </
div> <
div class="btn-group"> <button type="button" class="btn"> Edit <span class="visually-hidden">{todo.name}</span> </button> <button type="button" class="btn btn__danger"> Delete <span class="visually-hidden">{todo.name}</span> </button> </
div> </
div> </li> {:else} <li>Nothing to do here!</li> {/each}...
...And 3 more matches
Paint Flashing Tool - Firefox Developer Tools
light painted area" icon in the Toolbox again. Example: CSS transitions One area where implementation choices can affect repaint efficiency is in CSS transitions. The example below shows two different ways to move an element using a CSS transition. The first way applies the transition to the element's margin-left, while the second way moves the element using the transform property. ...
... the Toolbox again. Example: CSS transitions One area where implementation choices can affect repaint efficiency is in CSS transitions. The example below shows two different ways to move an element using a CSS transition. The first way applies the transition to the element's margin-left, while the second way moves the element using the transform property. ...
...ces can affect repaint efficiency is in CSS transitions. The example below shows two different ways to move an element using a CSS transition. The first way applies the transition to the element's margin-left, while the second way moves the element using the transform property. ...
...And 3 more matches
AbstractRange - Web APIs
e types are defined. A range is an object that indicates the start and end points of a section of content within the document. As an abstract interface, you will not directly instantiate an object of type AbstractRange. Instead, you will use the Range or StaticRange interfaces. To understand the difference between those two interfaces, and how to choose which is appropriate for your needs. ...
...A collapsed range is one whose start position and end position are the same, resulting in a zero-character-long range. endContainer Read only The DOM Node in which the end of the range, as specified by the endOffset property, is located. e...
... and end positions will generally be easier to make perform well. Rather than having to negotiate the DOM figuring out what your global offset refers to, the user agent (browser) can instead go directly to the node indicated by the starting position and start from there, working its way forward until it reaches the given offset into the ending node. ...
...And 3 more matches
Examples of web and XML development using the DOM - Web APIs
1.gif"> </p> <p>Image 2: height="50", width="500", but no style <img id="image2" src="https://udn.realityripple.com/samples/d2/8ba7141ed1.gif" height="50" width="500"> </p> <p>Image 3: no height, width, but style="height: 50px; width: 500px;" <img id="image3" src="https://udn.realityripple.com/samples/d2/8ba7141ed1.gif" style="height: 50px; width: 500px;"> </p> <
div id="output"> </
div> </body> </html> Example 2: Image Attributes <!DOCTYPE html> <html lang="en"> <head> <title>Modifying an image border</title> <script> function setBorderWidth(width) { document.getElementById("img1").style.borderWidth = width + "px"; } </script> </head> <body> <p> <img id="img1" src="image1.gif" style="border: 5px solid green;" width="100" height="...
...<input type="button" value="Make border 5px-wide" onclick="setBorderWidth(5);" /> </form> </body> </html> Example 3: Manipulating Styles In this simple example, some basic style properties of an HTML paragraph element are accessed using the style object on the element and that object's CSS style properties, which can be retrieved and set from the DOM. In this case, you are manipulating the in
dividual styles directly. In the next example (see Example 4), you can use stylesheets and their rules to change styles for whole documents. <!DOCTYPE html> <html lang="en"> <head> <title>Changing color and font-size example</title> <script> function changeText() { var p = document.getElementById("pid"); p.style.color = "blue" p.style.fontSize = "18pt" } </script> </head> <body> <p id="pid"...
...head> <body> <p id="pid" onclick="window.location.href = 'http://www.cnn.com/';">linker</p> <form> <p><input value="rec" type="button" onclick="changeText();" /></p> </form> </body> </html> Example 4: Using Stylesheets The styleSheets property on the document object returns a list of the stylesheets that have been loaded on that document. You can access these stylesheets and their rules in
dividually using the stylesheet, style, and CSSRule objects, as demonstrated in this example, which prints out all of the style rule selectors to the console. var ss = document.styleSheets; for(var i = 0; i < ss.length; i++) { for(var j = 0; j < ss[i].cssRules.length; j++) { dump( ss[i].cssRules[j].selectorText + "\n" ); } } For a document with a single stylesheet in which the following th...
...And 3 more matches
GlobalEventHandlers.onmouseup - Web APIs
ote: The opposite of onmouseup is onmousedown. Syntax target.onmouseup = functionRef; Value functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example In this example, a piece of "toast" hides when you click down with the mouse, and reappears when you release. It uses the onmousedown and onmouseup event handlers. ...
...seup is onmousedown. Syntax target.onmouseup = functionRef; Value functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example In this example, a piece of "toast" hides when you click down with the mouse, and reappears when you release. It uses the onmousedown and onmouseup event handlers. ...
... Syntax target.onmouseup = functionRef; Value functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example In this example, a piece of "toast" hides when you click down with the mouse, and reappears when you release. It uses the onmousedown and onmouseup event handlers. ...
...And 3 more matches
HTMLElement.offsetLeft - Web APIs
a span with wrapped text. Syntax left = element.offsetLeft; left is an integer representing the offset to the left in pixels from the closest relatively positioned parent element. ...
...to the left in pixels from the closest relatively positioned parent element. Example var colorTable = document.getElementById("t1"); var tOLeft = colorTable.offsetLeft; if (tOLeft > 5) { // large left offset: do something here } This example shows a 'long' sentence that wraps within a
div with a blue border, and a red box that one might think should describe the boundaries of the span. <
div style="width: 300px; border-color:blue; border-style:solid; border-width:1;"> <span>Short span. ...
...Left; if (tOLeft > 5) { // large left offset: do something here } This example shows a 'long' sentence that wraps within a
div with a blue border, and a red box that one might think should describe the boundaries of the span. <
div style="width: 300px; border-color:blue; border-style:solid; border-width:1;"> <span>Short span. ...
...And 3 more matches
MouseEvent.relatedTarget - Web APIs
m The EventTarget the pointing device entered to For events with no secondary target, relatedTarget returns null. FocusEvent.relatedTarget is a similar property for focus events. Syntax var target = instanceOfMouseEvent.relatedTarget Return value An EventTarget object or null. Example Try moving your mouse cursor into and out of the red and blue boxes. ...
...the pointing device entered to For events with no secondary target, relatedTarget returns null. FocusEvent.relatedTarget is a similar property for focus events. Syntax var target = instanceOfMouseEvent.relatedTarget Return value An EventTarget object or null. Example Try moving your mouse cursor into and out of the red and blue boxes. ...
...vice entered to For events with no secondary target, relatedTarget returns null. FocusEvent.relatedTarget is a similar property for focus events. Syntax var target = instanceOfMouseEvent.relatedTarget Return value An EventTarget object or null. Example Try moving your mouse cursor into and out of the red and blue boxes. ...
...And 3 more matches
RTCRemoteOutboundRtpStreamStats.localId - Web APIs
nd, the function returns null. The main networkTestStop() function Now let's look at the networkTestStop() function itself. It takes as input the RTCPeerConnection being tested, calls getStats() to get a new RTCStatsReport with current statistics, then computes the results it's looking for, outputting those results as appropriate to the user by appending appropriate HTML to the contents of the <
div> element whose class is stats-box. async function networkTestStop(pc) { if (pc) { let statsBox = document.querySelector(".stats-box"); let endReport = await pc.getStats(); for (let endRemoteOutbound of endReport.values()) { if (endRemoteOutbound.type === "remote-outbound-rtp") { let startRemoteOutbound = startReport.get(endRemoteOutbound.id); if (startRemote...
...ate = framesDecoded / elapsedTime; let timeString = ""; if (!isNaN(elapsedTime)) { timeString = ` representing ${elapsedTime}s`; } let frameString = ""; if (!isNaN(framesDecoded)) { frameString = `Decoded ${framesDecoded} frames for a frame rate of ${frameRate.toFixed(2)} FPS.<br>`; } let logEntry = `<
div class="stats-entry"><h2>Report ID: ${endRemoteOutbound.id}</h2>` + `Remote peer sent ${packetsSent} packets ${timeString}.<br>` + `${frameString}` + `Data size: ${bytesSent} bytes.</
div>`; statsBox.innerHTML += logEntry; } else { statsBox.innerHTML += `<
div class="stats-error">Unable to find ini...
...tbound.id}</h2>` + `Remote peer sent ${packetsSent} packets ${timeString}.<br>` + `${frameString}` + `Data size: ${bytesSent} bytes.</
div>`; statsBox.innerHTML += logEntry; } else { statsBox.innerHTML += `<
div class="stats-error">Unable to find initial statistics for ID ${endRemoteOutbound.id}.</
div>` } } statsBox.scrollTo(0, statsBox.scrollHeight); } } } Here's what's going on in the networkTestStop() function: after calling the RTCPeerConnection method getStats() to get the latest statistics report for the connection and storing it in endReport, This is an RTCStatsReport object, which maps strings taken from the RTCStatsType enumerated type to objects of the co...
...And 3 more matches
UIEvent.layerX - Web APIs
Note the pageX\pageY properties still return the absolute position in the document, includ...
...Note the pageX\pageY properties still return the absolute position in the document, including page scrolling.</span> <span>Make the p...
... } #d3 { position: absolute; top: 240px; left: 20%; width: 50%; border: solid blue 1px; padding: 10px; } </style> </head> <body onmousedown="showCoords(event)"> <p>To display the mouse coordinates please click anywhere on the page.</p> <
div id="d1"> <span>This is an un-positioned
div so clicking it will return layerX/layerY values almost the same as pageX/PageY values.</span> </
div> <
div id="d2"> <span>This is a positioned
div so clicking it will return layerX/layerY values that are relative to the top-left corner of this positioned element. Note the pageX\pageY properties still return the absolute position in the document, including page scrolling.</span> <span>Make the page scroll more! This is a positioned
div so clicking it will return layerX/layerY values that are r...
...And 3 more matches
UIEvent.layerY - Web APIs
Note the pageX\pageY properties still return the absolute position in the document, includ...
...Note the pageX\pageY properties still return the absolute position in the document, including page scrolling.</span> <span>Make the p...
... } #d3 { position: absolute; top: 240px; left: 20%; width: 50%; border: solid blue 1px; padding: 10px; } </style> </head> <body onmousedown="showCoords(event)"> <p>To display the mouse coordinates please click anywhere on the page.</p> <
div id="d1"> <span>This is an un-positioned
div so clicking it will return layerX/layerY values almost the same as pageX/PageY values.</span> </
div> <
div id="d2"> <span>This is a positioned
div so clicking it will return layerX/layerY values that are relative to the top-left corner of this positioned element. Note the pageX\pageY properties still return the absolute position in the document, including page scrolling.</span> <span>Make the page scroll more! This is a positioned
div so clicking it will return layerX/layerY values that are r...
...And 3 more matches
UIEvent.pageY - Web APIs
Note the pageX\pageY properties still return the absolute position in the document, includi...
...Note the pageX\pageY properties still return the absolute position in the document, including page scrolling.</span> <span>Make the pa...
... } #d3 { position: absolute; top: 240px; left: 20%; width: 50%; border: solid blue 1px; padding: 10px; } </style> </head> <body onmousedown="showCoords(event)"> <p>To display the mouse coordinates please click anywhere on the page.</p> <
div id="d1"> <span>This is an un-positioned
div so clicking it will return layerX/layerY values almost the same as pageX/PageY values.</span> </
div> <
div id="d2"> <span>This is a positioned
div so clicking it will return layerX/layerY values that are relative to the top-left corner of this positioned element. Note the pageX\pageY properties still return the absolute position in the document, including page scrolling.</span> <span>Make the page scroll more! This is a positioned
div so clicking it will return layerX/layerY values that are re...
...And 3 more matches
Using DTMF with WebRTC - Web APIs
ould be done over the network instead of it all being simply linked up inline as it is here. HTML The HTML for this example is very basic; there are only three elements of importance: An <audio> element to play the audio received by the RTCPeerConnection being "called." A <button> element to trigger creating and connecting the two RTCPeerConnection objects, then sending the DTMF tones. ...
...Keep in mind that the process of establishing the connection is somewhat contrived here; you normally don't build both ends of the connection in the same document. Global variables First, we establish global variables. ...
...Keep in mind that the process of establishing the connection is somewhat contrived here; you normally don't build both ends of the connection in the same document. Global variables First, we establish global variables. ...
...And 3 more matches
Using Web Workers - Web APIs
}),{type: 'text/javascript'}); // Creating a new document.worker property containing all our "text/js-worker" scripts. document.worker = new Worker(window.URL.createObjectURL(blob)); document.worker.onmessage = function(oEvent) { pageLog('Received: ' + oEvent.data); }; // Start the worker. window.onload = function() { document.worker.postMessage(''); }; </script> </head> <body><
div id="logDisplay"></
div></body> </html> The embedded worker is now nested into a new custom document.worker property. It is also worth noting that you can also convert a function into a Blob, then generate an object URL from that blob. For example: function fn2workerURL(fn) { var blob = new Blob(['('+fn.toString()+')()'], {type: 'application/javascript'}) return URL.createObjectURL(blob) } ...
...will define global properties with those names, but they will not register the function to receive messages sent by the web page that created the worker). This starts the recursion, spawning new copies of itself to handle each iteration of the calculation. ...
... properties with those names, but they will not register the function to receive messages sent by the web page that created the worker). This starts the recursion, spawning new copies of itself to handle each iteration of the calculation. ...
...And 3 more matches
Window.devicePixelRatio - Web APIs
o decimal places. Then the updatePixelRatio() function is called once to display the starting value, after which the media query is created using matchMedia() and addEventListener() is called to set up updatePixelRatio() as a handler for the change event. HTML The HTML creates the boxes containing the instructions and the pixel-ratio box that will display the current pixel ratio information. ...
...e updatePixelRatio() function is called once to display the starting value, after which the media query is created using matchMedia() and addEventListener() is called to set up updatePixelRatio() as a handler for the change event. HTML The HTML creates the boxes containing the instructions and the pixel-ratio box that will display the current pixel ratio information. ...
...ns and the pixel-ratio box that will display the current pixel ratio information. <
div class="container"> <
div class="inner-container"> <p>This example demonstrates the effect of zooming the page in and out (or moving it to a screen with a different scaling factor) on the value of the property <code>Window.devicePixelRatio</code>. ...
...And 3 more matches
WindowOrWorkerGlobalScope.setInterval() - Web APIs
l(flashText, 1000); } function flashText() { var oElem = document.getElementById('my_box'); oElem.style.color = oElem.style.color == 'red' ? 'blue' : 'red'; // oElem.style.color == 'red' ? 'blue' : 'red' is a conditional or ternary operator. } function stopTextColor() { clearInterval(nIntervId); } </script> </head> <body onload="changeColor();"> <
div id="my_box"> <p>Hello World</p> </
div> <button onclick="stopTextColor();">Stop</button> </body> </html> Example 3: Typewriter simulation The following example simulates typewriter by first clearing and then slowly typing content into the NodeList that matches a specified group of selectors. <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>JavaScript Typewriter - MDN Exam...
...ext-align: center;">CopyLeft 2012 by <a href="https://developer.mozilla.org/" target="_blank">Mozilla Developer Network</a></p> <p id="controls" style="text-align: center;">[ <span class="intLink" onclick="oTWExample1.play();">Play</span> | <span class="intLink" onclick="oTWExample1.pause();">Pause</span> | <span class="intLink" onclick="oTWExample1.terminate();">Terminate</span> ]</p> <
div id="info"> Vivamus blandit massa ut metus mattis in fringilla lectus imperdiet. Proin ac ante a felis ornare vehicula. Fusce pellentesque lacus vitae eros convallis ut mollis magna pellentesque. Pellentesque placerat enim at lacus ultricies vitae facilisis nisi fringilla. In tincidunt tincidunt tincidunt. </
div> <h1>JavaScript Typewriter</h1> <
div id="article"> <p>Lorem ipsum dolor sit amet, con...
...aculis nunc, vitae scelerisque metus leo non metus. Proin mattis lobortis lobortis. Quisque accumsan faucibus erat, vel varius tortor ultricies ac. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec libero nunc. Nullam tortor nunc, elementum a consectetur et, ultrices eu orci. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a nisl eu sem vehicula egestas.</p> </
div> </body> </html> View this demo in action. See also: clearInterval(). Callback arguments As previously discussed, Internet Explorer versions 9 and below do not support the passing of arguments to the callback function in either setTimeout() or setInterval(). The following IE-specific code demonstrates a method for overcoming this limitation. To use, simply add the following code to the top of...
...And 3 more matches
XPathEvaluator.evaluate() - Web APIs
a document that is not supported by the XPathEvaluator, a DOMException of type WRONG_DOCUMENT_ERR is raised. NOT_SUPPORTED_ERR If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Example The following example shows the use of the evaluate() method. ...
... not supported by the XPathEvaluator, a DOMException of type WRONG_DOCUMENT_ERR is raised. NOT_SUPPORTED_ERR If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Example The following example shows the use of the evaluate() method. ...
...upported by the XPathEvaluator, a DOMException of type WRONG_DOCUMENT_ERR is raised. NOT_SUPPORTED_ERR If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Example The following example shows the use of the evaluate() method. ...
...And 3 more matches
XPathExpression - Web APIs
n an application, because it is just compiled once and all namespace prefixes which occur within the expression are preresolved. Objects of this type are created by calling XPathEvaluator.createExpression(). Methods XPathExpression.evaluate() Evaluates the XPath expression on the given node or document. Example The following example shows the use of the XPathExpression interface. ...
...ecause it is just compiled once and all namespace prefixes which occur within the expression are preresolved. Objects of this type are created by calling XPathEvaluator.createExpression(). Methods XPathExpression.evaluate() Evaluates the XPath expression on the given node or document. Example The following example shows the use of the XPathExpression interface. ...
... it is just compiled once and all namespace prefixes which occur within the expression are preresolved. Objects of this type are created by calling XPathEvaluator.createExpression(). Methods XPathExpression.evaluate() Evaluates the XPath expression on the given node or document. Example The following example shows the use of the XPathExpression interface. ...
...And 3 more matches
ARIA: Region role - Accessibility
Landmark roles provide a way to identify the organization and structure of a web page. ...
...Landmark roles provide a way to identify the organization and structure of a web page. ...
...hould always prefer using the correct semantic HTML element, in this case <section>, over using ARIA. Associated WAI-ARIA Roles, States, and Properties aria-labelledby Use this attribute to label the region. Often, the value of the aria-labelledby attribute will be the id of the element used to title the section. Keyboard Interactions None. Required JavaScript features None. Examples <
div role="region" aria-labelledby="region-heading"> <h2 id="region-heading">This heading's <code>id</code> attribute helps this region have an accessible name</h2> <!-- region content --> </
div> Accessibility concerns Use sparingly! Landmark roles are intended to be used sparingly, to identify larger overall sections of the document. Using too many landmark roles can create "noise" in screen r...
...And 3 more matches
ARIA: dialog role - Accessibility
og role is used to mark up an HTML based application dialog or window that separates content or UI from the rest of the web application or page. Dialogs are generally placed on top of the rest of the page content using an overlay. Dialogs can be either non-modal (it's still possible to interact with content outside of the dialog) or modal (only the content in the dialog can be interacted with). ...
...However, adding role="dialog" alone is not sufficient to make a dialog accessible. ...
...tle bar, the text inside that bar can be used to label the dialog itself. The best way to achieve this is by using the aria-labelledby attribute to the role="dialog" element. Additionally, if the dialog contains additional descriptive text besides the dialog title, this text can be associated with the dialog using the aria-describedby attribute. ...
...And 3 more matches
::part() - CSS: Cascading Style Sheets
The ::part CSS pseudo-element represents any element within a shadow tree that has a matching part attribute. ...
...ment represents any element within a shadow tree that has a matching part attribute. ...
...epresents any element within a shadow tree that has a matching part attribute. ...
...And 3 more matches
:nth-child() - CSS: Cascading Style Sheets
a group of siblings. This is the same as the :first-child selector (and has the same specificity). p:nth-child(n+8):nth-child(-n+15) Represents the eighth through the fifteenth <p> elements of a group of siblings. ...
...nth <p> elements of a group of siblings. ...
...<span>Span 3!</span> <span>Span 4</span> <span>Span 5!</span> <span>Span 6</span> <span>Span 7!</span> </
div> <br> <h3><code>span:nth-child(2n+1)</code>, WITH an <code><em></code> among the child elements.</h3> <p>Children 1, 5, and 7 are selected.<br> 3 is used in the counting because it is a child, but it isn't selected because it isn't a <code><span></code>.</p> <
div class="second"> <span>Span!</span> <span>Span</span> <em>This is an `em`.</em> <span>Span</span> <span>Span!</span> <span>Span</span> <span>Span!</span> <span>Span</span> </
div> <br> <h3><code>span:nth-of-type(2n+1)</code>, WITH an <code><em></code> among the child elements.</h3> <p>Children 1, 4, 6, and 8 are selected.<br> 3 isn't used in the counting or selected be...
...And 3 more matches
:nth-of-type() - CSS: Cascading Style Sheets
cts every fourth <p> element among any group of siblings */ p:nth-of-type(4n) { color: lime; } Syntax The nth-of-type pseudo-class is specified with a single argument, which represents the pattern for matching elements. See :nth-child for a more detailed explanation of its syntax. ...
...y fourth <p> element among any group of siblings */ p:nth-of-type(4n) { color: lime; } Syntax The nth-of-type pseudo-class is specified with a single argument, which represents the pattern for matching elements. See :nth-child for a more detailed explanation of its syntax. ...
... group of siblings */ p:nth-of-type(4n) { color: lime; } Syntax The nth-of-type pseudo-class is specified with a single argument, which represents the pattern for matching elements. See :nth-child for a more detailed explanation of its syntax. ...
...And 3 more matches
aspect-ratio - CSS: Cascading Style Sheets
specified as a <ratio> value representing the width-to-height aspect ratio of the viewport. It is a range feature, meaning you can also use the prefixed min-aspect-ratio and max-aspect-ratio variants to query minimum and maximum values, respectively. Examples The example below is contained in an <iframe>, which creates its own viewport. Resize the <iframe> to see aspect-ratio in action. ...
...ort. It is a range feature, meaning you can also use the prefixed min-aspect-ratio and max-aspect-ratio variants to query minimum and maximum values, respectively. Examples The example below is contained in an <iframe>, which creates its own viewport. Resize the <iframe> to see aspect-ratio in action. HTML <
div id='inner'> Watch this element as you resize your viewport's width and height. ...
...ct-ratio and max-aspect-ratio variants to query minimum and maximum values, respectively. Examples The example below is contained in an <iframe>, which creates its own viewport. Resize the <iframe> to see aspect-ratio in action. HTML <
div id='inner'> Watch this element as you resize your viewport's width and height. ...
...And 3 more matches
Resizing background images with background-size - CSS: Cascading Style Sheets
width and/or height of the image. By doing so, you can scale the image upward or downward as desired. Tiling a large image Let's consider a large image, a 2982x2808 Firefox logo image. We want (for some reason likely involving horrifyingly bad site design) to tile four copies of this image into a 300x300-pixel element. To do this, we can use a fixed background-size value of 150 pixels. ...
...ge. By doing so, you can scale the image upward or downward as desired. Tiling a large image Let's consider a large image, a 2982x2808 Firefox logo image. We want (for some reason likely involving horrifyingly bad site design) to tile four copies of this image into a 300x300-pixel element. To do this, we can use a fixed background-size value of 150 pixels. ...
... CSS property offers two special size values, contain and cover. Let's take a look at these. contain The contain value specifies that, regardless of the size of the containing box, the background image should be scaled so that each side is as large as possible while not exceeding the length of the corresponding side of the container. Try resizing the example below to see this in action. ...
...And 3 more matches
background-color - CSS: Cascading Style Sheets
a-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...e> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...centage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...And 3 more matches
border-color - CSS: Cascading Style Sheets
The border-color shorthand CSS property sets the color of an element's border. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Each side can be set in
dividually using border-top-color, border-right-color, border-bottom-color, and border-left-color; or using the writing mode-aware border-block-start-color, border-block-end-color, border-inline-start-color, and border-inline-end-color. You can find more information about border colors in Borders in Applying color to HTML elements using CSS. Constituent properties This property is a shorthand for the following CSS properties: border-bottom-color border-left-col...
...{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...pha-value> = <number> | <percentage><hue> = <number> | <angle> Examples Complete border-color usage HTML <
div id="justone"> <p><code>border-color: red;</code> is equivalent to</p> <ul><li><code>border-top-color: red;</code></li> <li><code>border-right-color: red;</code></li> <li><code>border-bottom-color: red;</code></li> <li><code>border-left-color: red;</code></li> </ul> </
div> <
div id="horzvert"> <p><code>border-color: gold red;</code> is equivalent to</p> <ul><li><code>border-top-color: gold;</code></li> <li><code>border-right-color: red;</code></li> <li><code>border-bottom-color: gold;</code></li> <li><code>border-left-color: red;</code></li> </ul> </
div> <
div id="topvertbott"> <p><code>border-color: red cyan gold;</code> is equivalent to</p> <...
...And 3 more matches
clear - CSS: Cascading Style Sheets
ndicating that the element is moved down to clear floats on end side of its containing block, that is the right floats on ltr scripts and the left floats on rtl scripts. ...
...syntax none | left | right | both | inline-start | inline-end Examples clear: left HTML <
div class="wrapper"> <p class="black">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus sit amet diam. Duis mattis varius dui. ...
...ing elit.</p> <p class="left">This paragraph clears left.</p> </
div> CSS .wrapper{ border:1px solid black; padding:10px; } .left { border: 1px solid black; clear: left; } .black { float: left; margin: 0; background-color: black; color: #fff; width: 20%; } .red { float: left; margin: 0; background-color: pink; width:20%; } p { width: 50%; } clear: right HTML <
div class="wrapper"> <p class="black">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus sit amet diam. Duis mattis varius dui. ...
...And 3 more matches
scale - CSS: Cascading Style Sheets
This maps better to typical user interface usage, and saves having to remember the exact order of transform functions to specify in the transform value. Syntax /* Keyword values */ scale: none; /* Single values */ /* values of more than 1 make the element grow */ scale: 2; /* values of less than 1 make the element shrink */ scale: 0.5; /* Two values */ scale: 2 0.5; /* Three values */ scale: 2 0.5 2; Values Single number value A <number> specifying a scale factor to make the affected element scale by the same factor along both the X and Y axes. ...
...nd Z axis scaling values (respectively) of a 3D scale. Equivalent to a scale3d() (3D scaling) function. none Specifies that no scaling should be applied. ...
...) of a 3D scale. Equivalent to a scale3d() (3D scaling) function. none Specifies that no scaling should be applied. ...
...And 3 more matches
scale() - CSS: Cascading Style Sheets
, consider making use of the prefers-reduced-motion media feature -- use it to write a media query that will turn off animations if the user has reduced animation specified in their system preferences. ...
...aking use of the prefers-reduced-motion media feature -- use it to write a media query that will turn off animations if the user has reduced animation specified in their system preferences. ...
...use of the prefers-reduced-motion media feature -- use it to write a media query that will turn off animations if the user has reduced animation specified in their system preferences. ...
...And 3 more matches
translate - CSS: Cascading Style Sheets
This maps better to typical user interface usage, and saves having to remember the exact order of transform functions to specify in the transform value. Syntax /* Keyword values */ translate: none; /* Single values */ translate: 100px; translate: 50%; /* Two values */ translate: 100px 200px; translate: 50% 105px; /* Three values */ translate: 50% 105px 5rem; Values Single <length-percentage> value A <length> or <percentage> that specifies a 2D translation, with the same translation along both the X and Y axes. ...
...efinition Initial valuenoneApplies totransformable elementsInheritednoPercentagesrefer to the size of bounding boxComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typea transformCreates stacking contextyes Formal syntax none | <length-percentage> [ <length-percentage> <length>? ...
...mable elementsInheritednoPercentagesrefer to the size of bounding boxComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typea transformCreates stacking contextyes Formal syntax none | <length-percentage> [ <length-percentage> <length>? ...
...And 3 more matches
unset - CSS: Cascading Style Sheets
lly inherits from its parent, and to its initial value if not. In other words, it behaves like the inherit keyword in the first case, when the property is an inherited property, and like the initial keyword in the second case, when the property is a non-inherited property. unset can be applied to any CSS property, including the CSS shorthand all. ...
...lue if not. In other words, it behaves like the inherit keyword in the first case, when the property is an inherited property, and like the initial keyword in the second case, when the property is a non-inherited property. unset can be applied to any CSS property, including the CSS shorthand all. ...
... not. In other words, it behaves like the inherit keyword in the first case, when the property is an inherited property, and like the initial keyword in the second case, when the property is a non-inherited property. unset can be applied to any CSS property, including the CSS shorthand all. ...
...And 3 more matches
Adding captions and subtitles to HTML5 video - Developer guides
show how to add captions and subtitles to it, using the WebVTT format and the <track> element. Captioned video example In this article, we will refer to the Video player with captions example. This example uses an excerpt from the Sintel open movie, created by the Blender Foundation. Note: You can find the source on Github, and also view the example live. HTML5 and Video Captions Before
diving into how to add captions to the video player, there are a number of things that we will first mention, which you should be aware of before we start. Captions versus subtitles Captions and subtitles are not the same thing: they have significantly different audiences, and convey different information, and it is recommended that you read up on the differences if you are not sure what they are. ...
...ribute is set on the English <track> element, indicating to the browser that this is the default subtitle file definition to use when subtitles have been turned on and the user has not made a specific selection. In addition to adding the <track> elements, we have also added a new button to control the subtitles menu that we will build. ...
... In addition to adding the <track> elements, we have also added a new button to control the subtitles menu that we will build. ...
...And 3 more matches
Making content editable - Developer guides
elements; inline table editing to add or remove rows and columns; and the grabber that allows moving of absolutely-positioned elements. See bug 1449564 and Firefox-specific HTML editing UI has been deprecated for additional details. How does it work? All you have to do is set the contenteditable attribute on nearly any HTML element to make it editable. Here's a simple example which creates a <
div> element whose contents the user can edit. <
div contenteditable="true"> This text can be edited by the user. </
div> Here's the above HTML in action: Executing commands When an HTML element has contenteditable set to true, the document.execCommand() method is made available. This lets you run commands to manipulate the contents of the editable region. Most commands affect the document's se...
...contenteditable across different browsers has been painful for a long time because of the differences in generated markup between browsers. For example, even something as simple as what happens when you press Enter/Return to create a new line of text inside an editable element was handled differently across the major browsers (Firefox inserted <br> elements, IE/Opera used <p>, Chrome/Safari used <
div>). Fortunately, in modern browsers things are somewhat more consistent. As of Firefox 60, Firefox will be updated to wrap the separate lines in <
div> elements, matching the behavior of Chrome, modern Opera, Edge, and Safari. Try it out in the above example. Note: Internet Explorer, which is no longer being developed, uses <p> elements instead of <
div>. If you want to use a different paragra...
...DocMode(bToSource) { var oContent; if (bToSource) { oContent = document.createTextNode(oDoc.innerHTML); oDoc.innerHTML = ""; var oPre = document.createElement("pre"); oDoc.contentEditable = false; oPre.id = "sourceText"; oPre.contentEditable = true; oPre.appendChild(oContent); oDoc.appendChild(oPre); document.execCommand("defaultParagraphSeparator", false, "
div"); } else { if (document.all) { oDoc.innerHTML = oDoc.innerText; } else { oContent = document.createRange(); oContent.selectNodeContents(oDoc.firstChild); oDoc.innerHTML = oContent.toString(); } oDoc.contentEditable = true; } oDoc.focus(); } function printDoc() { if (!validateMode()) { return; } var oPrntWin = window.open("","_blank","width=450,h...
...And 3 more matches
<template>: The Content Template element - HTML: Hypertext Markup Language
ot supported. } The result is the original HTML table, with two new rows appended to it via JavaScript: table { background: #000; } table td { background: #fff; } Avoiding DocumentFragment pitfall A DocumentFragment is not a valid target for various events, as such it is often preferable to clone or refer to the elements within it. ...
... result is the original HTML table, with two new rows appended to it via JavaScript: table { background: #000; } table td { background: #fff; } Avoiding DocumentFragment pitfall A DocumentFragment is not a valid target for various events, as such it is often preferable to clone or refer to the elements within it. ...
..., with two new rows appended to it via JavaScript: table { background: #000; } table td { background: #fff; } Avoiding DocumentFragment pitfall A DocumentFragment is not a valid target for various events, as such it is often preferable to clone or refer to the elements within it. ...
...And 3 more matches
itemref - HTML: Hypertext Markup Language
specified. Note: the itemref attribute is not part of the microdata data model. It is merely a syntactic construct to aid authors in adding annotations to pages where the data to be annotated does not follow a convenient tree structure. For example, it allows authors to mark up data in a table so that each column defines a separate item while keeping the properties in the cells. ...
... not part of the microdata data model. It is merely a syntactic construct to aid authors in adding annotations to pages where the data to be annotated does not follow a convenient tree structure. For example, it allows authors to mark up data in a table so that each column defines a separate item while keeping the properties in the cells. ...
... construct to aid authors in adding annotations to pages where the data to be annotated does not follow a convenient tree structure. For example, it allows authors to mark up data in a table so that each column defines a separate item while keeping the properties in the cells. ...
...And 3 more matches
HTTP Messages - HTTP
ent. There are two types of messages: requests sent by the client to trigger an action on the server, and responses, the answer from the server. HTTP messages are composed of textual information encoded in ASCII, and span over multiple lines. In HTTP/1.1, and earlier versions of the protocol, these messages were openly sent across the connection. In HTTP/2, the once human-readable message is now
divided up into HTTP frames, providing optimization and performance improvements. Web developers, or webmasters, rarely craft these textual HTTP messages themselves: software, a Web browser, proxy, or Web server, perform this action. They provide HTTP messages through config files (for proxies or servers), APIs (for browsers), or other interfaces. The HTTP/2 binary framing mechanism has been desi...
...ator of the expected version to use for the response. Headers HTTP headers from a request follow the same basic structure of an HTTP header: a case-insensitive string followed by a colon (':') and a value whose structure depends upon the header. The whole header, including the value, consist of one single line, which can be quite long. There are numerous request headers available. They can be
divided in several groups: General headers, like Via, apply to the message as a whole. Request headers, like User-Agent, Accept-Type, modify the request by specifying it further (like Accept-Language), by giving context (like Referer), or by conditionally restricting it (like If-None). Entity headers, like Content-Length which apply to the body of the request. Obviously, there is no such header ...
...viously, there is no such header transmitted if there is no body in the request. Body The final part of the request is its body. Not all requests have one: requests fetching resources, like GET, HEAD, DELETE, or OPTIONS, usually don't need one. Some requests send data to the server in order to update it: as often the case with POST requests (containing HTML form data). Bodies can be broadly
divided into two categories: Single-resource bodies, consisting of one single file, defined by the two headers: Content-Type and Content-Length. Multiple-resource bodies, consisting of a multipart body, each containing a different bit of information. This is typically associated with HTML Forms. HTTP Responses Status line The start line of an HTTP response, called the status line, contains th...
...And 3 more matches
Expressions and operators - JavaScript
also compound assignment operators that are shorthand for the operations listed in the following table: Compound assignment operators Name Shorthand operator Meaning Assignment x = y x = y Addition assignment x += y x = x + y Subtraction assignment x -= y x = x - y Multiplication assignment x *= y x = x * y
Division assignment x /= y x = x / y Remainder assignment x %= y x = x % y Exponentiation assignment x **= y x = x ** y Left shift assignment x <<= y x = x << y Right shift assignment x >>= y x = x >> y Unsigned right shift assignment x >>>= y x = x >>> y Bitwise AND assignment x &= y x = x & y Bi...
...s less than or equal to the right operand. var1 <= var2 var2 <= 5 Note: (=>) is not an operator, but the notation for Arrow functions. Arithmetic operators An arithmetic operator takes numerical values (either literals or variables) as their operands and returns a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and
division (/). These operators work as they do in most other programming languages when used with floating point numbers (in particular, note that
division by zero produces Infinity). For example: 1 / 2; // 0.5 1 / 2 == 1.0 / 2.0; // this is true In addition to the standard arithmetic operations (+, -, *, /), JavaScript provides the arithmetic operators listed in the following table: Arithmetic ...
... 12 % 5 returns 2. Increment (++) Unary operator. Adds one to its operand. If used as a prefix operator (++x), returns the value of its operand after adding one; if used as a postfix operator (x++), returns the value of its operand before adding one. If x is 3, then ++x sets x to 4 and returns 4, whereas x++ returns 3 and, only then, sets x to 4. ...
...And 3 more matches
Authoring MathML - MathML
arning.js/mpadded-min.js"></script> If you don't want to use this link to GitHub but instead to integrate these polyfills or others in your own project, you might need the detection scripts to verify the level of MathML support. ...
...ript> If you don't want to use this link to GitHub but instead to integrate these polyfills or others in your own project, you might need the detection scripts to verify the level of MathML support. ...
...don't want to use this link to GitHub but instead to integrate these polyfills or others in your own project, you might need the detection scripts to verify the level of MathML support. ...
...And 3 more matches
Digital audio concepts - Web media technologies
analog feature of the natural world. As an object vibrates, it causes the molecules surrounding it to vibrate as well. These molecules affect the ones adjacent to them, and so forth, propagating the vibration in the form of a wave outward from the source until the amplitude of the wave (its volume) fades away with distance. The granularity of an audio wave in the real world, then, is that of an in
dividual molecule of the medium through which the sound wave is traveling. On Earth, the medium most audio travels through is the air. Some audio does travel through water, or even through the rock comprising the planet itself (if you've ever heard the rumble or boom of an earthquake, you've experienced this phenomenon), but nearly all of the sounds you hear every day travel to your ears through the...
...would look if you took samples twice as often. Or ten times as often. The more samples you take, the smoother the wave becomes. Audio data format and structure At the most basic level, audio is represented by a stream of samples, each specifying the amplitude of the audio waveform as measured for a given slice of the overall waveform of the audio signal. There are several formats used for the in
dividual samples within an audio file. Most audio files use 16-bit signed integers for each sample, but others use 32-bit floating-point values or 24-bit or 32-bit integers. Some older audio file formats--which you won't find in use on the web--used 8-bit integer samples. In addition, samples may use signed or unsigned values, as well. The size of an in
dividual sample is called the sample size. The ...
... sound, there are two audio sources: one speaker on the left, and one on the right. Each of these is represented by one channel, and the number of channels contained in the audio signal is called the channel count. While recording or generating multi-channel audio files, the channels are assembled into a series of audio frames, each consisting of one sample for each of the audio's channels. An in
dividual sample is a numeric value representing the amplitude of the sound waveform at a single moment in time, and may be represented in various formats. Stereo audio is probably the most commonly used channel arrangement in web audio, and 16-bit samples are used for the majority of day-to-day audio in use today. For 16-bit stereo audio, each sample taken from the analog signal is recorded as two 1...
...And 3 more matches
SVG documentation index - SVG: Scalable Vector Graphics
34 begin NeedsCompatTable, SVG, SVG Attribute The begin attribute defines when an animation should begin or when an element should be discarded. 35 bias Filters, NeedsExample, SVG, SVG Attribute The bias attribute shifts the range of the filter. After applying the kernelMatrix of the <feConvolveMatrix> element to the input image to yield a number and applied the
divisor attribute, the bias attribute is added to each component. This allows representation of values that would otherwise be clamped to 0 or 1. 36 by SVG, SVG Attribute The by attribute specifies a relative offset value for an attribute that will be modified during an animation. 37 calcMode NeedsCompatTable, NeedsExample, SVG, SVG Attribute The calcMode att...
... defines the start and end points of a line of text as used by the text-anchor and inline-size properties. It also may affect the direction in which characters are positioned if the unicode-bidi property's value is either embed or bidi-override. 59 display SVG, SVG Attribute The display attribute lets you control the rendering of graphical or container elements. 60
divisor Filters, SVG, SVG Attribute The
divisor attribute specifies the value by which the resulting number of applying the kernelMatrix of a <feConvolveMatrix> element to the input image color value is
divided to yield the destination color value. 61 dominant-baseline Reference, SVG, SVG Attribute The dominant-baseline attribute specifies the dominant baseline, which i...
... repeatCount SVG, SVG Attribute The repeatCount attribute indicates the number of times an animation will take place. 176 repeatDur SVG, SVG Attribute The repeatDur attribute specifies the total duration for repeating an animation. 177 requiredFeatures SVG, SVG Attribute The requiredFeatures attribute takes a list of feature strings, with the in
dividual strings separated by white space. It determines whether or not all of the named features are supported by the browser; if all of them are supported, the attribute evaluates to true end the element is rendered; otherwise, the attribute evaluates to false and the current element and its children are skipped and thus will not be rendered. This provides a way to design SVG that gracefully falls ...
...And 3 more matches
page-mod - Archive of obsolete content
script in the context of the currently active tab when the user clicks a button: to block certain content, to change the font style, or to display the document's DOM structure. Using the attach method of the tab object, you can attach a set of content scripts to a particular tab. The scripts are executed immediately. ...
...font style, or to display the document's DOM structure. Using the attach method of the tab object, you can attach a set of content scripts to a particular tab. The scripts are executed immediately. ...
...he document's DOM structure. Using the attach method of the tab object, you can attach a set of content scripts to a particular tab. The scripts are executed immediately. ...
...And 2 more matches
Storing annotations - Archive of obsolete content
lick handler to the links which will send the URL to the add-on. Save this file in data/list as annotation-list.js. ...
...ich will send the URL to the add-on. Save this file in data/list as annotation-list.js. ...
...l send the URL to the add-on. Save this file in data/list as annotation-list.js. ...
...And 2 more matches
Monitoring WiFi access points - Archive of obsolete content
This object is described in lines 11 through 40 in the code above. The onChange() method (lines 13 through 27) begins by enabling UniversalXPConnect privileges, t...
...This object is described in lines 11 through 40 in the code above. The onChange() method (lines 13 through 27) begins by enabling UniversalXPConnect privileges, then clearing out the...
...return this; throw Components.results.NS_ERROR_NO_INTERFACE; }, } netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); var listener = new test(); var wifi_service = Components.classes["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor); wifi_service.startWatching(listener); </script> </head> <body> <
div id="d"><p></p></
div> <
div id="c"><p></p></
div> </body> </html> The nsIWifiListener object The first thing the code above does is to prototype the listener object that will be receiving notifications of changes to the access point list. This object is described in lines 11 through 40 in the code above. The onChange() method (lines 13 through 27) begins by enabling UniversalXPConnect privileges, then clearing out the
div (...
...And 2 more matches
jspage - Archive of obsolete content
m=c(this.uid);delete m[l];return this;}});window.addListener("unload",d);})();Element.Properties=new Hash;Element.Properties.style={set:function(a){this.style.cssText=a; },get:function(){return this.style.cssText;},erase:function(){this.style.cssText="";}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase(); }};Element.Properties.html=(function(){var c=document.createElement("
div");var a={table:[1,"<table>","</table>"],select:[1,"<select>","</select>"],tbody:[2,"<table><tbody>","</tbody></table>"],tr:[3,"<table><tbody><tr>","</tr></tbody></table>"]}; a.thead=a.tfoot=a.tbody;var b={set:function(){var e=Array.flatten(arguments).join("");var f=Browser.Engine.trident&&a[this.get("tag")];if(f){var g=c;g.innerHTML=f[1]+e+f[2]; for(var d=f[0];d--;){g=g.firstChild;}this.empty().a...
...ts).join("");var f=Browser.Engine.trident&&a[this.get("tag")];if(f){var g=c;g.innerHTML=f[1]+e+f[2]; for(var d=f[0];d--;){g=g.firstChild;}this.empty().adopt(g.childNodes);}else{this.innerHTML=e;}}};b.erase=b.set;return b;})();if(Browser.Engine.webkit&&Browser.Engine.version<420){Element.Properties.text={get:function(){if(this.innerText){return this.innerText; }var a=this.ownerDocument.newElement("
div",{html:this.innerHTML}).inject(this.ownerDocument.body);var b=a.innerText;a.destroy();return b;}};}Element.Properties.events={set:function(a){this.addEvents(a); }};Native.implement([Element,Window,Document],{addEvent:function(e,g){var h=this.retrieve("events",{});h[e]=h[e]||{keys:[],values:[]};if(h[e].keys.contains(g)){return this; }h[e].keys.push(g);var f=e,a=Element.Events.get(e),c=g,i=this;if(...
...},selected:function(){return this.selected;},enabled:function(){return(this.disabled===false); }});Element.Events.domready={onAdd:function(a){if(Browser.loaded){a.call(this);}}};(function(){var b=function(){if(Browser.loaded){return;}Browser.loaded=true; window.fireEvent("domready");document.fireEvent("domready");};window.addEvent("load",b);if(Browser.Engine.trident){var a=document.createElement("
div"); (function(){($try(function(){a.doScroll();return document.id(a).inject(document.body).set("html","temp").dispose();}))?b():arguments.callee.delay(50);})(); }else{if(Browser.Engine.webkit&&Browser.Engine.version<525){(function(){(["loaded","complete"].contains(document.readyState))?b():arguments.callee.delay(50); })();}else{document.addEvent("DOMContentLoaded",b);}}})();var JSON=new Hash(this.J...
...And 2 more matches
LIR - Archive of obsolete content
84 noti integer bitwise-NOT int 85 andi integer bitwise-AND int 86 ori integer bitwise-OR int 87 xori in...
... 84 noti integer bitwise-NOT int 85 andi integer bitwise-AND int 86 ori integer bitwise-OR int 87 xori integer bitwise-XOR int...
...l 77 ged integer double greater-than-or-equal 78 negi integer negate int 79 addi integer add int 80 subi integer subtract int 81 muli integer multiply int 82
divi integer i386/64
divide int 83 modi integer modulo int - LIR_modi is a hack. It's only used on i386/X64. The operand is the result of a LIR_
divi because on i386/X64
div and mod results are computed by the same instruction. 84 noti integer bitwise-NOT int 85 andi integer bitwise-AND int 86 ori integer bitwise-OR int 87 xori integer bitwise-XOR int 88 lshi integer left shift int 89 rshi integer right shift int (>>) 90 rshui integer right shift...
...And 2 more matches
Introduction to XUL - Archive of obsolete content
rstanding of such things. This paper contains a short introduction to Mozilla front-end architecture, concentrating on the task of building UIs. It is, as always, incomplete. Mozilla applications will be built of "small" components like dialog buttons and mail inbox folders, which we collectively term "widgets." Within a widget, drawing and user interactions are completely under control of the in
dividual widget, and set when the widget was built. Relative placement of widgets, their interactions with each other, and optionally some of their configuration, will be controlled by a UI layout specified in a script whose structure is defined in this and related documents. Widgets are pieces of the application largely self-contained, generally corresponding to a rectangle of window real estate. W...
...etails. In general, you will want to store XUL in *.xul files. A XUL file can contain XML elements and HTML elements, as well as special elements unique to XUL: XUL elements. Namespace declarations for XUL (and HTML, if HTML elements are used) must be included in the file. Namespaces must be treated carefully. Correct namespace usage dictates that the namespace be used only for the tag, not in in
dividual attributes. Rare exceptions to this rule are bugs. XUL File Preamble XUL is XML, and a good XUL file begins with the standard XML version and DOCTYPE statements. Since XML has no implicit display semantics, there must always be associated stylesheets. Mozilla includes a standard stylesheet, "xul.css". You can load as many style sheets as you wish using repeated processing directives, alth...
...in with the other content, delimited by a script element in the HTML namespace. <html:script type="application/javascript"> // dialog initialization code function InitWindow() { var checkbox = document.getElementById("remember"); if (checkbox) checkbox.checked = true; } </html:script> JavaScript can be referenced as in HTML documents: as onClick handlers and the like. See in
dividual widget documentation referenced at the index for a list of attributes accepting JavaScript values. JavaScript is most safely kept in a separate file and included in the XUL file <html:script language="javascript" src="our.js"/> or relegated to the contents of a CDATA section, to prevent the XML parser from choking on JavaScript which may look like XML content (a < character, for instance...
...And 2 more matches
The box model - Learn web development
t if your box is really the size you think it is! Margins, padding, and borders You've already seen the margin, padding, and border properties at work in the example above. The properties used in that example are shorthands and allow us to set all four sides of the box at once. These shorthands also have equivalent longhand properties, which allow control over the different sides of the box in
dividually. Let's explore these properties in more detail. Margin The margin is an invisible space around your box. It pushes other elements away from the box. Margins can have positive or negative values. Setting a negative margin on one side of your box can cause it to overlap other things on the page. Whether you are using the standard or alternative box model, the margin is always added after ...
...away from the box. Margins can have positive or negative values. Setting a negative margin on one side of your box can cause it to overlap other things on the page. Whether you are using the standard or alternative box model, the margin is always added after the size of the visible box has been calculated. We can control all margins of an element at once using the margin property, or each side in
dividually using the equivalent longhand properties: margin-top margin-right margin-bottom margin-left In the example below, try changing the margin values to see how the box is pushed around due to the margin creating or removing space (if it is a negative margin) between this element and the containing element. Margin collapsing A key thing to understand about margins is the concept of...
...s pushed around due to the margin creating or removing space (if it is a negative margin) between this element and the containing element. Margin collapsing A key thing to understand about margins is the concept of margin collapsing. If you have two elements whose margins touch, and both margins are positive, those margins will combine to become one margin, which is the size of the largest in
dividual margin. If one or both margins are negative, the amount of negative value will subtract from the total. In the example below, we have two paragraphs. The top paragraph has a margin-bottom of 50 pixels. The second paragraph has a margin-top of 30 pixels. The margins have collapsed together so the actual margin between the boxes is 50 pixels and not the total of the two margins. You can test...
...And 2 more matches
Adding vector graphics to the Web - Learn web development
re actually all PNGs -- with the left-hand star in each case representing a raster image, and the right-hand star representing a vector image. Again, go to the vector-versus-raster.html demo for a real example! Moreover, vector image files are much lighter than their raster equivalents, because they only need to hold a handful of algorithms, rather than information on every pixel in the image in
dividually. What is SVG? SVG is an XML-based language for describing vector images. It's basically markup, like HTML, except that you've got many different elements for defining the shapes you want to appear in your image, and the effects you want to apply to those shapes. SVG is for marking up graphics, not content. At the simplest end of the spectrum, you've got elements for creating simple shape...
...y provided you with some samples to get you started. You can also go to the SVG Element Reference, find out more details about other toys you can use in SVG, and try those out too. This section is all about practising your research skills, and having some fun. If you get stuck and can't get your code working, you can always reset it using the Reset button. ...
...ted. You can also go to the SVG Element Reference, find out more details about other toys you can use in SVG, and try those out too. This section is all about practising your research skills, and having some fun. If you get stuck and can't get your code working, you can always reset it using the Reset button. ...
...And 2 more matches
From object to iframe — other embedding technologies - Learn web development
h HTML fundamentals (as covered in Getting started with HTML) and the previous articles in this module. Objective: To learn how to embed items into web pages using <object>, <embed>, and <iframe>, like Flash movies and other webpages. A short history of embedding A long time ago on the Web, it was popular to use frames to create websites -- small parts of a website stored in in
dividual HTML pages. These were embedded in a master document called a frameset, which allowed you to specify the area on the screen that each frame filled, rather like sizing the columns and rows of a table. These were considered the height of coolness in the mid to late 90s, and there was evidence that having a webpage split up into smaller chunks like this was better for download speeds -- especia...
... of the UI. Select the Share or embed map option. Select the Embed map option, which will give you some <iframe> code -- copy this. Insert it into the Input box below, and see what the result is in the Output. If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see an answer. ...
.... Select the Embed map option, which will give you some <iframe> code -- copy this. Insert it into the Input box below, and see what the result is in the Output. If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see an answer. ...
...And 2 more matches
Handling common accessibility problems - Learn web development
you replace it with something else that fits in with your design better -- it is a very valuable accessiblity tool, and should not be removed. Building in keyboard accessibility Sometimes it is not possible to avoid losing keyboard accessibility. You might have inherited a site where the semantics are not very good (perhaps you've ended up with a horrible CMS that generates buttons made with <
div>s), or you are using a complex control that does not have keyboard accessibility built in, like the HTML5 <video> element (amazingly, Opera is the only browser that allows you to tab through the <video> element's default browser controls). You have a few options here: Create custom controls using <button> elements (which we can tab to by default!) and JavaScript to wire up their functionality.
...ir functionality. See Creating a cross-browser video player for some good examples of this. Create keyboard shortcuts via JavaScript, so functionality is activated when you press certain keys on the keyboard. See Desktop mouse and keyboard controls for some game-related examples that can be adapted for any purpose. Use some interesting tactics to fake button behaviour. Take for example our fake-
div-buttons.html example (see source code). Here we've given our fake <
div> buttons the ability to be focused (including via tab) by giving each one the attribute tabindex="0" (see WebAIM's tabindex article for more really useful details). This allows us to tab to the buttons, but not to activate them via the Enter/Return key. To do that, we had to add the following bit of JavaScript trickery: docu...
...kind of problems as CSS with respect to accessibility -- it can be disastrous for accessibility if used badly, or overused. We've already hinted at some accessibility problems related to JavaScript, mainly in the area of semantic HTML -- you should always use appropriate semantic HTML to implement functionality wherever it is available, for example use links and buttons as appropriate. Don't use <
div> elements with JavaScript code to fake functionality if at all possible -- it is error prone, and more work than using the free functionality HTML gives you. Simple functionality Generally simple functionality should work with just the HTML in place -- JavaScript should only be used to enhance functionality, not build it in entirely. Good uses of JavaScript include: Providing client-side for...
...And 2 more matches
Handling common HTML and CSS problems - Learn web development
ation into forms, such as times, dates, colors, numbers, etc. These are very useful, particularly on mobile platforms, where providing a pain-free way of entering data is very important for the user experience. Supporting platforms provide special UI widgets when these input types are used, such as a calendar widget for entering dates. ...
...rticularly on mobile platforms, where providing a pain-free way of entering data is very important for the user experience. Supporting platforms provide special UI widgets when these input types are used, such as a calendar widget for entering dates. ...
...ly on mobile platforms, where providing a pain-free way of entering data is very important for the user experience. Supporting platforms provide special UI widgets when these input types are used, such as a calendar widget for entering dates. ...
...And 2 more matches
Accessibility API cross-reference
hat forms an independent part of a document, page, or site. article <article> <Part> or <Art> Object representing entire app. ARIA role denotes interactive (not browsable) content operable in ways that differ from any of the other interactive ARIA roles, and may be only a part of the main document. APPLICATION FRAME n/a application See <
Div> and <NonStruct> A region that contains mostly site-oriented content, rather than page-specific content. banner A portion of quoted content which is 'too long' to appear 'inline' n/a blockquote <BlockQuote> Entire window border as 1 object BORDER n/a n/a n/a Specific kin...
... Abstract role - A form of widget that performs an action but does not receive input data. command A supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful when separated from the main content. complementary <aside> n/a but <
Div> or even <p> have been suggested for this purpose A widget that may contain navigable descendants or owned children. composite (abstract role) A large perceivable region that contains information about the parent document such as copyright, authors' names etc. contentinfo <footer> Page footers are often tagged as an Art...
...ts. directory See <nav> If it really is a table of contents, use <TOC> containing <TOCI> elements (which are wrappers for internal hyperlinks in such a table). For an index, use <Index> with a <L>(List) inside. No default semantics in HTML, but semantics and other accessibility features may be provided with ARIA. See also Span n/a n/a n/a <
div> <
Div> but if you need custom semantic structure, use <NonStruct> instead Window that corresponds to an MDI document. In ARIA, used to nest browsable rich text content inside interactive content DOCUMENT n/a n/a document Document A drop down list, different from COMBOBOX DROPLIST n/a n/a listbox For math & ch...
...And 2 more matches
How Mozilla's build system works
sive Make Backend The recursive make backend is the tried-and-true backend used to build the tree. It's what's been used since the dawn of Mozilla. Essentially, there are makefiles in each directory. make starts processing the makefile in the root directory and then recursively descends into child directories until it's done. But there's more to the process than that. The recursive make backend
divides the source tree into tiers. A tier is a grouping of related directories containing makefiles of their own. For example, there is a tier for the Netscape Portable Runtime (nspr), one for the JavaScript engine, one for the core Gecko platform, one for the XUL app being built, and so on. The main moz.build file defines the tiers and directories in the tiers. In reality, the main moz.build files...
...efines how it is integrated with the build system. Think of each moz.build file as a data structure telling the build system what to do. During build backend generation, all moz.build files relevant to the current build configuration are read and converted into files and actions used to build the tree (such as makefiles). In this section, we'll talk about how moz.build files actually work. An in
dividual moz.build file is actually a Python script. However, they are unlike most Python scripts. The execution environment is strictly controlled, so moz.build files can only perform a limited set of operations. moz.build files are limited to performing the following actions: Calling functions that are explicitly made available to the moz.build environment. Assigning to a well-defined set of va...
...ctions (they are not made available to the execution environment). The most important actions of moz.build files are #1 and #2 from the above list. These are how the execution of a moz.build file tells the build system what to do. For example, you can assign to the DIRS list to define which directories to traverse into looking for additional moz.build files. The output of the execution of an in
dividual moz.build file is a Python dictionary. This dictionary contains the UPPERCASE variables directly assigned to and the special variables indirectly assigned to by calling functions exported to the execution environment. This is what we were referring to when we said you can think of moz.build files as data structures. moz.build UPPERCASE Variables and Functions The set of special symbols ava...
...And 2 more matches
MathML Accessibility in Mozilla
lower b lower c upper d end multi-scripts __________ Not supported yet. See bug 1176983 and WebKit's bug 146454 a. pre-subscript e pre-superscript f pre-superscript g subscript b subscript c superscript d a base b subscript c subscript d superscript e presubscript f presuperscript g presuperscript scripted x+y __________ long
division symbol enclosing x plus y end symbol __________ Not supported. See WebKit's bug 146543. x plus y Enclosed by: a long
division sign x + y long
division enclosed x+y __________ long
division symbol enclosing x plus y end symbol __________ Not supported. See WebKit's bug 146543. x plus y Encl...
...See WebKit's bug 146543. ...
...See WebKit's bug 146543. ...
...And 2 more matches
DMD
ions of it. The "Twice-reported stack trace records" and "Unreported stack trace records" sections are the most important, because they indicate ways in which the memory reporters can be improved. Here's an example stack trace record from the "Unreported stack trace records" section. ...
... blocks, to make it run faster. The decision on whether to record is done probabilistically, and larger blocks are more likely to have an allocation stack trace recorded. All unreported blocks that lack an allocation stack trace will end up in a single record. ...
... Allocated at { #01: (no stack trace recorded due to --stacks=partial) } } In contrast, stack traces are always recorded when a block is reported, which means you can end up with records like this where the allocation point is unknown but the reporting point is known: Once-reported { 104,491 blocks in heap block record 13 of 4,689 10,392,000 bytes (10,392,000 requested / 0 slop) In
dividual block sizes: 512 x 124; 256 x 242; 192 x 813; 128 x 54,664; 64 x 48,648 1.35% of the heap (48.65% cumulative) 1.64% of once-reported (59.18% cumulative) Allocated at { #01: (no stack trace recorded due to --stacks=partial) } Reported at { #01: mozilla::dmd::DMDFuncs::Report(void const*) (/home/njn/moz/mi5/go64dmd/memory/replace/dmd/../../../../memory/replace/dmd/DMD.cpp:164...
...And 2 more matches
A guide to searching crash reports
The Mozilla crash-stats site provides facilities for investigating large numbers of Firefox crash reports. This guide to searching through crash reports may help you locate the crash reports that will help you find and fix the Firefox bug you're working on. Specifically, crash-stats offers two basic functions: Searching You can search the crash reports database by over 100 criteria: crash signature, date, platform, product, version, etc. Grouping You can cluster the results of each search into groups using the same criteria. To achieve full power and flexibility requires a good understanding of both of these functions. ...
...that signature. The "Add term" link in each "Signature" column cell lets you perform a narrower subsequent search among crash reports with that signature. The links in each "Bugs" column cell link to bug reports in Bugzilla. The default search: Crash reports If you switch to the "Crash Reports" tab you will see results like the ones in the following screenshot. This is a list of all the in
dividual crash reports that match the search criteria. If the number of matches is large -- in this case it exceeds 1.3 million, just as we saw in the "Signature facet" tab -- the results will be spread across multiple pages, which you can visit by clicking the links at the top right of the tab. The links within the results do the following things. The link in each "Crash ID" column cell links to...
...crash reports that match the search criteria. If the number of matches is large -- in this case it exceeds 1.3 million, just as we saw in the "Signature facet" tab -- the results will be spread across multiple pages, which you can visit by clicking the links at the top right of the tab. The links within the results do the following things. The link in each "Crash ID" column cell links to an in
dividual crash report. The links in each "Signature" column cell have the same effect that they did in the "Signature facet" tab. The links in the remaining column cells also let you perform a narrower subsequent search with that link's value added to the search criteria. A narrower search You can add criteria to perform a narrower search. For example, to perform a search for all Mac crash repor...
...And 2 more matches
sslfnc.html
on cannot use NSS to perform any cryptographic operations until after it enables appropriate cipher suites by calling one of the SSL Export Policy Functions: NSS_SetDomesticPolicy, NSS_SetExportPolicy, and NSS_SetFrancePolicy configure the cipher suites for domestic, international, and French versions of software products with encryption features. SSL_CipherPolicySet sets policy flags for in
dividual cipher suites, one at a time. This may be helpful if you have an export license that permits more or fewer capabilities than those allowed by the other export policy functions. NSS_InitReadWrite Sets up configuration files and performs other tasks required to run Network Security Services. Unlike NSS_Init, NSS_InitReadWrite provides both read and write access to database files. Syn...
...NULL_MD5 (not enabled by default) enabled If nonzero, the specified cipher is enabled. If zero, the cipher is disabled. Returns The function returns one of these values: If successful, SECSuccess. If unsuccessful, SECFailure. Use PR_GetError to obtain the error code. Description The CipherPrefSetDefault function enables or disables in
dividual cipher suites globally. You typically call this in response to changes in user-controlled settings. You must call this function once for each cipher you want to enable or disable. To enable or disable cipher suites for an in
dividual socket, use SSL_CipherPrefSet. The set of available SSL cipher suites may grow from release to release of NSS. Applications will find it desirable to determine...
...allow cipher suites until only those that you may legally export are permitted. Important If you call NSS_SetFrancePolicy sometime after initialization to change cipher suite policy settings, you must also call SSL_ClearSessionCache. Otherwise, the old settings remain in the session cache and will be used instead of the new settings. SSL_CipherPolicySet Sets policy for the use of in
dividual cipher suites. SSL_CipherPolicySet replaces the deprecated function SSL_SetPolicy. Syntax #include "ssl.h" #include "proto.h" SECStatus SSL_CipherPolicySet(PRInt32 cipher, PRInt32 policy); Parameters This function has the following parameters: cipher A value from one of the following lists. Values for SSL2 (all are disallowed by default): ...
...And 2 more matches
Statistics API
mpleted normally, this will be "none". allocated: integer (MB) - Size of the JavaScript heap in MiB at the start of the GC. slices: array of Objects - A list of objects describing each slice in detail. times: Object - A map from phase names to the total time taken by each phase: the sum of each field of the map from the slices. The last two fields require a bit of elaboration. ...
...eger (MB) - Size of the JavaScript heap in MiB at the start of the GC. slices: array of Objects - A list of objects describing each slice in detail. times: Object - A map from phase names to the total time taken by each phase: the sum of each field of the map from the slices. The last two fields require a bit of elaboration. GC work can be
divided into phases, such as marking or sweeping. ...
...A little bit of GC work is done in each slice. In between slices, other browser code is allowed to run. The slices array describes how long each slice took and what work was done during the slice. ...
...And 2 more matches
Gecko Roles
T Represents a document window. A document window is always contained within an application window. ROLE_PANE Represents a pane within a frame or document window. Users can navigate between panes and within the contents of the current pane, but cannot navigate between items in different panes. ...
... ROLE_TOOLBAR Represents a toolbar, which is a grouping of controls (push buttons or toggle buttons) that provides easy access to frequently used features. ...
... ROLE_TOOLBAR Represents a toolbar, which is a grouping of controls (push buttons or toggle buttons) that provides easy access to frequently used features. ...
...And 2 more matches
nsIAccessibleRole
indow. A document window is always contained within an application window. It is used for role="document". ROLE_PANE 16 Represents a pane within a frame or document window. Users can navigate between panes and within the contents of the current pane, but cannot navigate between items in different panes. Thus, panes represent a level of grouping lower than frame windows or documents, but above in
dividual controls. It is used for the first child of a or iframe. ROLE_CHART 17 Represents a graphical image used to represent data. ROLE_DIALOG 18 Represents a dialog box or message box. It is used for xul:dialog, role="dialog". ROLE_BORDER 19 Represents a window border. ROLE_GROUPING 20 Logically groups other objects. There is not always a parent-child relationship between the grouping obje...
...ta. ROLE_DIALOG 18 Represents a dialog box or message box. It is used for xul:dialog, role="dialog". ROLE_BORDER 19 Represents a window border. ROLE_GROUPING 20 Logically groups other objects. There is not always a parent-child relationship between the grouping object and the objects it contains. It is used for html:textfield, xul:groupbox, role="group". ROLE_SEPARATOR 21 Used to visually
divide a space into two regions, such as a separator menu item or a bar that
divides split panes within a window. It is used for xul:separator, html:hr, role="separator". ROLE_TOOLBAR 22 Represents a toolbar, which is a grouping of controls (push buttons or toggle buttons) that provides easy access to frequently used features. It is used for xul:toolbar, role="toolbar". ROLE_STATUSBAR 23 Represen...
...s a container of page tab controls. Is it used for xul:tabs, DHTML: role="tabs". Also refer to ROLE_PAGETAB. ROLE_CLOCK 61 Represents a control that displays time. ROLE_SPLITBUTTON 62 Represents a button on a toolbar that has a drop-down list icon directly adjacent to the button. ROLE_IPADDRESS 63 Represents an edit control designed for an Internet Protocol (IP) address. The edit control is
divided into sections for the different parts of the IP address. ROLE_ACCEL_LABEL 64 Represents a label control that has an accelerator. ROLE_ARROW 65 Represents an arrow in one of the four cardinal directions. ROLE_CANVAS 66 Represents a control that can be drawn into and is used to trap events. It is used for html:canvas. ROLE_CHECK_MENU_ITEM 67 Represents a menu item with a check box. RO...
...And 2 more matches
CSSStyleDeclaration.setProperty() - Web APIs
is equal to the selector .box p, which indicates it is the one we want. If so, we store a reference to this CSSStyleRule object in a variable. We then use three functions to generate random values for the properties in question, and update the rule with these values. ...
...hen use three functions to generate random values for the properties in question, and update the rule with these values. ...
...e three functions to generate random values for the properties in question, and update the rule with these values. ...
...And 2 more matches
ChildNode.after() - Web APIs
this ChildNode. DOMString objects are inserted as equivalent Text nodes. Syntax [Throws, Unscopable] void ChildNode.after((Node or DOMString)... nodes); Parameters nodes A set of Node or DOMString objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...es A set of Node or DOMString objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...ring objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...And 2 more matches
ChildNode.before() - Web APIs
this ChildNode. DOMString objects are inserted as equivalent Text nodes. Syntax [Throws, Unscopable] void ChildNode.before((Node or DOMString)... nodes); Parameters nodes A set of Node or DOMString objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...s A set of Node or DOMString objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...ing objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...And 2 more matches
DataTransfer.dropEffect - Web APIs
are: copy A copy of the source item is made at the new location. move An item is moved to a new location. link A link is established to the source at the new location. none The item may not be dropped. Assigning any other value to dropEffect has no effect and the old value is retained. Example This example shows the use of the dropEffect and effectAllowed properties. ...
... may not be dropped. Assigning any other value to dropEffect has no effect and the old value is retained. Example This example shows the use of the dropEffect and effectAllowed properties. HTML Content <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element. ...
...ot be dropped. Assigning any other value to dropEffect has no effect and the old value is retained. Example This example shows the use of the dropEffect and effectAllowed properties. HTML Content <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element. ...
...And 2 more matches
DataTransferItemList.add() - Web APIs
. If the drag item couldn't be created (for example, if the associated DataTransfer object has no data store), null is returned. Exceptions NotSupportedError A string data parameter was provided, and the list already contains an item whose kind is "Plain Unicode string" and whose type is equal to the specified type parameter. Example This example shows the use of the add() method. ...
...y contains an item whose kind is "Plain Unicode string" and whose type is equal to the specified type parameter. Example This example shows the use of the add() method. ...
...ains an item whose kind is "Plain Unicode string" and whose type is equal to the specified type parameter. Example This example shows the use of the add() method. ...
...And 2 more matches
DataTransferItemList.clear() - Web APIs
ing the list empty. The drag data store in which this list is kept is only writable while handling the dragstart event. While handling drop, the drag data store is in read-only mode, and this method silently does nothing. No exception is thrown. Syntax DataTransferItemList.clear(); Parameters None. Return value undefined Example This example shows the use of the clear() method. ...
...xception is thrown. Syntax DataTransferItemList.clear(); Parameters None. Return value undefined Example This example shows the use of the clear() method. ...
...n is thrown. Syntax DataTransferItemList.clear(); Parameters None. Return value undefined Example This example shows the use of the clear() method. ...
...And 2 more matches
Document.getElementsByTagNameNS() - Web APIs
ile saved with the .xhtml extension. ...
...l extension. ...
...//www.w3.org/1999/xhtml"> <head> <title>getElementsByTagNameNS example</title> <script type="text/javascript"> function getAllParaElems() { var allParas = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p"); var num = allParas.length; alert("There are " + num + " <p> elements in this document"); } function
div1ParaElems() { var
div1 = document.getElementById("
div1") var
div1Paras =
div1.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p"); var num =
div1Paras.length; alert("There are " + num + " <p> elements in
div1 element"); } function
div2ParaElems() { var
div2 = document.getElementById("
div2") var
div2Paras =
div2.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p"); var num =
div2Paras.length; alert("There are ...
...And 2 more matches
DocumentFragment.querySelector() - Web APIs
agment with the class "myclass" is returned: var el = documentfragment.querySelector(".myclass"); CSS syntax and the method's argument The string argument pass to querySelector must follow the CSS syntax. ...
...ss "myclass" is returned: var el = documentfragment.querySelector(".myclass"); CSS syntax and the method's argument The string argument pass to querySelector must follow the CSS syntax. ...
...class" is returned: var el = documentfragment.querySelector(".myclass"); CSS syntax and the method's argument The string argument pass to querySelector must follow the CSS syntax. ...
...And 2 more matches
Element.getBoundingClientRect() - Web APIs
(((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.scrollLeft == 'number' ? t : document.body).scrollLeft // For scrollY (((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.scrollTop == 'number' ? ...
...parentNode)) && typeof t.scrollLeft == 'number' ? ...
...Node)) && typeof t.scrollLeft == 'number' ? ...
...And 2 more matches
Element.removeAttributeNS() - Web APIs
The removeAttributeNS() method of the Element interface removes the specified attribute from an element. Syntax element.removeAttributeNS(namespace, attrName); Parameters namespace is a string that contains the namespace of the attribute. attrName is a string that names the attribute to be removed from the current node. ...
... The removeAttributeNS() method of the Element interface removes the specified attribute from an element. Syntax element.removeAttributeNS(namespace, attrName); Parameters namespace is a string that contains the namespace of the attribute. attrName is a string that names the attribute to be removed from the current node. ...
... element.removeAttributeNS(namespace, attrName); Parameters namespace is a string that contains the namespace of the attribute. attrName is a string that names the attribute to be removed from the current node. ...
...And 2 more matches
Event.preventDefault() - Web APIs
lector("#id-checkbox").addEventListener("click", function(event) { document.getElementById("output-box").innerHTML += "Sorry! ...
....addEventListener("click", function(event) { document.getElementById("output-box").innerHTML += "Sorry! ...
... for="id-checkbox">Checkbox:</label> <input type="checkbox" id="id-checkbox"/> </form> <
div id="output-box"></
div> Result Stopping keystrokes from reaching an edit field The following example demonstrates how invalid text input can be stopped from reaching the input field with preventDefault(). Nowadays, you should usually use native HTML form validation instead. ...
...And 2 more matches
FormData() - Web APIs
ontent. ...
...those with a name, not disabl...
...those with a name, not disabled and c...
...And 2 more matches
Recording a media element - Web APIs
a few seconds. You can stop the video by clicking the creatively-named "Stop" button. The "Download" button will download the received data (although it's in a raw, unwrapped form that isn't very useful). </p> <br> Let's start by looking at the key bits of the HTML. There's a little more than this, but it's just informational rather than being part of the core operation of the app. <
div class="left"> <
div id="startButton" class="button"> Start </
div> <h2>Preview</h2> <video id="preview" width="160" height="120" autoplay muted></video> </
div> We present our main interface in two columns. On the left is a start button and a <video> element which displays the video preview; this is the video the user's camera sees. Note that the autoplay attribute is used so that as s...
...tart button and a <video> element which displays the video preview; this is the video the user's camera sees. Note that the autoplay attribute is used so that as soon as the stream starts to arrive from the camera, it immediately gets displayed, and the muted attribute is specified to ensure that the sound from the user's microphone isn't output to their speakers, causing an ugly feedback loop. <
div class="right"> <
div id="stopButton" class="button"> Stop </
div> <h2>Recording</h2> <video id="recording" width="160" height="120" controls></video> <a id="downloadButton" class="button"> Download </a> </
div> On the right we see a stop button and the <video> element which will be used to play back the recorded video. Notice that the playback panel doesn't have autoplay set (s...
...On the right we see a stop button and the <video> element which will be used to play back the recorded video. Notice that the playback panel doesn't have autoplay set (so the playback doesn't start as soon as media arrives), and it has controls set, which tells it to show the user controls to play, pause, and so forth. Below the playback element is a button for downloading the recorded video. ...
...And 2 more matches
Node.removeChild() - Web APIs
e following exception: Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. If the child doesn't exist on the DOM of the page, the method throws the following exception: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. ...
...tion: Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. If the child doesn't exist on the DOM of the page, the method throws the following exception: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. ...
...NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. If the child doesn't exist on the DOM of the page, the method throws the following exception: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. ...
...And 2 more matches
Node - Web APIs
ProcessingInstruction, DocumentType, Notation, Entity, and EntityReference. In some cases, a particular feature of the base Node interface may not apply to one of its child interfaces; in that case, the inheriting node may return null or throw an exception, depending on circumstances. For example, attempting to add children to a node type that cannot have children will throw an exception. ...
... Node.baseURIRead only Returns a DOMString representing the base URL of the document containing the Node. Node.baseURIObject Read only (Not available to web content.) The nsIURI object representing the base URI for the elem...
... certain string). Parameters rootNode The Node object whose descendants will be recursed through. callback Optional An optional callback function that receives a Node as its only argument. If omitted, eachNode returns an Array of every node contained within rootNode (including the root itself). ...
...And 2 more matches
Using the Web Speech API - Web APIs
me. Browser support Support for Web Speech API speech recognition is curently limited to Chrome for Desktop and Android -- Chrome has supported it since around version 33 but with prefixed interfaces, so you need to include prefixed versions of them, e.g. webkitSpeechRecognition. HTML and CSS The HTML and CSS for the app is really trivial. We simply have a title, instructions paragraph, and a
div into which we output diagnostic messages. <h1>Speech color changer</h1> <p>Tap/click then say a color to change the background color of the app.</p> <
div> <p class="output"><em>...diagnostic messages</em></p> </
div> The CSS provides a very simple responsive styling so that it looks ok across devices. JavaScript Let's look at the JavaScript in a bit more detail. Chrome support As mentioned...
...er to choose the correct one from. But it is not needed for this simple demo, so we are just specifying one (which is actually the default anyway.) recognition.grammars = speechRecognitionList; recognition.continuous = false; recognition.lang = 'en-US'; recognition.interimResults = false; recognition.maxAlternatives = 1; Starting the speech recognition After grabbing references to the output <
div> and the HTML element (so we can output diagnostic messages and update the app background color later on), we implement an onclick handler so that when the screen is tapped/clicked, the speech recognition service will start. This is achieved by calling SpeechRecognition.start(). The forEach() method is used to output colored indicators showing what colors to try saying. var diagnostic = document...
...lex-looking, so let's explain it step by step. The SpeechRecognitionEvent.results property returns a SpeechRecognitionResultList object containing SpeechRecognitionResult objects. It has a getter so it can be accessed like an array -- so the first [0] returns the SpeechRecognitionResult at position 0. Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual recognised words. These also have getters so they can be accessed like arrays -- the second [0] therefore returns the SpeechRecognitionAlternative at position 0. We then return its transcript property to get a string containing the in
dividual recognised result as a string, set the background color to that color, and report the color recognised as a diagnostic message in the UI. We also use ...
...And 2 more matches
XPathResult.iterateNext() - Web APIs
the XPathResult. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE, an XPathException of type TYPE_ERR is thrown. INVALID_STATE_ERR If the document is mutated since the result was returned, an XPathException of type INVALID_STATE_ERR is thrown. Example The following example shows the use of the iterateNext() method. ...
...xceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE, an XPathException of type TYPE_ERR is thrown. INVALID_STATE_ERR If the document is mutated since the result was returned, an XPathException of type INVALID_STATE_ERR is thrown. Example The following example shows the use of the iterateNext() method. ...
...ons TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE, an XPathException of type TYPE_ERR is thrown. INVALID_STATE_ERR If the document is mutated since the result was returned, an XPathException of type INVALID_STATE_ERR is thrown. Example The following example shows the use of the iterateNext() method. ...
...And 2 more matches
XPathResult.numberValue - Web APIs
Note: This feature is available in Web Workers. Syntax var value = result.numberValue; Return value The return value is the numeric value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not NUMBER_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the numberValue property. ...
...e is available in Web Workers. Syntax var value = result.numberValue; Return value The return value is the numeric value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not NUMBER_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the numberValue property. ...
...vailable in Web Workers. Syntax var value = result.numberValue; Return value The return value is the numeric value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not NUMBER_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the numberValue property. ...
...And 2 more matches
XPathResult.resultType - Web APIs
D_NODE_TYPE 8 A result node-set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression. FIRST_ORDERED_NODE_TYPE 9 A result node-set containing the first node in the document that matches the expression. Example The following example shows the use of the resultType property. ...
... A result node-set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression. FIRST_ORDERED_NODE_TYPE 9 A result node-set containing the first node in the document that matches the expression. Example The following example shows the use of the resultType property. ...
...ult node-set containing any single node that matches the expression. The node is not necessarily the first node in the document that matches the expression. FIRST_ORDERED_NODE_TYPE 9 A result node-set containing the first node in the document that matches the expression. Example The following example shows the use of the resultType property. ...
...And 2 more matches
XPathResult.snapshotItem() - Web APIs
nt if it is mutated. Syntax var node = result.snapshotItem(i); Return value The Node at the given index within the node set of the XPathResult. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the snapshotItem() method. ...
.... Syntax var node = result.snapshotItem(i); Return value The Node at the given index within the node set of the XPathResult. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the snapshotItem() method. ...
...tax var node = result.snapshotItem(i); Return value The Node at the given index within the node set of the XPathResult. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the snapshotItem() method. ...
...And 2 more matches
XPathResult.snapshotLength - Web APIs
rs. Syntax var snapshotLength = result.snapshotLength; Return value An integer value representing the number of nodes in the result snapshot. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the snapshotLength property. ...
...apshotLength = result.snapshotLength; Return value An integer value representing the number of nodes in the result snapshot. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the snapshotLength property. ...
...Length = result.snapshotLength; Return value An integer value representing the number of nodes in the result snapshot. Exceptions TYPE_ERR In case XPathResult.resultType is not UNORDERED_NODE_SNAPSHOT_TYPE or ORDERED_NODE_SNAPSHOT_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the snapshotLength property. ...
...And 2 more matches
XPathResult.stringValue - Web APIs
. Note: This feature is available in Web Workers. Syntax var value = result.stringValue; Return value The return value is the string value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not STRING_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the stringValue property. ...
...re is available in Web Workers. Syntax var value = result.stringValue; Return value The return value is the string value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not STRING_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the stringValue property. ...
...available in Web Workers. Syntax var value = result.stringValue; Return value The return value is the string value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not STRING_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the stringValue property. ...
...And 2 more matches
ARIA: timer role - Accessibility
Description The timer role indicates to assistive technologies that this part of the web content is a live region containing a timer listing the time remaining or elapsed time. A timer's inner text should be an updating current time measurement. ...
... Description The timer role indicates to assistive technologies that this part of the web content is a live region containing a timer listing the time remaining or elapsed time. A timer's inner text should be an updating current time measurement. ...
...autiously! Examples Some prominent web timers include clocks, stop watches and countdowns, such as ticketing websites, e-commerce sites, and event countdowns (see https://countingdownto.com/). As an illustration of aria-atomic, consider a site with a simple clock, showing hours and minutes. The clock is updated each minute, with the new remaining time simply overwriting the current content. ...
...And 2 more matches
ARIA: figure role - Accessibility
The ARIA figure role can be used to identify a figure inside page content where appropriate semantics do not already exist. A figure is generally considered to be one or more images, code snippets, or other content that puts across information in a different way to a regular flow of text. <
div role="figure" aria-labelledby="caption"> <img src="image.png" alt="full alternative image description"> <p id="caption">Figure 1: The caption</p> </
div> In the above example, we have a figure that consists of two separate content items -- an image and a caption. This is wrapped by a <
div> element that identifies the content as a figure using role="figure". Instead of using ARIA to create a figure, consider using the native, semantic HTML <figure> element. along with the <figcaption> eleme...
...r content. For example, make sure it is perceivable by users of assistive technology, navigable by keyboard as well as mouse, and so on. You can add a caption or label to your figure in a number of ways. You could add an ID to an element containing content that describes the figure, and then reference that ID inside an appropriate attribute on the figure to associate the figure with the label: <
div role="figure" aria-labelledby="figure-1"> ... <p id="figure-1">Text that describes the figure.</p> </
div> Use aria-labelledby when the text is a concise label. Use aria-describedby when the text is a longer description. Again, this can be done semantically, without ARIA, with HTML's <figure> and <figcaption> elements <figure> ... <figcaption>Text that describes the figure.</figcapt...
...scription. Again, this can be done semantically, without ARIA, with HTML's <figure> and <figcaption> elements <figure> ... <figcaption>Text that describes the figure.</figcaption> </figure> If you don't want the label to be visible on the screen, but still want to provide a descriptive label for assistive technology users, you can use the aria-label attribute on the figure container: <
div role="figure" aria-label="Text that describes the figure."> ... </
div> You can use the aria-label with <figure> as well: <figure aria-label="Text that describes the figure."> ... </figure> Generally, you should reference the figure from the main text, but the figure need not be displayed at the same location as the referencing element. Note: If at all possible in your work, you should us...
...And 2 more matches
ARIA: textbox role - Accessibility
the user about it. The default is a single line input, in which Return or Enter submits the form; in this case, it is preferable to use an HTML <input> with type="text". To create a multi-line text box which supports line breaks, as in an HTML <textarea>, set aria-multiline="true". Including the HTML contenteditable attribute ensures the text node is editable. ...
...put, in which Return or Enter submits the form; in this case, it is preferable to use an HTML <input> with type="text". To create a multi-line text box which supports line breaks, as in an HTML <textarea>, set aria-multiline="true". Including the HTML contenteditable attribute ensures the text node is editable. ...
...n which Return or Enter submits the form; in this case, it is preferable to use an HTML <input> with type="text". To create a multi-line text box which supports line breaks, as in an HTML <textarea>, set aria-multiline="true". Including the HTML contenteditable attribute ensures the text node is editable. ...
...And 2 more matches
:checked - CSS: Cascading Style Sheets
ked { margin-left: 25px; border: 1px solid blue; } The user can engage this state by checking/selecting an element, or disengage it by unchecking/deselecting the element. Note: Because browsers often treat <option>s as replaced elements, the extent to which they can be styled with the :checked pseudo-class varies from browser to browser. ...
... the element. Note: Because browsers often treat <option>s as replaced elements, the extent to which they can be styled with the :checked pseudo-class varies from browser to browser. ...
...ement. Note: Because browsers often treat <option>s as replaced elements, the extent to which they can be styled with the :checked pseudo-class varies from browser to browser. ...
...And 2 more matches
:last-of-type - CSS: Cascading Style Sheets
no longer required. Syntax :last-of-type Examples Styling the last paragraph HTML <h2>Heading</h2> <p>Paragraph 1</p> <p>Paragraph 2</p> CSS p:last-of-type { color: red; font-style: italic; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector (*) is implied when no simple selector is written. ...
... required. Syntax :last-of-type Examples Styling the last paragraph HTML <h2>Heading</h2> <p>Paragraph 1</p> <p>Paragraph 2</p> CSS p:last-of-type { color: red; font-style: italic; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector (*) is implied when no simple selector is written. ...
...tax :last-of-type Examples Styling the last paragraph HTML <h2>Heading</h2> <p>Paragraph 1</p> <p>Paragraph 2</p> CSS p:last-of-type { color: red; font-style: italic; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector (*) is implied when no simple selector is written. ...
...And 2 more matches
animation-fill-mode - CSS: Cascading Style Sheets
fill-mode>#where <single-animation-fill-mode> = none | forwards | backwards | both Examples You can see the effect of animation-fill-mode in the following example. It demonstrates how, for an animation that runs for an infinite time, you can cause it to remain in its final state rather than reverting to the original state (which is the default). ...
...ngle-animation-fill-mode> = none | forwards | backwards | both Examples You can see the effect of animation-fill-mode in the following example. It demonstrates how, for an animation that runs for an infinite time, you can cause it to remain in its final state rather than reverting to the original state (which is the default). ...
...ds | both Examples You can see the effect of animation-fill-mode in the following example. It demonstrates how, for an animation that runs for an infinite time, you can cause it to remain in its final state rather than reverting to the original state (which is the default). ...
...And 2 more matches
bottom - CSS: Cascading Style Sheets
ied as a percentage, the specified value; otherwise, autoAnimation typea length, percentage or calc(); Formal syntax <length> | <percentage> | auto Examples Absolute and fixed positioning This example demonstrates the difference in behavior of the bottom property, when position is absolute versus fixed. ...
...ed value; otherwise, autoAnimation typea length, percentage or calc(); Formal syntax <length> | <percentage> | auto Examples Absolute and fixed positioning This example demonstrates the difference in behavior of the bottom property, when position is absolute versus fixed. ...
...ue; otherwise, autoAnimation typea length, percentage or calc(); Formal syntax <length> | <percentage> | auto Examples Absolute and fixed positioning This example demonstrates the difference in behavior of the bottom property, when position is absolute versus fixed. ...
...And 2 more matches
box-align - CSS: Cascading Style Sheets
tch; /* Global values */ box-lines: inherit; box-lines: initial; box-lines: unset; The direction of layout depends on the element's orientation: horizontal or vertical. Syntax The box-align property is specified as one of the keyword values listed below. Values start The box aligns contents at the start, leaving any extra space at the end. center The box aligns contents in the center,
dividing any extra space equally between the start and the end. end The box aligns contents at the end, leaving any extra space at the start. baseline The box aligns the baselines of the contents (lining up the text). This only applies if the box's orientation is horizontal. stretch The box stretches the contents so that there is no extra space in the box. Notes The edge of the box designate...
... set using the element's align attribute, then the style is ignored. ...
... Bro...
...And 2 more matches
box-sizing - CSS: Cascading Style Sheets
ding + height of the content. Formal definition Initial valuecontent-boxApplies toall elements that accept width or heightInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax content-box | border-box Examples Box sizes with content-box and border-box This example shows how different box-sizing values alter the rendered size of two otherwise identical elements. ...
...l definition Initial valuecontent-boxApplies toall elements that accept width or heightInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax content-box | border-box Examples Box sizes with content-box and border-box This example shows how different box-sizing values alter the rendered size of two otherwise identical elements. ...
...n Initial valuecontent-boxApplies toall elements that accept width or heightInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax content-box | border-box Examples Box sizes with content-box and border-box This example shows how different box-sizing values alter the rendered size of two otherwise identical elements. ...
...And 2 more matches
calc() - CSS: Cascading Style Sheets
/* property: calc(expression) */ width: calc(100% - 80px); The calc() function takes a single expression as its parameter, with the expression's result used as the value. The expression can be any simple expression combining the following operators, using standard operator precedence rules: + Addition. - Subtraction. * Multiplication. At least one of the arguments must be a <number>. /
Division. The right-hand side must be a <number>. The operands in the expression may be any <length> syntax value. You can use different units for each value in your expression, if you wish. You may also use parentheses to establish computation order when needed. Notes The + and - operators must be surrounded by whitespace. For instance, calc(50% -8px) will be parsed as a percentage followed by...
...will be parsed as a percentage followed by a negative length -- an invalid expression -- while calc(50% - 8px) is a percentage followed by a subtraction operator and a length. Likewise, calc(8px + -50%) is treated as a length followed by an addition operator and a negative percentage. The * and / operators do not require whitespace, but adding it for consistency is both allowed and recommended.
Division by zero results in an error being generated by the HTML parser. Math expressions involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables may be treated as if auto had been specified. It is permitted to nest calc() functions, in which case the inner ones are treated as simple paren...
...s Criterion 1.4.4 | W3C Understanding WCAG 2.0 Usage with integers When calc() is used where an <integer> is expected, the value will be rounded to the nearest integer. For example: .modal { z-index: calc(3 / 2); } This will give .modal a final z-index value of 2. Note: The Chrome browser currently won't accept some values returned by calc() when an integer is expected. This includes any
division, even if it results in an integer. ie. z-index: calc(4 / 2); will not be accepted. Examples Positioning an object on screen with a margin calc() makes it easy to position an object with a set margin. In this example, the CSS creates a banner that stretches across the window, with a 40-pixel gap between both sides of the banner and the edges of the window: .banner { position: absolute;...
...And 2 more matches
element() - CSS: Cascading Style Sheets
ageElement() method to change the element being used as the background for a given CSS background element. Syntax element(id) where: id The ID of an element to use as the background, specified using the HTML attribute #id on the element. Examples These examples can be viewed live in builds of Firefox that support -moz-element(). ...
...ere: id The ID of an element to use as the background, specified using the HTML attribute #id on the element. Examples These examples can be viewed live in builds of Firefox that support -moz-element(). A somewhat realistic example This example uses a hidden <
div> as a background. The background element uses a gradient, but also includes text that is rendered as part of the background. ...
...irefox that support -moz-element(). A somewhat realistic example This example uses a hidden <
div> as a background. The background element uses a gradient, but also includes text that is rendered as part of the background. <
div style="width:400px; height:400px; background:-moz-element(#myBackground1) no-repeat;"> <p>This box uses the element with the #myBackground1 ID as its background!</p> </
div> <
div style="overflow:hidden; height:0;"> <
div id="myBackground1" style="width:1024px; height:1024px; background-image: linear-gradient(to right, red, orange, yellow, white);"> <p style="transform-origin:0 0; transform: rotate(45deg); color:white;">This text is part of the background. ...
...And 2 more matches
font-kerning - CSS: Cascading Style Sheets
ext. normal Font kerning information stored in the font must be applied. none Font kerning information stored in the font is disabled. Formal definition Initial valueautoApplies toall elements. ...
...nt kerning information stored in the font must be applied. none Font kerning information stored in the font is disabled. Formal definition Initial valueautoApplies toall elements. ...
...ning information stored in the font must be applied. none Font kerning information stored in the font is disabled. Formal definition Initial valueautoApplies toall elements. ...
...And 2 more matches
overscroll-behavior-block - CSS: Cascading Style Sheets
it so it sits comforably inside the viewport, but its content is given a large height so it will also scroll vertically. By default, when the inner box is scrolled and a scroll boundary is reached, the whole page will begin to scroll, which is probably not what we want. To avoid this happening in the block direction, we've set overscroll-behavior-block: contain on the inner box. ...
...its comforably inside the viewport, but its content is given a large height so it will also scroll vertically. By default, when the inner box is scrolled and a scroll boundary is reached, the whole page will begin to scroll, which is probably not what we want. To avoid this happening in the block direction, we've set overscroll-behavior-block: contain on the inner box. ...
...ge will begin to scroll, which is probably not what we want. To avoid this happening in the block direction, we've set overscroll-behavior-block: contain on the inner box. ...
...And 2 more matches
overscroll-behavior-inline - CSS: Cascading Style Sheets
so it sits comforably inside the viewport, but its content is given a large width so it will also scroll horizontally. By default, when the inner box is scrolled and a scroll boundary is reached, the whole page will begin to scroll, which is probably not what we want. To avoid this happening in the inline direction, we've set overscroll-behavior-inline: contain on the inner box. ...
... comforably inside the viewport, but its content is given a large width so it will also scroll horizontally. By default, when the inner box is scrolled and a scroll boundary is reached, the whole page will begin to scroll, which is probably not what we want. To avoid this happening in the inline direction, we've set overscroll-behavior-inline: contain on the inner box. ...
...will begin to scroll, which is probably not what we want. To avoid this happening in the inline direction, we've set overscroll-behavior-inline: contain on the inner box. ...
...And 2 more matches
repeating-conic-gradient() - CSS: Cascading Style Sheets
the image represented by the conic gradient will not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document. ...
...t will not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document. ...
... not be accessible to screen reader users. If the image contains information critical to understanding the page's overall purpose, it is better to describe it semantically in the document. ...
...And 2 more matches
skew() - CSS: Cascading Style Sheets
value is 0, resulting in a purely horizontal skewing. ...
... resulting in a purely horizontal skewing. ...
...ting in a purely horizontal skewing. ...
...And 2 more matches
transform-origin - CSS: Cascading Style Sheets
a percentageAnimation typesimple list of length, percentage, or calc Formal syntax [ <length-percentage> | left | center | right | top | bottom ] | [ [ <length-percentage> | left | center | right ] && [ <length-percentage> | top | center | bottom ] ] <length>?where <length-percentage> = <length> | <percentage> Examples Code Sample transform: none; <
div class="box1"> </
div> .box1 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform: none; -webkit-transform: none; } transform: rotate(30deg); <
div class="box2"> </
div> .box2 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform: rotate(...
...-webkit-transform: none; } transform: rotate(30deg); <
div class="box2"> </
div> .box2 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform: rotate(30deg); -webkit-transform: rotate(30deg); } transform: rotate(30deg); transform-origin: 0 0; <
div class="box3"> </
div> .box3 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform-origin: 0 0; -webkit-transform-origin: 0 0; transform: rotate(30deg); -webkit-transform: rotate(30deg); } transform: rotate(30deg); transform-origin: 100% 100%; <
div class="box4"> </
div> .box4 { ...
...100% 100%; <
div class="box4"> </
div> .box4 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform-origin: 100% 100%; -webkit-transform-origin: 100% 100%; transform: rotate(30deg); -webkit-transform: rotate(30deg); } transform: rotate(30deg); transform-origin: -1em -3em; <
div class="box5"> </
div> .box5 { margin: 0.5em; width: 3em; height: 3em; border: solid 1px; background-color: palegreen; transform-origin: -1em -3em; -webkit-transform-origin: -1em -3em; transform: rotate(30deg); -webkit-transform: rotate(30deg); } transform: scale(1.7); <
div class="box6"> </
div> .box6 { margin: 0.5em; width: 3em...
...And 2 more matches
transition-timing-function - CSS: Cascading Style Sheets
Values <timing-function> Each <timing-function> represents the timing function to link to the corresponding property to transition, as defined in transition-property. The non-step keyword values (ease, linear, ease-in-out, etc.) each represent cubic Bezier curve with fixed four point values, with the cubic-bezier() function value allowing for a non-predefined value. The step timing functions
divides the input time into a specified number of intervals that are equal in length. It is defined by a number of steps and a step position. ease Equal to cubic-bezier(0.25, 0.1, 0.25, 1.0), the default value, increases in velocity towards the middle of the transition, slowing back down at the end. linear Equal to cubic-bezier(0.0, 0.0, 1.0, 1.0), transitions at an even speed. ease-in ...
...r>, <number <a href="/docs/CSS/Value_definition_syntax#Brackets" title="Brackets: enclose several entities, combinators, and multipliers to transform them as a single component">[0,1]>, <number>)<step-timing-function> = step-start | step-end | steps(<integer>[, <step-position>]?)where <step-position> = jump-start | jump-end | jump-none | jump-both | start | end Examples Cubic-Bezier examples <
div class="parent"> <
div class="ease">ease</
div> <
div class="easein">ease-in</
div> <
div class="easeout">ease-out</
div> <
div class="easeinout">ease-in-out</
div> <
div class="linear">linear</
div> <
div class="cb">cubic-bezier(0.2,-2,0.8,2)</
div> </
div> .parent {} .parent >
div[class] { width: 12em; min-width: 12em; margin-bottom: 4px; background-color: black; border: 1px ...
...seout">ease-out</
div> <
div class="easeinout">ease-in-out</
div> <
div class="linear">linear</
div> <
div class="cb">cubic-bezier(0.2,-2,0.8,2)</
div> </
div> .parent {} .parent >
div[class] { width: 12em; min-width: 12em; margin-bottom: 4px; background-color: black; border: 1px solid red; color: white; transition-property: all; transition-duration: 7s; } .parent >
div.box1{ width: 90vw; min-width: 24em; background-color: magenta; color: yellow; border: 1px solid orange; transition-property: all; transition-duration: 2s; } function updateTransition() { var els = document.querySelectorAll(".parent >
div[class]"); for(var c = els.length, i = 0; i < c; i++) { els[i].classList.toggle("box1"); } } var intervalID = window.set...
...And 2 more matches
Video player styling basics - Developer guides
Preliminary modifications from the original example This section summarises the modifications that were made to the original video player example to make the styling task easier, before the bulk of the work was started. HTML Markup There are a few changes that were made to the HTML markup shown in the previous article. ...
...l video player example to make the styling task easier, before the bulk of the work was started. HTML Markup There are a few changes that were made to the HTML markup shown in the previous article. The custom video controls and <progress> element are now contained within <
div> elements, rather than residing inside unordered list items. ...
...video controls and <progress> element are now contained within <
div> elements, rather than residing inside unordered list items. ...
...And 2 more matches
HTML attribute: pattern - HTML: Hypertext Markup Language
Specifying a pattern You can use the pattern attribute to specify a regular expression that the inputted value must match in order to be considered valid (see Validating against a regular expression for a simple crash course on using regular expressions to validate inputs). The example below restricts the value to 4-8 characters and requires that it contain only lower-case letters. ...
...w restricts the value to 4-8 characters and requires that it contain only lower-case letters. ...
...cts the value to 4-8 characters and requires that it contain only lower-case letters. ...
...And 2 more matches
<input type="url"> - HTML: Hypertext Markup Language
of their pages has a problem. In our simplified form, the user needs to enter the URL of the page that has a problem, and a message describing what is wrong. But we want the URL to only successfully validate if the entered URL is in a Myco domain. Since inputs of type url validate against both the standard URL validation and the specified pattern, you can implement this easily. ...
...u can implement this easily. ...
... Second, in the url input we set pattern to ".
...And 2 more matches
<shadow>: The obsolete Shadow Root element - HTML: Hypertext Markup Language
lement Attributes This element includes the global attributes. Example Here is a simple example of using the <shadow> element. It is an HTML file with everything needed in it. Note: This is an experimental technology. For this code to work, the browser you display it in must support Web Components. See Enabling Web Components in Firefox. ...
...ncludes the global attributes. Example Here is a simple example of using the <shadow> element. It is an HTML file with everything needed in it. Note: This is an experimental technology. For this code to work, the browser you display it in must support Web Components. See Enabling Web Components in Firefox. <html> <head></head> <body> <!-- This <
div> will hold the shadow roots. ...
...ement. It is an HTML file with everything needed in it. Note: This is an experimental technology. For this code to work, the browser you display it in must support Web Components. See Enabling Web Components in Firefox. <html> <head></head> <body> <!-- This <
div> will hold the shadow roots. ...
...And 2 more matches
Using templates and slots - Web Components
However, it is generally more practical to add slots within a <template> element, since you are unlikely to need to define a pattern based on an already-rendered element.
...cal to add slots within a <template> element, since you are unlikely to need to define a pattern based on an already-rendered element. In addition, even if it is not already rendered, the purpose of the container as a template should be more semantically clear when using the <template>. In addition, <template> can have items directly added to it, like <td>, which would disappear when added to a <
div>. Note: You can find this complete example at element-details (see it running live also). Creating a template with some slots First of all, we use the <slot> element within a <template> element to create a new "element-details-template" document fragment containing some named slots: <template id="element-details-template"> <style> details {font-family: "Open Sans Light",Helvetica,Arial}...
... The <template> uses <slot> and its name attribute to make three...
...And 2 more matches
dev/panel - Archive of obsolete content
This module is new in Firefox 34. Note that at the moment you can't debug remote targets (for example, Firefox OS, the Firefox OS Simulator, or Firefox for Android) using tools developed with this API. We're working on removing this restriction. Enables you to extend the Firefox Developer Tools. Most of the Firefox Developer Tools are hosted in a UI component called the Toolbox. In
dividual built-in tools, such as the JavaScript Debugger or the Web Console, occupy "panels" in the toolbox. With the dev/panel module, you can create your own panels in the Toolbox: The panel gets a tab in the Toolbox toolbar which enables the user to open it: You specify the panel's content and behavior using HTML, CSS, and JavaScript. When the panel's created, the framework passes it a debuggee:...
...However, it can receive messages from the add-on that created it, and the add-on can pass it the debuggee so it can communicate with the debugger server the developer tools are targeting. Communicating with the panel document The main add-...
...However, it can receive messages from the add-on that created it, and the add-on can pass it the debuggee so it can communicate with the debugger server the developer tools are targeting. Communicating with the panel document The main add-on code can't direc...
... not support the complete remote debugging protocol. We're still working on documenting exactly which messages are supported by volcan.js. To use volcan.js, you can just include it from your panel's HTML like this: <html> <head> <meta charset="utf-8"> <link href="./my-panel.css"rel="stylesheet"></link> <script src="resource://sdk/dev/volcan.js"></script> </head> <body> <
div id = "content"></
div> </body> <script src="./my-panel.js"></script> </html> Here's a script that uses volcan.js to get the selected tab and display its URL: // my-panel.js var content = document.getElementById("content"); window.addEventListener("message", function(event) { var debuggee = event.ports[0]; volcan.connect(debuggee). then(listTabs). then(writeTabList); }); functi...
Multiple item extension packaging - Archive of obsolete content
wn below: /install.rdf Install Manifest /extension1.xpi Extension /extension2.xpi Extension /theme1.jar Theme /theme2.jar Theme ... The Extension Manager will read the install.rdf Install Manifest to determine if this is a Multiple Item Package and then start the installation of the in
dividual packages it contains automatically. No other files besides the install.rdf Install Manifest and the files with a jar and xpi file extension will be extracted or utilized. install.rdf A multiple item package does not have the same requirements as an extension for its install.rdf. The only required properties are em:id, em:targetApplication, and em:type. For the Firefox and Thunderbird 1.5 ...
...le item package for the em:targetApplication. If this is not done, any items that are not compatible will not be installed unless a compatibility check discovers updated compatibility information. Installation Installation can be performed using any of the existing methods used for installing extensions / themes. The same user interface is used for installing a multiple item package (i.e. ...
... any of the existing methods used for installing extensions / themes. The same user interface is used for installing a multiple item package (i.e. the in
dividual packages contained in the multiple item package will not be listed). This also allows displaying of signing information for the multiple item package. If a manager (e.g. extension / theme manager) is used, the manager will display the in
dividual items contained by the multiple item package after the download completes in the same manner that it would if the user had chosen to install multiple in
dividual items simultaneously. The manager will not display the multiple item package in the list of items after the download has completed. Signing All extensions now require signing by Mozilla. For multiple item packages, all internal add...
...Additionally, the container add-on ID must not be the same as the ID of any of the contained add-ons. Official References for Toolkit API Official References. Do not add to this list without contacting Benjamin Smedberg. Note that this page is included from the pages listed below. ...
JXON - Archive of obsolete content
bjects, you can uncomment the following code from the JXON library: /* Uncomment the following code if you want to enable the .appendJXON() method for *all* the "element" objects! ...
...the following code from the JXON library: /* Uncomment the following code if you want to enable the .appendJXON() method for *all* the "element" objects! ...
...press": "return numbersOnly(this, event);", "@onpaste": "return false;" } } }] }, "p": { "input": { "@type": "submit", "@value": "Purchase!" } }, "@action": "https://secure-test.worldpay.com/wcc/purchase", "@name": "BuyForm", "@method": "POST" } }); will populate the previous element in the following way: <
div id="form_container"> <form action="https://secure-test.worldpay.com/wcc/purchase" name="BuyForm" method="POST"> <script type="text/javascript"> function numbersOnly(oToCheckField, oKeyEvent) { return oKeyEvent.charCode === 0 || /\d/.test(String.fromCharCode(oKeyEvent.charCode)); } </script> <input type="hidden" name="instId" value="1234" /> <input type="hidde...
...="pullover"/><label for="rel_pullover">Pullover</label></span> </td> </tr> <tr> <th style="text-align: right;">Quantity:</th> <td> <input type="text" name="myInput" onkeypress="return numbersOnly(this, event);" onpaste="return false;" /> </td> </tr> </table> <p> <input type="submit" value="Purchase!" /> </p> </form> </
div> Other examples Example #1: How to use JXON to create an HTML document instead of an XML document: /* The structure of my document */ var oMyHTMLStruct = { "html": { "head": { "meta": { "@http-equiv": "Content-Type", "@content": "text/html; charset=UTF-8" }, "title": "My HTML Document", "script": { "@type": "text/javascript", "keyVa...
MMgc - Archive of obsolete content
s) [mem] mark(1) 0 objects (180866 kb 205162 mb/s) in 0.88 millis (2.5195 s) [mem] DRC reaped 114040 objects (3563 kb) freeing 903 pages (7800 kb) in 17.41 millis (2.0015 s) How MMgc works Mark/Sweep The MMgc garbage collector uses a mark/sweep algorithm. This is one of the most common garbage collection algorithms. Every object in the system has an associated "mark bit." A garbage collection is
divided into two phases: Mark and Sweep. In the Mark phase, all of the mark bits are cleared. The garbage collector is aware of "roots", which are starting points from which all "live" application data should be reachable. The collector starts scanning objects, starting at the roots and fanning outwards. For every object it encounters, it sets the mark bit. When the Mark phase concludes, the Sweep ph...
...o the black object we only needed one push on the the queue. This could be a significant speedup if the black object was a large array getting populated with a bunch of new objects. On the other hand if the black is a huge array and only a couple slots had new objects written to them we are wasting time by marking the whole thing. A popular solution to this is what's called card marking. Here you
divide memory into "cards" and when a white object is written to a black object you mark the card containing the slot the pointer to the white object was written to. After all marking is done you circle back and remark the black portion of any card that was flagged by the write barrier. There are two techniques to optimize this process. One is to save all the addresses of all pages that had cards mar...
...ave to bring every page into memory to check its hand, so to speak). Another option is to check every page while doing the normal marking and it any of its cards where flagged handle them immediately since your already reading/writing from that page. The result will be at the end of the mark cycle fewer things need to be marked. These two optimizations can be combined. Increment Time Slice Before
diving into the this it should be acknowledged that another way to go about this is to use a background thread and not worry about incremental marking. This approach was not chosen for the following reasons: Coordinating the marking thread and the main thread will require locking and may suffer due to lock overhead/contention Supporting Mac classic's cooperative threads makes this approach harder Fl...
...tly we make the decision on when to do a collection based on how much memory has been allocated since the last collection, if its over a certain fraction of the the total heap size we do a collection and if its not we expand. Similarly we can base the decision on when to start marking when we've consumed a certain portion of the heap since the last collection, call this the ISD (incremental start
divisor). So if we go with an ISD of 4 we start marking when a quarter of the heap is left and an ISD of 1 means we're always marking. Now that we know when we start marking there are two conflicting goals to achieve in selecting the marking time slice: Maintain the frame rate Make sure the collector gets to the sweep stage soon enough to avoid too much heap expansion If we don't maintain the frame...
Source code directories overview - Archive of obsolete content
ages. This code originated as the reference implementation for the JPEG specification from the Independent JPEG Group. js contains C code for tokenizing, parsing, interpretting and executing Javascript scripts. This code originated in Mozilla Classic. l10n contains code for building localizations. layout contains the C interfaces and code for the layout engine. The layout engine decides how to
divide up the "window real estate" among all the pieces of content. It resizes and aligns pieces of content according to the CSS1 and CSS2 (cascading style sheets), alignment styles and the content itself. It does not actually render the content; it just assigns different pieces of the window to various content items. This is known as "reflowing" the content. This code is also known by the names, "NG...
...ns C code for various different browsing related features that are built into Mozilla. It contains code for handling various image formats (e.g. .PNG, .GIF), allowing drop-in Java virtual machines (called OJI, for "Open Java Interface"), supporting plug-ins and reading various compression formats (e.g. JAR, ZIP, ZLIB). This code originated from Mozilla as well as various different companies and in
dividual people. netwerk contains C interfaces and code for low-level access to the network (using sockets and file and memory caches) as well as higher-level access (using various protocols such as http, ftp, gopher, castanet). This code is also known by the names, "netlib" and "Necko." nsprpub contains C code for the cross platform "C" Runtime Library. The "C" Runtime Library contains basic non-v...
...ses the mail message to it for display. It is generic and can hand the content off to internal components (like Messenger), to plug-ins or helper apps. view contains C interfaces and code for different types of views (e.g. scrolling view). A view contains content but does not contain the title bar, borders or other decorations (which are contained by frames). This code serves to manipulate the in
dividual content that it contains. For example, a scrolling view will find out the scroll bar positions and tell its content where to draw according the scroll bar thumbs. webshell contains C interfaces, C code, Linux shell scripts and other files for embedding Mozilla in other programs on various different platforms in various different ways (e.g. as plug-in, as ActiveX component, as XPCOM classes)...
...kit things. xreis the XUL runtime engine. This directory contains the code for initializing the toolkit. Original Document Information Author(s): Daniel Howard Other Contributors: Heikki Toivonen (11-Nov-1999), HervA(C) Renault (for the French translation) (16-Nov-1999) Last Updated Date: Michael Kaply 2-June-2005 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. Further History: Document History. ...
Menu - Archive of obsolete content
re: add(items) clear() insertBefore(newItems, target) remove(target) replace(target, newItems) reset() set(items) The following jetpack.Menu properties can also be defined on a ContextMenuSet: beforeHide beforeShow Note that a jetpack.Menu object is passed to beforeHide and beforeShow, since they are called during a context menu's invocation. They may then modify the menu. In
dividual menus are drawn from the set using on(): on(selector) Returns a new ContextMenuSet whose context menus are those that arise from nodes that match the given CSS selector(s). The selector must be a true CSS selector, not a jQuery or other type of pseudo-selector. Note: Selectors don't automatically include the children of nodes they match. For example, jetpack.menu.context.page.on("a[href]")...
...hey have the following properties: Property Description node The DOM node on which the menu is shown. This is the node the user clicked to open the menu. Be careful when dealing with nested nodes. For example, if the user clicks on an image inside a link, this property will be set to the image, not the link. Similarly, if the user clicks a node within a
div, this property will be the node, not the
div. document The content document in which the menu is shown. window The content window in which the menu is shown. Targets Some methods act on existing items within a menu. Existing items are always identified using targets. A target is a string, regular expression, or integer. A string target is cas...
...contextMenu becomes the button's conte...
...kipedia", icon: "http://en.wikipedia.org/favicon.ico", data: "http://en.wikipedia.org/wiki/" } ]), command: function (menuitem) { context.window.location.href = menuitem.data + jetpack.selection.text; } }; }); Create some
div buttons (e.g., in a slidebar or status bar item) and specify their context menu: for (let i = 0; i < 10; i++) { var button = $('<
div class="button" />', document); buttonContainer.append(button); } jetpack.menu.context.on(".button").add(["Do This", "Do That"]); Create a
div button (e.g., in a slidebar or status bar item) and attach menus directly to it. contextMenu becomes the button's context menu. Left-click the button to show popupMenu: var button = $("<
div />", document); button.text("Click Me"); var contextMenu = new j...
Space Manager Detailed Design - Archive of obsolete content
andRect, this);} // Remove and delete all the band rects in the list void Clear(); }; FrameInfo* GetFrameInfoFor(nsIFrame* aFrame); FrameInfo* CreateFrameInfo(nsIFrame* aFrame, const nsRect& aRect); void DestroyFrameInfo(FrameInfo*); void ClearFrameInfo(); void ClearBandRects(); BandRect* GetNextBand(const BandRect* aBandRect) const; void
DivideBand(BandRect* aBand, nscoord aBottom); PRBool CanJoinBands(BandRect* aBand, BandRect* aPrevBand); PRBool JoinBands(BandRect* aBand, BandRect* aPrevBand); void AddRectToBand(BandRect* aBand, BandRect* aBandRect); void InsertBandRect(BandRect* aBandRect); nsresult GetBandAvailableSpace(const BandRect* aBand, nscoord aY, ...
...g bandrects, or the band rect passed in is below the bottommost rect. In this case,just append the band rect and return. Starting at the head of the list of bandRects, check for intersection with the rect passed in: case #1: the rect is totally above the current band rect, so insert a new band rect before the current bandRect cases #2 and #7: the rect is partially above the band rect, so it is
divided into two bandRects, one entirely above the band, and one containing the remainder of the rect. Insert the part that is totally above the bandRect before the current bandRect, as in case #1 above, and adjust the other band rect to exclude the part already added. case #5: the rect is totally below the current bandRect, so just skip to the next band case #3 and #4: rect is at least partially i...
...ely above the band, and one containing the remainder of the rect. Insert the part that is totally above the bandRect before the current bandRect, as in case #1 above, and adjust the other band rect to exclude the part already added. case #5: the rect is totally below the current bandRect, so just skip to the next band case #3 and #4: rect is at least partially intersection with the bandRect, so
divide the current band into two parts, where the top part is above the current rect. Move to the new band just created, which is the next band. case #6: the rect shares the bottom and height with the bandRect,so just add the rect to the band. case #4 and #7: create a new rect for the part that overlaps the bandRect, and add it to the current bandRect (similar to case #6) and then move on to the ne...
... band. case #4 and #7: create a new rect for the part that overlaps the bandRect, and add it to the current bandRect (similar to case #6) and then move on to the next band, removing that part from the rect passed in. If no more bands, append the rect passed in to the end of the bandRect list. This algorithm is pretty confusing - basically what needs to happen is that rects and bands need to be
divided up so that complicated cases like#2, #4, and #7, are reduced to simpler cases where the rects is totally above,below, or between a band rect. From the current implementation, it might be worth verifying that the final result of the inserts is a correctly ordered list of bandRects (debug mode only). Algorithm 3: RemoveRegion When a float is removed, the Space Manager is notified by a call t...
Adding HTML Elements - Archive of obsolete content
ould think that the elements were XUL elements and they would not display because img, input, table, and so on are not valid XUL tags. In XUL, you can add labels with the description or label element. You should use these elements when you can. You can also add labels to controls either by using the HTML label element, or you can simply put the text inside another HTML block element (such as p or
div) as in the example below. Example 1 : Source View <html:p> Search for: <html:input id="find-text"/> <button id="okbutton" label="OK"/> </html:p> This code will cause the text 'Search for:' to be displayed, followed by an input element and an OK button. Notice that the XUL button can appear inside the HTML elements, as it does here. Plain text will only be displayed when placed inside an HT...
...e 2 : Source View <html:p> Click the box below to remember this decision. <html:p> <html:input id="rtd" type="checkbox"/> <html:label for="rtd">Remember This Decision</html:label> </html:p> </html:p> In this case, one p tag was used to place the text in and another was used to break apart the text into multiple lines. Text outside of HTML blocks Example 3 : Source View <html:
div> Would you like to save the following documents? <html:hr/> </html:
div> Expense Report 1 What I Did Last Summer <button id="yes" label="Yes"/> <button id="no" label="No"/> As can be seen in the image, the text inside the
div tag was displayed but the other text (Expense Report 1 and What I Did Last Summer) was not. This is because there is no HTML or XUL element capable of displaying tex...
...v> Expense Report 1 What I Did Last Summer <button id="yes" label="Yes"/> <button id="no" label="No"/> As can be seen in the image, the text inside the
div tag was displayed but the other text (Expense Report 1 and What I Did Last Summer) was not. This is because there is no HTML or XUL element capable of displaying text enclosing it. To have this text appear, you would need to put it inside the
div tag, or enclose the text in a description tag. Note: Due to bug 554290, this text actually does render in Gecko 1.9.2 and later. Invalid HTML elements <html:po>Case 1</html:po> <
div>Case 2</
div> <html:description value="Case 3"/> All three of the cases above will not display, each for a different reason. Case 1 po is not a valid HTML tag and Mozilla has no idea what to do with it. ...
...To get it to work, you will need to add the html: qualifier. ...
-ms-scrollbar-base-color - Archive of obsolete content
ge> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...percentage>, <percentage>, <alpha-value>? ...
...color schemes.
div { width: 150px; height: 150px; border-style: solid; border-width: thin; overflow-y: scroll; font-family: sans-serif; float: left; margin-right: 10px; } .aquaScroll { scrollbar-base-color: aqua; scrollbar-arrow-color: blue; border-color: blue; } .bisqueScroll { scrollbar-base-color: bisque; scrollbar-arrow-color: red; border-color: red; } <body> <
div class="aquaScroll"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> <
div class="bisqueScroll"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. ...
...Note that scrollbar-base-color sets the scroll bar face color and highlight color to different shades of the same base color. ...
XForms Repeat Element - Archive of obsolete content
sure to test your form carefully. ...
...al id="1"> <nest>Nest 1.1</nest> <nest>Nest 1.2</nest> </val> <val id="2"> <nest>Nest 2.1</nest> <nest>Nest 2.2</nest> </val> </data> </xforms:instance> </xforms:model> <
div xforms:repeat-nodeset="val"> This is the inline content, just text. Here comes the output: <br/> <xf:output ref="@id"><xf:label>Output: </xf:label></xf:output> <
div xf:repeat-nodeset="nest"><xf:output ref="."><xf:label>Nested output: </xf:label></xf:output></
div> </
div> Repeat in anonymous content (usage in XBL) You can use repeat elements inside anonymous content to create powerful new widgets. In this scenario, though, you should use the anonid attribute to identify the repeat element that has been placed inside anonymous content. <head> <xbl:binding...
...tent> <xf:repeat xbl:inherits="bind, model, nodeset" anonid="anonidGridRepeat"> <xf:trigger> <xf:label>R</xf:label> <xf:delete ev:event="DOMActivate" at="index('anonidGridRepeat')" xbl:inherits="model, bind, nodeset"/> </xf:trigger> </xf:repeat> </xbl:content> </xbl:binding> </xbl:bindings> <style>
div.grid { -moz-binding: url('#grid'); } </style> <xf:model> <xf:instance> <data xmlns=""> <repeat> <item> <input>Input1</input> </item> <item> <input>Input2</input> </item> <item> <input>Input3</input> </item> </repeat> </data> </xf:instance> </xf:mode...
... <item> <input>Input1</input> </item> <item> <input>Input2</input> </item> <item> <input>Input3</input> </item> </repeat> </data> </xf:instance> </xf:model> </head> <body> <xf:repeat nodeset="/data/repeat/item" id="gridRepeat"> <xf:input ref="input"/> </xf:repeat> <br/> <
div class="grid" nodeset="/data/repeat/item"/> </body> ...
Grid Cell - MDN Web Docs Glossary: Definitions of Web-related terms
Additional row or column tracks will be created to create enough cells to hold all items. ...
... will be created to create enough cells to hold all items. In the example we have created a three column track grid. The five items are placed into grid cells working along an initial row of three grid cells, then creating a new row for the remaining two. ...
... for the remaining two. ...
... * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(3,1fr); grid-auto-rows: 100px; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> </
div> Learn More Property reference grid-template-columns grid-template-rows grid-auto-rows grid-auto-columns Further reading CSS Grid Layout Guide: Basic concepts of grid layout Definition of Grid Cells in the CSS Grid Layout specification ...
Speculative parsing - MDN Web Docs Glossary: Definitions of Web-related terms
sing tree builder output Speculative tree building fails when document.write() changes the tree builder state such that the speculative state after the </script> tag no longer holds when all the content inserted by document.write() has been parsed. However, only unusual uses of document.write() cause trouble. Here are the things to avoid: Don't write unbalanced trees. <script>document.write("<
div>");</script> is bad. <script>document.write("<
div></
div>");</script> is OK. Don't write an unfinished token. <script>document.write("<
div></
div");</script> is bad. Don't finish your writing with a carriage return. <script>document.write("Hello World!\r");</script> is bad. <script>document.write("Hello World!\n");</script> is OK. Note that writing balanced tags may cause other tags to be inferr...
... Don't format part of a table. ...
... Don't format part of a table. ...
...r writing with a carriage return. <script>document.write("Hello World!\r");</script> is bad. <script>document.write("Hello World!\n");</script> is OK. Note that writing balanced tags may cause other tags to be inferred in a way that makes the write unbalanced. E.g. <script>document.write("<
div></
div>");</script> inside the head element will be interpreted as <script>document.write("</head><body><
div></
div>");</script> which is unbalanced. Don't format part of a table. <table><script>document.write("<tr><td>Hello World!</td></tr>");</script></table> is bad. ...
Mobile accessibility - Learn web development
mple.html example (see it running live) to see what we mean. Alternatively, mouse-specific events such as mousedown and mouseup create problems -- their event handlers cannot be invoked using non-mouse controls. If you try to control our simple-box-drag.html (see example live) example with a keyboard or touch, you'll see the problem. ...
...what we mean. Alternatively, mouse-specific events such as mousedown and mouseup create problems -- their event handlers cannot be invoked using non-mouse controls. If you try to control our simple-box-drag.html (see example live) example with a keyboard or touch, you'll see the problem. ...
...use-specific events such as mousedown and mouseup create problems -- their event handlers cannot be invoked using non-mouse controls. If you try to control our simple-box-drag.html (see example live) example with a keyboard or touch, you'll see the problem. ...
...e with a keyboard or touch, you'll see the problem. This occurs because we are using code such as the following:
div.onmousedown = function() { initialBoxX =
div.offsetLeft; initialBoxY =
div.offsetTop; movePanel(); } document.onmouseup = stopMove; To enable other forms of control, you need to use different, yet equivalent events -- for example, touch events work on touchscreen devices:
div.ontouchstart = function(e) { initialBoxX =
div.offsetLeft; initialBoxY =
div.offsetTop; positionHandler(e); movePanel(); } panel.ontouchend = stopMove; We've provided a simple example that shows how to use the mouse and touch events together -- see multi-control-box-drag.html (see the example live also). Note: You can also see fully functional examples showing how to implement differe...
Backgrounds and borders - Learn web development
many values can be passed in at once. .box { background: linear-gradient(105deg, rgba(255,255,255,.2) 39%, rgba(51,56,57,1) 96%) center center / 400px 200px no-repeat, url(big-star.png) center no-repeat, rebeccapurple; } We'll return to how the shorthand works later in the tutorial, but first let's have a look at the different things you can do with backgrounds in CSS, by looking at the in
dividual background properties. Background colors The background-color property defines the background color on any element in CSS. The property accepts any valid <color>. A background-color extends underneath the content and padding box of the element. In the example below, we have used various color values to add a background color to the box, a heading, and a <span> element. Play around with t...
...ackground-position property allows you to choose the position in which the background image appears on the box it is applied to. This uses a coordinate system in which the top-left-hand corner of the box is (0,0), and the box is positioned along the horizontal (x) and vertical (y) axes. Note: The default background-position value is (0,0). The most common background-position values take two in
dividual values -- a horizontal value followed by a vertical value. You can use keywords such as top and right (look up the others on the background-position page): .box { background-image: url(star.png); background-repeat: no-repeat; background-position: top center; } And Lengths, and percentages: .box { background-image: url(star.png); background-repeat: no-repeat; background-posi...
...d 10px from the right: .box { background-image: url(star.png); background-repeat: no-repeat; background-position: top 20px right 10px; } Use the example below to play around with these values and move the star around inside the box. Note: background-position is a shorthand for background-position-x and background-position-y, which allow you to set the different axis position values in
dividually. Gradient backgrounds A gradient -- when used for a background -- acts just like an image and is also set by using the background-image property. You can read more about the different types of gradients and things you can do with them on the MDN page for the <gradient> data type. A fun way to play with gradients is to use one of the many CSS Gradient Generators available on the web, su...
...e will look at how to use borders creatively. Typically when we add borders to an element with CSS we use a shorthand property that sets the color, width, and style of the border in one line of CSS. We can set a border for all four sides of a box with border: .box { border: 1px solid black; } Or we can target one edge of the box, for example: .box { border-top: 1px solid black; } The in
dividual properties for these shorthands would be: .box { border-width: 1px; border-style: solid; border-color: black; } And for the longhands: .box { border-top-width: 1px; border-top-style: solid; border-top-color: black; } Note: These top, right, bottom, and left border properties also have mapped logical properties that relate to the writing mode of the document (e.g. left-to-r...
Sizing items in CSS - Learn web development
file it is embedding into the page. This size is described as the intrinsic size -- which comes from the image itself. If you place an image on a page and do not change its height and width, either using attributes on the <img> tag or CSS, it will be displayed using that intrinsic size. We have given the image in the example below a border so that you can see the extent of the file. An empty <
div> however, has no size of its own. If you add a <
div> to your HTML with no content, then give it a border as we did with the image, you will see a line on the page. This is the collapsed border on the element -- there is no content to hold it open. In our example below, that border stretches to the width of the container, because it is a block level element, a behavior that should be starting to b...
...he width of the container, because it is a block level element, a behavior that should be starting to become familiar to you. It has no height (or size in the block dimension) because there is no content. In the example above, try adding some text inside the empty element. The border now contains that text because the height of the element is defined by the content. ...
...As we discovered in our previous lesson on overflow, a set height can cause content to overflow if there is more content than the element has space to fit inside it. ...
...units, they can often be used interchangeably with lengths. When using a percentage you need to be aware what it is a percentage of. In the case of a box inside another container, if you give the child box a percentage width it will be a percentage of the width of the parent container. This is because percentages resolve against the size of the containing block. With no percentage applied our <
div> would take up 100% of the available space, as it is a block level element. If we give it a percentage width, this becomes a percentage of the space it would normally fill. Percentage margins and padding If you set margins and padding as a percentage, you may notice some strange behavior. In the below example we have a box. We have given the inner box a margin of 10% and a padding of 10%. The p...
Practical positioning examples - Learn web development
art with, we'd like you to make a local copy of the starting HTML file -- info-box-start.html. Save this somewhere sensible on your local computer, and open it up in your text editor. Let's look at the HTML contained within the body: <section class="info-box"> <ul> <li><a href="#" class="active">Tab 1</a></li> <li><a href="#">Tab 2</a></li> <li><a href="#">Tab 3</a></li> </ul> <
div class="panels"> <article class="active-panel"> <h2>The first tab</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque turpis nibh, porttitor nec venenatis eu, pulvinar in augue. Vestibulum et orci scelerisque, vulputate tellus quis, lobortis dui. Vivamus varius libero at ipsum mattis efficitur ut nec nisl. Nullam eget tincidunt metus. Donec ultrices, urna...
... <h2>The third tab</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque turpis nibh, porttitor nec venenatis eu, pulvinar in augue. And now an ordered list: how exciting!</p> <ol> <li>dui neque eleifend lorem, a auctor libero turpis at sem.</li> <li>Aliquam ut porttitor urna.</li> <li>Nulla facilisi</li> </ol> </article> </
div> </section> So here we've got a <section> element with a class of info-box, which contains a <ul> and a <
div>. The unordered list contains three list items with links inside, which will become the actual tabs to click on for displaying our content panels. The
div contains three <article> elements, which will make up the content panels that correspond to each tab. Each panel contains some sample ...
...t this using JavaScript when a tab is clicked on. Place the following CSS below your other styles: .info-box li a:focus, .info-box li a:hover { background-color: #a60000; color: white; } .info-box li a.active { background-color: #a60000; color: white; } Styling the panels The next job is to style our panels. Let's get going! First, of all, add the following rule to style the .panels <
div> container. Here we simply set a fixed height to make sure the panels fit snugly inside the info-box, position relative to set the <
div> as the positioning context, so you can then place positioned child elements relative to it and not the <html> element, and finally we clear the float set in the CSS above so that it doesn't interfere with the remainder of the layout. .info-box .panels { heigh...
...o-box, position relative to set the <
div> as the positioning context, so you can then place positioned child elements relative to it and not the <html> element, and finally we clear the float set in the CSS above so that it doesn't interfere with the remainder of the layout. .info-box .panels { height: 352px; position: relative; clear: both; } Finally for this section, we will style the in
dividual <article> elements that comprise our panels. The first rule we'll add will absolutely position the panels, and make them all sit flush to the top and left of their <
div> container -- this part is absolutely key to this whole layout feature, as it makes the panels sit on top of one another. The rule also gives the panels the same set height as the container, and gives the content some padding...
Supporting older browsers - Learn web development
if a floated item, for example, is also a Grid Item using CSS Grid Layout. Couple this information with the knowledge that browsers ignore CSS that they don't understand, and you have a way to create simple layouts using the legacy techniques we have already covered, which are then overwritten by your Grid layout in modern browsers that understand it. In the below example, we have floated three <
div>s so they display in a row. Any browser that does not support CSS Grid Layout will see the row of boxes as a floated layout. A floated item that becomes a grid item loses the float behaviour, which means that by turning the wrapper into a Grid Container, the floated items become Grid Items. If the browser supports Grid Layout it will display the grid view, if not it ignores the display: grid and ...
...it will display the grid view, if not it ignores the display: grid and related properties and the floated layout is used. * {box-sizing: border-box;} .wrapper { background-color: rgb(79,185,227); padding: 10px; max-width: 400px; display: grid; grid-template-columns: 1fr 1fr 1fr; } .item { float: left; border-radius: 5px; background-color: rgb(207,232,220); padding: 1em; } <
div class="wrapper"> <
div class="item">Item One</
div> <
div class="item">Item Two</
div> <
div class="item">Item Three</
div> </
div> Note: The clear property also has no effect once the cleared item becomes a grid item, so you could have a layout with a cleared footer, which is then turned into a Grid Layout. Fallback Methods There are a number of layout methods which can be used in a simi...
...em is placed in, so it actually becomes a third of the size we want once the Grid Layout is introduced. * {box-sizing: border-box;} .wrapper { background-color: rgb(79,185,227); padding: 10px; max-width: 400px; display: grid; grid-template-columns: 1fr 1fr 1fr; } .item { float: left; border-radius: 5px; background-color: rgb(207,232,220); padding: 1em; width: 33.333%; } <
div class="wrapper"> <
div class="item">Item One</
div> <
div class="item">Item Two</
div> <
div class="item">Item Three</
div> </
div> To deal with this issue we need to have a way to detect if Grid is supported and therefore if it will override the width. CSS has a solution for us here. Feature queries Feature queries allow you to test whether a browser supports any particular CSS feature. Th...
... if we know that we have grid support. * {box-sizing: border-box;} .wrapper { background-color: rgb(79,185,227); padding: 10px; max-width: 400px; display: grid; grid-template-columns: 1fr 1fr 1fr; } .item { float: left; border-radius: 5px; background-color: rgb(207,232,220); padding: 1em; width: 33.333%; } @supports (display: grid) { .item { width: auto; } } <
div class="wrapper"> <
div class="item">Item One</
div> <
div class="item">Item Two</
div> <
div class="item">Item Three</
div> </
div> Support for feature queries is very good across modern browsers, however, you should note that it is the browsers that do not support CSS Grid, which also doesn't support feature queries. This means that an approach as detailed above will work for those browsers.
Example 1 - Learn web development
This is the first example of code that explains how to build a custom form widget. ...
... This is the first example of code that explains how to build a custom form widget. ...
...: .2em solid #000; border-top-width : .1em; border-radius: 0 0 .4em .4em; box-shadow: 0 .2em .4em rgba(0,0,0,.4); box-sizing : border-box; min-width : 100%; max-height: 10em; /* 100px */ overflow-y: auto; overflow-x: hidden; } .select .option { padding: .2em .3em; } .select .highlight { background: #000; color: #FFFFFF; } Result for basic state Active state HTML <
div class="select active"> <span class="value">Cherry</span> <ul class="optList hidden"> <li class="option">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> CSS /* --------------- */ /* Required Styles */ /* --------------- */ .select { position: relative; display : i...
...er: .2em solid #000; border-top-width : .1em; border-radius: 0 0 .4em .4em; box-shadow: 0 .2em .4em rgba(0,0,0,.4); box-sizing : border-box; min-width : 100%; max-height: 10em; /* 100px */ overflow-y: auto; overflow-x: hidden; } .select .option { padding: .2em .3em; } .select .highlight { background: #000; color: #FFFFFF; } Result for active state Open state HTML <
div class="select active"> <span class="value">Cherry</span> <ul class="optList"> <li class="option highlight">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> CSS /* --------------- */ /* Required Styles */ /* --------------- */ .select { position: relative; display ...
Eclipse CDT
dex". However, you may find this too disruptive, since re-indexing will then happen very frequently and code assistance can be broken while the index is rebuilding. The alternative is to leave that option disabled and update the index manually as necessary. To update the index manually, use the context menu in the Project Explorer tab on the left side of the window. To rebuild for changes in an in
dividual directory (for example, to take account of some changes that you yourself made) select "Index > Freshen All Files" on that directory. To rebuild the entire index (for example when you pull from mozilla-central) select "Index > Rebuild" on the project root. Usage tips Below are some of the more useful user tips. (If you're thinking of adding tips, please first consider how widely useful the...
...ipse user guide and Eclipse CDT user guide. Keyboard shortcuts Regarding key bindings (keyboard shortcuts), the bindings given below are the defaults. You can change the key bindings by opening the workspace preferences (Eclipse > Preferences, or Window > Preferences) and selecting "General > Keys". You can set the scheme to "Emacs" or "Microsoft Visual Studio" if that's your thing, or change in
dividual key bindings. When changing in
dividual key bindings, note that bindings are context sensitive and that any changes you make may be ignored if they conflict with existing bindings, or if they are overridden by a binding for a more specific context. For example, changing the Find Next command to cmd-G/ctrl-G is not sufficient. For that to work you also either need to find the existing bindings...
...d for will be highlighted (you may need to scroll to it) - double click to see its definition. The results for "Quick Type Hierarchy" will only show those classes in the inheritance tree that override the method. Double click on a class to go straight to its override's definition. Building from Eclipse In short, don't do this. Eclipse doesn't have good facilities for building incrementally in in
dividual directories in the way that Mozilla developers generally require. More importantly, unless you're willing to screw up Eclipse's code assistance (in which case why bother using Eclipse) you're going to have to set Eclipse's "Build" step to do a very slow, non-parallel, full rebuild. (See the "Code assistance" section above for why.) Nevertheless, if you understand the above warning and you s...
...allation Details > Configuration. If they did, then maybe you need to increase the limits still further for your OS/JVM combination. Resource is out of sync with the file system If you get the message "Resource is out of sync with the file system", then you didn't set the "Refresh" options above in the Initial workspace preferences section. Either set those, or else refresh the project (or an in
dividual directory/file) manually using the Refresh item from the context menu in the Project Explorer tab. Old Everything that follows is old content that should maybe just be deleted now? GDB Timeouts I don't think this old comment from 2007/2008 is an issue anymore. Out of the box, you may/will get GDB connection timeouts. This is because Eclipse is trying to push every subfolder in GDB's env...
Performance best practices for Firefox front-end engineers
asks for the size or position of anything. Since everything is pending a reflow, the answer isn't available, so everything stalls until the reflow is complete and the script can be given an answer. Flushing layout also means that styles must be flushed to calculate the most up-to-date state of things, so it's a double-whammy. ...
... is pending a reflow, the answer isn't available, so everything stalls until the reflow is complete and the script can be given an answer. Flushing layout also means that styles must be flushed to calculate the most up-to-date state of things, so it's a double-whammy. Here's a simple example, cribbed from this blog post by Paul Rouget:
div1.style.margin = "200px"; // Line 1 var height1 =
div1.clientHeight; // Line 2
div2.classList.add("foobar"); // Line 3 var height2 =
div2.clientHeight; // Line 4 doSomething(height1, height2); // Line 5 At line 1, we're setting some style information on a DOM node that's going to result in a reflow - but (at just line 1) it's okay, because that reflow will happen after the style calculation. Note line 2 though - we're asking for t...
...M node that's going to result in a reflow - but (at just line 1) it's okay, because that reflow will happen after the style calculation. Note line 2 though - we're asking for the height of some DOM node. This means that Gecko needs to synchronously calculate layout (and styles) using an uninterruptible reflow in order to answer the question that JavaScript is asking ("What is the clientHeight of
div1?"). It's possible for our example to avoid this synchronous, uninterruptible reflow by moving lines 2 and 4 above line 1. Assuming there weren't any style changes requiring size or position recalculation above line 1, the clientHeight information should be cached since the last reflow, and will not result in a new layout calculation. If you can avoid querying for the size or position of things...
... The Gecko profiler add-on is your friend The Gecko profiler is your best friend when diagnosing performance problems and looking for bottlenecks. There's plenty of excellent documentation on MDN about the Gecko profiler: Basic instructions for gathering and sharing a performance profile Advanced profile analysis Don't guess--measure. If you're working ...
overflow-clip-box-block
similar use the value content-box. Note that this property is activated by default only in the UA stylesheet and chrome contexts. Value not found in DB! Syntax Values padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
... stylesheet and chrome contexts. Value not found in DB! Syntax Values padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
... padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
...ng-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
overflow-clip-box-inline
similar use the value content-box. Note that this property is activated by default only in the UA stylesheet and chrome contexts. Value not found in DB! Syntax Values padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
... stylesheet and chrome contexts. Value not found in DB! Syntax Values padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
... padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
...ng-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
overflow-clip-box
elementsInheritednoMediavisualComputed valueas specifiedAnimation typediscreteCanonical orderthe unique non-ambiguous order defined by the formal grammar Syntax Values padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
...nique non-ambiguous order defined by the formal grammar Syntax Values padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
...padding-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
...-box This keyword makes the clipping be related to the padding box. content-box This keyword makes the clipping be related to the content box. ...
NSS tools : signtool
chive (JAR) file to associate the signatures with files in a directory. Electronic software distribution over any network involves potential security problems. To help address some of these problems, you can associate digital signatures with the files in a JAR archive. Digital signatures allow SSL-enabled clients to perform two important operations: * Confirm the identity of the in
dividual, company, or other entity whose digital signature is associated with the files * Check whether the files have been tampered with since being signed If you have a signing certificate, you can use Netscape Signing Tool to digitally sign files and package them as a JAR file. An object-signing certificate is a special kind of certificate that allows you to associate your digi...
...l signature is associated with the files * Check whether the files have been tampered with since being signed If you have a signing certificate, you can use Netscape Signing Tool to digitally sign files and package them as a JAR file. An object-signing certificate is a special kind of certificate that allows you to associate your digital signature with one or more files. An in
dividual file can potentially be signed with multiple digital signatures. For example, a commercial software developer might sign the files that constitute a software product to prove that the files are indeed from a particular company. A network administrator manager might sign the same files with an additional digital signature based on a company-generated certificate to indicate tha...
... following example will do this and that Listing Available Signing Certificates You use the -L option to list the nicknames for all available certificates and check which ones are signing certificates. signtool -L using certificate directory: /u/jsmith/.netscape S Certificates - ------------ BBN Certificate Services CA Root 1 IBM World Registry CA VeriSign Class 1 CA - In
dividual Subscriber - VeriSign, Inc. GTE CyberTrust Root CA Uptime Group Plc. Class 4 CA * Verisign Object Signing Cert Integrion CA GTE CyberTrust Secure Server CA AT&T Directory Services * test object signing cert Uptime Group Plc. Class 1 CA VeriSign Class 1 Primary CA - ------------ Certificates that can be used to sign objects have *'s to their left. Two signing cer...
...n the following example, the user input is in boldface: signtool -G MyTestCert using certificate directory: /u/someuser/.netscape Enter certificate information. All fields are optional. Acceptable characters are numbers, letters, spaces, and apostrophes. certificate common name: Test Object Signing Certificate organization: Netscape Communications Corp. ...
JIT Optimization Strategies
GetProperty_ArgumentsLength Attempts to optimize an arguments.length property access. This optimization only works if the arguments object is used in well-understood ways within the function. The function containing the arguments.length is allowed to use the arguments object in the following ways without disabling this optimization: Access arguments.length Access arguments.callee Access in
dividual args using arguments[i] Save arguments into variables, as long as those variables cannot be accessed by any nested function, and as long as there exists no eval anywhere within the function or nested function definitions. Call a function using f.apply(obj, arguments) If the function contains any use of the arguments object that falls out of the cases defined above, this optimization will...
...ve). GetProp_ArgumentsCallee Attempts to optimize an arguments.callee property access. This optimization only works if the arguments object is used in well-understood ways within the function. The function containing the arguments.callee is allowed to use the arguments object in the following ways without disabling this optimization: Access arguments.length Access arguments.callee Access in
dividual args using arguments[i] Save arguments into variables, as long as those variables cannot be accessed by any nested function, and as long as there exists no eval anywhere within the function or nested function definitions. Call a function using f.apply(obj, arguments) If the function contains any use of the arguments object that falls out of the cases defined above, this optimization will...
...pts to optimize element accesses on the arguments special object available in functions. This optimization only works if the arguments object is used in well-understood ways within the function. The function containing the arguments.length is allowed to use the arguments object in the following ways without disabling this optimization: Access arguments.length Access arguments.callee Access in
dividual args using arguments[i] Save arguments into variables, as long as those variables cannot be accessed by any nested function, and as long as there exists no eval anywhere within the function or nested function definitions. Call a function using f.apply(obj, arguments) If the function contains any use of the arguments object that falls out of the cases defined above, this optimization will...
...empts to optimize element writes to the arguments special object available in functions. This optimization only works if the arguments object is used in well-understood ways within the function. The function containing the arguments.length is allowed to use the arguments object in the following ways without disabling this optimization: Access arguments.length Access arguments.callee Access in
dividual args using arguments[i] Save arguments into variables, as long as those variables cannot be accessed by any nested function, and as long as there exists no eval anywhere within the function or nested function definitions. Call a function using f.apply(obj, arguments) If the function contains any use of the arguments object that falls out of the cases defined above, this optimization will...
An Overview of XPCOM
sary right away can be "lazy loaded", or not loaded at all, which can improve the performance of your application. Maintenance Even when you are not updating a component, designing your application in a modular way can make it easier for you to find and maintain the parts of the application that you are interested in. Mozilla has over four million lines of code, and no single in
dividual understands the entire codebase. The best way to tackle a project of this size is to
divide it into smaller, more manageable pieces, use a component programming model, and to organize related sets of components into modules. The network library, for example, consists of components for each of the protocols, HTTP, FTP, and others, which are bundled together and linked into a single library. T...
... it into smaller, more manageable pieces, use a component programming model, and to organize related sets of components into modules. The network library, for example, consists of components for each of the protocols, HTTP, FTP, and others, which are bundled together and linked into a single library. This library is the networking module, also known as "necko." But it's not always a good idea to
divide things up. There are some things in the world that just go together, and others that shouldn't be apart. For example, one author's son will not eat a peanut-butter sandwich if there isn't jam on it, because in his world, peanut butter and jam form an indelible union. Some software is the same. In areas of code that are tightly-coupled--in classes that are only used internally, for example--the...
...e are some things in the world that just go together, and others that shouldn't be apart. For example, one author's son will not eat a peanut-butter sandwich if there isn't jam on it, because in his world, peanut butter and jam form an indelible union. Some software is the same. In areas of code that are tightly-coupled--in classes that are only used internally, for example--the expensive work to
divide things may not be worth the effort. The HTTP component in Gecko doesn't expose private classes it uses as separate components. The "stuff" that's internal to the component stays internal, and isn't exposed to XPCOM. In the haste of early Mozilla development, components were created where they were inappropriate, but there's been an ongoing effort to remove XPCOM from places like this. Interf...
...rvice, they talk to the same instance of that service. When a user looks up a phone number in a company database, for example, probably that database is being represented by an "object" that is the same for all co-workers. If it weren't, the application would need to keep two copies of a large database in memory, for one thing, and there might also be inconsistencies between records as the copies
diverged. Providing this single point of access to functionality is what the singleton design pattern is for, and what services do in an application (and in a development environment like XPCOM). In XPCOM, in addition to the component support and management, there are a number of services that help the developer write cross platform components. These services include a cross platform file abstracti...
Tutorial: Show Allocations Per Call Path - Firefox Developer Tools
In the Scratchpad, ensure that no text is selected, and press the "Run" button. (If you get an error complaining that Components.utils is not defined, be sure you've selected Browser from the scratchpad's Environment menu, as described in step 2.) Save the following HTML text to a file, and visit the file in your browser. Make sure the current browser tab is displaying this page. ...
...cratchpad, ensure that no text is selected, and press the "Run" button. (If you get an error complaining that Components.utils is not defined, be sure you've selected Browser from the scratchpad's Environment menu, as described in step 2.) Save the following HTML text to a file, and visit the file in your browser. Make sure the current browser tab is displaying this page. <
div onclick="do
DivsAndSpans()"> Click here to make the page do some allocations. </
div> <script> function makeFactory(type) { return function factory(content) { var elt = document.createElement(type); elt.textContent = content; return elt; }; } var
divFactory = makeFactory('
div'); var spanFactory = makeFactory('span'); function
divsAndSpans() { for (i = 0; i < 10; i++) {...
..."> Click here to make the page do some allocations. </
div> <script> function makeFactory(type) { return function factory(content) { var elt = document.createElement(type); elt.textContent = content; return elt; }; } var
divFactory = makeFactory('
div'); var spanFactory = makeFactory('span'); function
divsAndSpans() { for (i = 0; i < 10; i++) { var
div =
divFactory('
div #' + i);
div.appendChild(spanFactory('span #' + i)); document.body.appendChild(
div); } } function do
DivsAndSpans() {
divsAndSpans(); } </script> Open the browser console (Menu Button > Developer > Browser Console), and then evaluate the expression demoTrackAllocations() in the browser console. This begins logging allocations in the current browser tab.
...internal structure.) As expected, the onclick handler is responsible for all allocation done by the page's own code. (The line number for the onclick handler is 1, indicating that the allocating call is located on line one of the handler text itself. We will probably change this to be the line number within page.html, not the line number within the handler code.) The onclick handler calls do
DivsAndSpans, which calls
divsAndSpans, which invokes closures of factory to do all the actual allocation. (It is unclear why spanFactory allocated thirteen objects, despite being called only ten times.) Source Metadata Generated from file: js/src/doc/Debugger/Tutorial-Alloc-Log-Tree.md Watermark: sha256:b56f6df61c39dbe19ca1f49752aea42207c804355513f4fea8249bdeb4cb056d Changeset: 251fcc...
Animation.onremove - Web APIs
r the remove event. This event is sent when the animation is removed (i.e., put into an active replace state). Syntax var removeHandler = animation.onremove; animation.onremove = removeHandler; Value A function to be called to handle the remove event, or null if no remove event handler is set. ...
...sent when the animation is removed (i.e., put into an active replace state). Syntax var removeHandler = animation.onremove; animation.onremove = removeHandler; Value A function to be called to handle the remove event, or null if no remove event handler is set. ...
...). Syntax var removeHandler = animation.onremove; animation.onremove = removeHandler; Value A function to be called to handle the remove event, or null if no remove event handler is set. Examples In our simple replace indefinite animations demo, you can see the following code: const
divElem = document.querySelector('
div'); document.body.addEventListener('mousemove', evt => { let anim =
divElem.animate( { transform: `translate(${ evt.clientX}px, ${evt.clientY}px)` }, { duration: 500, fill: 'forwards' } ); anim.commitStyles(); //anim.persist() anim.onremove = function() { console.log('Animation removed'); } console.log(anim.replaceState); }); Here we have a <
div> element, and an event listener that fires the event handler code whenever the mouse moves. Th...
...This could result in a huge animations list, which could create a memory leak. ...
Animation.persist() - Web APIs
The persist() method of the Web Animations API's Animation interface explicitly persists an animation, when it would otherwise be removed due to the browser's Automatically removing filling animations behavior. Syntax animation.persist(); Parameters None. Return value None. ...
... of the Web Animations API's Animation interface explicitly persists an animation, when it would otherwise be removed due to the browser's Automatically removing filling animations behavior. Syntax animation.persist(); Parameters None. Return value None. ...
...imation, when it would otherwise be removed due to the browser's Automatically removing filling animations behavior. Syntax animation.persist(); Parameters None. Return value None. Examples In our simple replace indefinite animations demo, you can see the following code: const
divElem = document.querySelector('
div'); document.body.addEventListener('mousemove', evt => { let anim =
divElem.animate( { transform: `translate(${ evt.clientX}px, ${evt.clientY}px)` }, { duration: 500, fill: 'forwards' } ); anim.commitStyles(); //anim.persist() anim.onremove = function() { console.log('Animation removed'); } console.log(anim.replaceState); }); Here we have a <
div> element, and an event listener that fires the event handler code whenever the mouse moves. Th...
...This could result in a huge animations list, which could create a memory leak. ...
Animation.replaceState - Web APIs
itial value of the animation's replace state; when the animation has been removed by the browser's Automatically removing filling animations behavior. persisted: The animation has been explicitly persisted by invoking Animation.persist() on it. removed: The animation has been explicitly removed. ...
...lace state; when the animation has been removed by the browser's Automatically removing filling animations behavior. persisted: The animation has been explicitly persisted by invoking Animation.persist() on it. removed: The animation has been explicitly removed. ...
...ally removing filling animations behavior. persisted: The animation has been explicitly persisted by invoking Animation.persist() on it. removed: The animation has been explicitly removed. Examples In our simple replace indefinite animations demo, you can see the following code: const
divElem = document.querySelector('
div'); document.body.addEventListener('mousemove', evt => { let anim =
divElem.animate( { transform: `translate(${ evt.clientX}px, ${evt.clientY}px)` }, { duration: 500, fill: 'forwards' } ); anim.commitStyles(); //anim.persist() anim.onremove = function() { console.log('Animation removed'); } console.log(anim.replaceState); }); Here we have a <
div> element, and an event listener that fires the event handler code whenever the mouse moves. Th...
...This could result in a huge animations list, which could create a memory leak. ...
BatteryManager.onchargingchange - Web APIs
Specifies an event listener to receive chargingchange events. These events occur when the battery charging state is updated. Syntax battery.onchargingchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingchange event occurs. ...
... Specifies an event listener to receive chargingchange events. These events occur when the battery charging state is updated. Syntax battery.onchargingchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingchange event occurs. ...
... Specifies an event listener to receive chargingchange events. These events occur when the battery charging state is updated. Syntax battery.onchargingchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingchange event occurs. ...
...es an event listener to receive chargingchange events. These events occur when the battery charging state is updated. Syntax battery.onchargingchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingchange event occurs. ...
BatteryManager.onchargingtimechange - Web APIs
Specifies an event listener to receive chargingtimechange events. These events occur when the battery chargingTime is updated. Syntax battery.onchargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingtimechange event occurs. ...
... Specifies an event listener to receive chargingtimechange events. These events occur when the battery chargingTime is updated. Syntax battery.onchargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingtimechange event occurs. ...
... Specifies an event listener to receive chargingtimechange events. These events occur when the battery chargingTime is updated. Syntax battery.onchargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingtimechange event occurs. ...
...t listener to receive chargingtimechange events. These events occur when the battery chargingTime is updated. Syntax battery.onchargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the chargingtimechange event occurs. ...
BatteryManager.ondischargingtimechange - Web APIs
Specifies an event listener to receive dischargingtimechange events. These events occur when the battery dischargingTime is updated. Syntax battery.ondischargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the dischargingtimechange event occurs. ...
... Specifies an event listener to receive dischargingtimechange events. These events occur when the battery dischargingTime is updated. Syntax battery.ondischargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the dischargingtimechange event occurs. ...
... Specifies an event listener to receive dischargingtimechange events. These events occur when the battery dischargingTime is updated. Syntax battery.ondischargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the dischargingtimechange event occurs. ...
...o receive dischargingtimechange events. These events occur when the battery dischargingTime is updated. Syntax battery.ondischargingtimechange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the dischargingtimechange event occurs. ...
BatteryManager.onlevelchange - Web APIs
The BatteryManager.onlevelchange property specifies an event listener to receive levelchange events. These events occur when the battery level is updated. Syntax navigator.battery.onlevelchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the levelchange event occurs. ...
... The BatteryManager.onlevelchange property specifies an event listener to receive levelchange events. These events occur when the battery level is updated. Syntax navigator.battery.onlevelchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the levelchange event occurs. ...
... The BatteryManager.onlevelchange property specifies an event listener to receive levelchange events. These events occur when the battery level is updated. Syntax navigator.battery.onlevelchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the levelchange event occurs. ...
...roperty specifies an event listener to receive levelchange events. These events occur when the battery level is updated. Syntax navigator.battery.onlevelchange = funcRef Where battery is a BatteryManager object, and funcRef is a function to be called when the levelchange event occurs. ...
CSSMathSum - Web APIs
function. Constructor CSSMathSum.CSSMathSum() Creates a new CSSMathSum object. Properties CSSMathSum.values Returns a CSSNumericArray object which contains one or more CSSNumericValue objects. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator and values, and dig into the values a bit. ...
...structor CSSMathSum.CSSMathSum() Creates a new CSSMathSum object. Properties CSSMathSum.values Returns a CSSNumericArray object which contains one or more CSSNumericValue objects. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator and values, and dig into the values a bit. ...
...MathSum() Creates a new CSSMathSum object. Properties CSSMathSum.values Returns a CSSNumericArray object which contains one or more CSSNumericValue objects. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator and values, and dig into the values a bit. ...
...rray object which contains one or more CSSNumericValue objects. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator and values, and dig into the values a bit. ...
CSSMathValue.operator - Web APIs
Value A String. Interface Value CSSMathSum "sum" CSSMathProduct "product" CSSMathMin "min" CSSMathMax "max" CSSMathClamp "clamp" CSSMathNegate "negate" CSSMathInvert "invert" Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
... CSSMathSum "sum" CSSMathProduct "product" CSSMathMin "min" CSSMathMax "max" CSSMathClamp "clamp" CSSMathNegate "negate" CSSMathInvert "invert" Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
...thProduct "product" CSSMathMin "min" CSSMathMax "max" CSSMathClamp "clamp" CSSMathNegate "negate" CSSMathInvert "invert" Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
...p "clamp" CSSMathNegate "negate" CSSMathInvert "invert" Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
CSSMathValue - Web APIs
is a list of interfaces based on the CSSMathValue interface. CSSMathInvert CSSMathMax CSSMathMin CSSMathNegate CSSMathProduct CSSMathSum Properties CSSMathValue.operator Indicates the operator that the current subtype represents. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
...nterfaces based on the CSSMathValue interface. CSSMathInvert CSSMathMax CSSMathMin CSSMathNegate CSSMathProduct CSSMathSum Properties CSSMathValue.operator Indicates the operator that the current subtype represents. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
.... CSSMathInvert CSSMathMax CSSMathMin CSSMathNegate CSSMathProduct CSSMathSum Properties CSSMathValue.operator Indicates the operator that the current subtype represents. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator. ...
... CSSMathValue.operator Indicates the operator that the current subtype represents. Event handlers No Methods None. Examples We create an element with a width determined using a calc() function, then console.log() the operator. <
div>has width</
div> We assign a width with a calculation
div { width: calc(30% - 20px); } We add the JavaScript const styleMap = document.querySelector('
div').computedStyleMap(); console.log( styleMap.get('width') ); // CSSMathSum {values: CSSNumericArray, operator: "sum"} console.log( styleMap.get('width').operator ); // 'sum' console.log( styleMap.get('width').values[1].value ); // -20 The CSSMathValue.operator returns 'sum' because styleMap.get('width').values[1].value ); is -20: adding a negative number. Specific...
Basic animations - Web APIs
yle> </head> <body> <canvas id="cw"></canvas> </body> </html> OutPut Snake Game <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Nokia 1100:snake..Member berries</title> </head> <body> <
div class="keypress hide"> <
div class="up" onclick="emit(38)">↑</
div> <
div class="right" onclick="emit(39)">→</
div> <
div class="left" onclick="emit(37)">←</
div> <
div class="down" onclick="emit(40)">↓</
div> </
div> <
div class="banner" id="selector"> <
div> Time :<span id="time">0</span> </
div> <
div>LousyG...
...ypress hide"> <
div class="up" onclick="emit(38)">↑</
div> <
div class="right" onclick="emit(39)">→</
div> <
div class="left" onclick="emit(37)">←</
div> <
div class="down" onclick="emit(40)">↓</
div> </
div> <
div class="banner" id="selector"> <
div> Time :<span id="time">0</span> </
div> <
div>LousyGames (C)</
div> <
div> Score :<span id="score">0</span> </
div> <
div class="touch off" onclick="touch(this)">touch</
div> </
div> <canvas id="main"></canvas> </body> <style> body { margin: 0; overflow: hidden; background: #000 } .banner { text-align: center; color: #fff; background: #3f51b5; line-height:...
... background: #000 } .banner { text-align: center; color: #fff; background: #3f51b5; line-height: 29px; position: fixed; left: 0; top: 0; right: 0; font-family: monospace; height: 30px; opacity: .4; display: flex; transition: .5s } .banner:hover { opacity: 1 }
div#selector>
div { flex-basis: 30% } @keyframes diss { from { opacity: 1 } to { opacity: 0 } } .keypress>
div { border: dashed 3px #fff; height: 48%; width: 48%; display: flex; align-content: center; justify-content: center; align-self: center; align-items:...
... font-weight: 900; color: #fff; transition: .5s; opacity: .1; border-radius: 7px } .keypress { position: fixed; width: 100vw; height: 100vh; top: 0; left: 0; display: flex; flex-wrap: wrap; justify-content: space-around; opacity: 1; user-select: none } .keypress>
div:hover { opacity: 1 } .touch { background: #8bc34a } .off { background: #f44336 } .hide { opacity: 0 } </style> </html> Javascript function tmz() { var e = new Date(t), i = new Date, n = Math.abs(i.getMinutes() - e.getMinutes()), o = Math.abs(i.getSeconds() - e.getSeconds()); return...
DataTransfer.clearData() - Web APIs
empty string or is not provided, the data for all types is removed. Example This example shows the use of the DataTransfer object's getData(), setData() and clearData() methods. HTML <span class="tweaked" id="source" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element. ...
...pes is removed. Example This example shows the use of the DataTransfer object's getData(), setData() and clearData() methods. HTML <span class="tweaked" id="source" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element. ...
... removed. Example This example shows the use of the DataTransfer object's getData(), setData() and clearData() methods. HTML <span class="tweaked" id="source" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element. ...
...the DataTransfer object's getData(), setData() and clearData() methods. HTML <span class="tweaked" id="source" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element. ...
Detecting device orientation - Web APIs
DeviceOrientationEvent.gamma value represents the motion of the device around the y axis, represented in degrees with values ranging from -90 to 90. This represents a left to right motion of the device. Orientation example This example will work on any browser supporting the deviceorientation event and running on a device able to detect its orientation. ...
....gamma value represents the motion of the device around the y axis, represented in degrees with values ranging from -90 to 90. This represents a left to right motion of the device. Orientation example This example will work on any browser supporting the deviceorientation event and running on a device able to detect its orientation. ...
...ents the motion of the device around the y axis, represented in degrees with values ranging from -90 to 90. This represents a left to right motion of the device. Orientation example This example will work on any browser supporting the deviceorientation event and running on a device able to detect its orientation. ...
...e motion of the device around the y axis, represented in degrees with values ranging from -90 to 90. This represents a left to right motion of the device. Orientation example This example will work on any browser supporting the deviceorientation event and running on a device able to detect its orientation. ...
Document: DOMContentLoaded event - Web APIs
OMContentLoaded may fire before your script has a chance to run, so it is wise to check before adding a listener. ...
...se to check before adding a listener. ...
...heck before adding a listener. ...
...// Loading hasn't finished yet document.addEventListener('DOMContentLoaded', doSomething); } else { // `DOMContentLoaded` has already fired doSomething(); } Live example HTML <
div class="controls"> <button id="reload" type="button">Reload</button> </
div> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents" rows="8" cols="30"></textarea> </
div> CSS body { display: grid; grid-template-areas: "control log"; } .controls { grid-area: control; display: flex; align-items: center; justify-content: center; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button { display: block; } #reload { height: 2rem; } JS const log = document.querySelector('.event-log-contents'); const reload =...
Document.getElementById() - Web APIs
t.querySelectorAll(), getElementById() is only available as a method of the global document object, and not available as a method on all element objects in the DOM. Because ID values must be unique throughout the entire document, there is no need for "local" versions of the function. ...
...objects in the DOM. Because ID values must be unique throughout the entire document, there is no need for "local" versions of the function. Example <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <
div id="parent-id"> <p>hello word1</p> <p id="test1">hello word2</p> <p>hello word3</p> <p>hello word4</p> </
div> <script> var parentDOM = document.getElementById('parent-id'); var test1 = parentDOM.getElementById('test1'); //throw error //Uncaught TypeError: parentDOM.getElementById is not a function </script> </body> </html> If there is no element with the given id, this function returns null. Note that the id parameter is case-sensitive, so document.getElementById...
...tElementById('parent-id'); var test1 = parentDOM.getElementById('test1'); //throw error //Uncaught TypeError: parentDOM.getElementById is not a function </script> </body> </html> If there is no element with the given id, this function returns null. ...
...The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "id" are not of type ID unless so defined in the document's DTD. The id attribute is defined to be of ID type in the common cases of XHTML, XUL, and other. ...
Document: readystatechange event - Web APIs
The readystatechange event is fired when the readyState attribute of a document has changed. ...
... The readystatechange event is fired when the readyState attribute of a document has changed. ...
... The readystatechange event is fired when the readyState attribute of a document has changed. ...
...t has changed. ...
Document: wheel event - Web APIs
alues in the wheel event don't necessarily reflect the content's scrolling direction. Therefore, do not rely on the wheel event's delta* properties to get the scrolling direction. Instead, detect value changes of scrollLeft and scrollTop in the scroll event. Examples Scaling an element via the wheel This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
...arily reflect the content's scrolling direction. Therefore, do not rely on the wheel event's delta* properties to get the scrolling direction. Instead, detect value changes of scrollLeft and scrollTop in the scroll event. Examples Scaling an element via the wheel This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
... the scrolling direction. Instead, detect value changes of scrollLeft and scrollTop in the scroll event. Examples Scaling an element via the wheel This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
... Working Draft ...
DocumentOrShadowRoot.elementsFromPoint() - Web APIs
umentOrShadowRoot interface returns an array of all elements at the specified coordinates (relative to the viewport). It operates in a similar way to the elementFromPoint() method. Syntax const elements = document.elementsFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Return value An array of element objects. ...
...e returns an array of all elements at the specified coordinates (relative to the viewport). It operates in a similar way to the elementFromPoint() method. Syntax const elements = document.elementsFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Return value An array of element objects. ...
...he specified coordinates (relative to the viewport). It operates in a similar way to the elementFromPoint() method. Syntax const elements = document.elementsFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Return value An array of element objects. ...
...inates (relative to the viewport). It operates in a similar way to the elementFromPoint() method. Syntax const elements = document.elementsFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Return value An array of element objects. ...
DocumentOrShadowRoot.nodeFromPoint() - Web APIs
pmost node at the specified coordinates (relative to the viewport). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var node = document.nodeFromPoint(x, y); Parameters x A double representing the horizontal coordinate of a point. y A double representing the vertical coordinate of a point. Returns A Node object. ...
...d coordinates (relative to the viewport). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var node = document.nodeFromPoint(x, y); Parameters x A double representing the horizontal coordinate of a point. y A double representing the vertical coordinate of a point. Returns A Node object. ...
...). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var node = document.nodeFromPoint(x, y); Parameters x A double representing the horizontal coordinate of a point. y A double representing the vertical coordinate of a point. Returns A Node object. ...
... method is only implemented in Firefox, and only available to chrome code. Syntax var node = document.nodeFromPoint(x, y); Parameters x A double representing the horizontal coordinate of a point. y A double representing the vertical coordinate of a point. Returns A Node object. ...
DocumentOrShadowRoot.nodesFromPoint() - Web APIs
ot interface returns an array of all nodes at the specified coordinates (relative to the viewport). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var nodes = document.nodesFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Returns An array of Node objects. ...
...ray of all nodes at the specified coordinates (relative to the viewport). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var nodes = document.nodesFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Returns An array of Node objects. ...
...ordinates (relative to the viewport). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var nodes = document.nodesFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Returns An array of Node objects. ...
...e to the viewport). Currently this method is only implemented in Firefox, and only available to chrome code. Syntax var nodes = document.nodesFromPoint(x, y); Parameters x The horizontal coordinate of a point. y The vertical coordinate of a point. Returns An array of Node objects. ...
Element: error event - Web APIs
r can't be used. For example, if a script has an execution error or an image can't be found or is invalid. Bubbles No Cancelable No Interface Event or UIEvent Event handler property onerror The event object is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
...bbles No Cancelable No Interface Event or UIEvent Event handler property onerror The event object is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
... No Cancelable No Interface Event or UIEvent Event handler property onerror The event object is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
...ject is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
Element: overflow event - Web APIs
The overflow event is fired when an element has been overflowed by its content or has been rendered for the first time in this state (only works for elements styled with overflow != visible). It is a proprietary event specific to Gecko (Firefox). ...
...vent is fired when an element has been overflowed by its content or has been rendered for the first time in this state (only works for elements styled with overflow != visible). It is a proprietary event specific to Gecko (Firefox). ...
...n an element has been overflowed by its content or has been rendered for the first time in this state (only works for elements styled with overflow != visible). It is a proprietary event specific to Gecko (Firefox). ...
...ement has been overflowed by its content or has been rendered for the first time in this state (only works for elements styled with overflow != visible). It is a proprietary event specific to Gecko (Firefox). ...
Element.releasePointerCapture() - Web APIs
how to set it for a particular element. Syntax targetElement.releasePointerCapture(pointerId); Parameters pointerId The pointerId of a PointerEvent object. Return value This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. ...
...a PointerEvent object. Return value This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. Example This example sets pointer capture on a <
div> when you press down on it. This lets you slide the element horizontally, even when you pointer moves outside of its boundaries. ...
...eturn value This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. Example This example sets pointer capture on a <
div> when you press down on it. This lets you slide the element horizontally, even when you pointer moves outside of its boundaries. ...
... This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. Example This example sets pointer capture on a <
div> when you press down on it. This lets you slide the element horizontally, even when you pointer moves outside of its boundaries. ...
Element.scrollLeft - Web APIs
ft = 10; scrollLeft can be specified as any integer value. However: If the element can't be scrolled (e.g., it has no overflow), scrollLeft is set to 0. If specified as a value less than 0 (greater than 0 for right-to-left elements), scrollLeft is set to 0. If specified as a value greater than the maximum that the content can be scrolled, scrollLeft is set to the maximum. ...
...an be specified as any integer value. However: If the element can't be scrolled (e.g., it has no overflow), scrollLeft is set to 0. If specified as a value less than 0 (greater than 0 for right-to-left elements), scrollLeft is set to 0. If specified as a value greater than the maximum that the content can be scrolled, scrollLeft is set to the maximum. ...
...f the element can't be scrolled (e.g., it has no overflow), scrollLeft is set to 0. If specified as a value less than 0 (greater than 0 for right-to-left elements), scrollLeft is set to 0. If specified as a value greater than the maximum that the content can be scrolled, scrollLeft is set to the maximum. ...
...lement can't be scrolled (e.g., it has no overflow), scrollLeft is set to 0. If specified as a value less than 0 (greater than 0 for right-to-left elements), scrollLeft is set to 0. If specified as a value greater than the maximum that the content can be scrolled, scrollLeft is set to the maximum. ...
Element.setAttributeNodeNS() - Web APIs
setAttributeNodeNS adds a new namespaced attribute node to an element. Syntax replacedAttr = element.setAttributeNodeNS(attributeNode) replacedAttr is the replaced attribute node, if any, returned by this function. attributeNode is an Attr node. ...
... setAttributeNodeNS adds a new namespaced attribute node to an element. Syntax replacedAttr = element.setAttributeNodeNS(attributeNode) replacedAttr is the replaced attribute node, if any, returned by this function. attributeNode is an Attr node. ...
... setAttributeNodeNS adds a new namespaced attribute node to an element. Syntax replacedAttr = element.setAttributeNodeNS(attributeNode) replacedAttr is the replaced attribute node, if any, returned by this function. attributeNode is an Attr node. ...
...teNodeNS adds a new namespaced attribute node to an element. Syntax replacedAttr = element.setAttributeNodeNS(attributeNode) replacedAttr is the replaced attribute node, if any, returned by this function. attributeNode is an Attr node. ...
Element.setPointerCapture() - Web APIs
element (such as by scrolling or panning). Syntax targetElement.setPointerCapture(pointerId); Parameters pointerId The pointerId of a PointerEvent object. Return value This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. ...
...a PointerEvent object. Return value This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. Example This example sets pointer capture on a <
div> when you press down on it. This lets you slide the element horizontally, even when you pointer moves outside of its boundaries. ...
...eturn value This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. Example This example sets pointer capture on a <
div> when you press down on it. This lets you slide the element horizontally, even when you pointer moves outside of its boundaries. ...
... This method returns undefined. Exceptions Exception Explanation InvalidPointerId pointerId does not match any of the active pointers. Example This example sets pointer capture on a <
div> when you press down on it. This lets you slide the element horizontally, even when you pointer moves outside of its boundaries. ...
Element: underflow event - Web APIs
n-standard underflow event, which is specific to Firefox, is fired when an element is no longer overflowed by its content. This only works for elements for which overflow is not set to visible. The counterpart overflow event is fired when overflow occurs. ...
...ent, which is specific to Firefox, is fired when an element is no longer overflowed by its content. This only works for elements for which overflow is not set to visible. The counterpart overflow event is fired when overflow occurs. ...
...cific to Firefox, is fired when an element is no longer overflowed by its content. This only works for elements for which overflow is not set to visible. The counterpart overflow event is fired when overflow occurs. ...
...o Firefox, is fired when an element is no longer overflowed by its content. This only works for elements for which overflow is not set to visible. The counterpart overflow event is fired when overflow occurs. ...
Element: wheel event - Web APIs
heel event don't necessarily reflect the content's scrolling direction. Therefore, do not rely on the wheel event's delta* properties to get the scrolling direction. Instead, detect value changes of scrollLeft and scrollTop of the target in the scroll event. Examples Scaling an element via the wheel This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
...the content's scrolling direction. Therefore, do not rely on the wheel event's delta* properties to get the scrolling direction. Instead, detect value changes of scrollLeft and scrollTop of the target in the scroll event. Examples Scaling an element via the wheel This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
... direction. Instead, detect value changes of scrollLeft and scrollTop of the target in the scroll event. Examples Scaling an element via the wheel This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
... Working Draft ...
GlobalEventHandlers.onmousedown - Web APIs
use button. Note: The opposite of onmousedown is onmouseup. Syntax target.onmousedown = functionRef; Value functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example This example reveals part of an image when you press and hold a mouse button. It uses the onmousedown, onmouseup, and onmousemove event handlers. ...
...posite of onmousedown is onmouseup. Syntax target.onmousedown = functionRef; Value functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example This example reveals part of an image when you press and hold a mouse button. It uses the onmousedown, onmouseup, and onmousemove event handlers. ...
...nmouseup. Syntax target.onmousedown = functionRef; Value functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example This example reveals part of an image when you press and hold a mouse button. It uses the onmousedown, onmouseup, and onmousemove event handlers. ...
... a function name or a function expression. The function receives a MouseEvent object as its sole argument. Example This example reveals part of an image when you press and hold a mouse button. It uses the onmousedown, onmouseup, and onmousemove event handlers. ...
GlobalEventHandlers.onwheel - Web APIs
wheel with onscroll: onwheel handles general wheel rotation, while onscroll handles scrolling of an object's content. Syntax target.onwheel = functionRef; Value functionRef is a function name or a function expression. The function receives a WheelEvent object as its sole argument. Examples This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
...general wheel rotation, while onscroll handles scrolling of an object's content. Syntax target.onwheel = functionRef; Value functionRef is a function name or a function expression. The function receives a WheelEvent object as its sole argument. Examples This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
... Value functionRef is a function name or a function expression. The function receives a WheelEvent object as its sole argument. Examples This example shows how to scale an element using the mouse (or other pointing device) wheel. ...
... Living Standard ...
HTMLFormElement - Web APIs
The HTMLFormElement interface represents a <form> element in the DOM. It allows access to--and, in some cases, modification of--aspects of the form, as well as access to its component elements. ...
... HTMLFormElement.elements Read only A HTMLFormControlsCollection holding all form controls belonging to this form element. HTMLFormElement.lengthRead only A long reflecting the number of controls in the form. HTMLFormElement.name A DOMString ref...
... the onsubmit property. Usage notes Obtaining a form element object To obtain an HTMLFormElement object, you can use a CSS selector with querySelector(), or you can get a list of all of the forms in the document using its forms property. Document.forms returns an array of HTMLFormElement objects listing each of the forms on the page. You can then use any of the following syntaxes to get an in
dividual form: document.forms[index] Returns the form at the specified index into the array of forms. document.forms[id] Returns the form whose ID is id. document.forms[name] Returns the form whose name attribute's value is name. Accessing the form's elements You can access the list of the form's data-containing elements by examining the form's elements property. This returns an HTMLFormCo...
... <input name="id"> will take precedence over <form id="...">. This means that form.id will not refer to the form's id, but to the element whose name is "id". This will be the case with any other form properties, such as <input name="action"> or <input name="post">. <input name="elements"> will render the form's elements collection inaccessible. The reference form.elements will now refer to the in
dividual element. To avoid such problems with element names: Always use the elements collection to avoid ambiguity between an element name and a form property. Never use "elements" as an element name. If you are not using JavaScript, this will not cause a problem. Elements that are considered form controls The elements included by HTMLFormElement.elements and HTMLFormElement.length are the ...
HTMLImageElement.alt - Web APIs
th no semantic meaning--such as those which are solely decorative--or of limited informational value, should have their alt attributes set to the empty string (""). This is shown in the example below. HTML In the HTML for this example, shown below, the <img> element includes the alt property, which will prevent the image from having any alternate text, since it's simply a decorational detail. <
div class="container"> <
div class="left-margin"> <img src="/files/16861/margin-flourish.svg" alt=""> </
div> <
div class="contents"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque quis orci ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac neque libero. Vivamus consectetur rhoncus elit eget porta. Etiam pulvinar ex id sapien laoree...
...gula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac neque libero. Vivamus consectetur rhoncus elit eget porta. Etiam pulvinar ex id sapien laoreet, quis aliquet odio lobortis. Nam ac mauris at risus laoreet cursus vitae et sapien. Etiam molestie auctor eros, ac porta risus scelerisque sit amet. Ut nunc neque, porta eu auctor at, tempor et arcu.</p> </
div> </
div> CSS The CSS for this example simply sets up the styles for the layout as shown in the result below. They're not crucial to the concept shown in the HTML above, but you may expand the view below if you wish to read the CSS used. View the CSS Editors: If you change the CSS below, please be sure to close the details box using the toggle at the top of the CSS view before saving. Otherwise...
...citing). The alt attribute is set to New Page! to allow that text to be displayed in place of the image if the image isn't available. It is also available to be read by screen readers. HTML The HTML below creates a snippet of content from a site using the described icon. Note the use of the alt attribute on the <img>, providing a good substitution string to use in case the image doesn't load. <
div class="container"> <img src="https://udn.realityripple.com/samples/87/eace6b7d6a.svg" alt="New Page!" class="pageinfo-badge"> <p class="contents"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque quis orci ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac neque libero. Vivamus consectetur rhoncus elit eget porta. Etiam pulvinar e...
...ula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac neque libero. Vivamus consectetur rhoncus elit eget porta. Etiam pulvinar ex id sapien laoreet, quis aliquet odio lobortis. Nam ac mauris at risus laoreet cursus vitae et sapien. Etiam molestie auctor eros, ac porta risus scelerisque sit amet. Ut nunc neque, porta eu auctor at, tempor et arcu. </p> </
div> CSS The main feature of the CSS here is the use of clip-path and shape-outside to wrap the text around the icon in an appealing way. .container { max-width: 500px; } .pageinfo-badge { width: 9em; padding-right: 1em; float: left; clip-path: polygon(100% 0, 100% 50%, 90% 70%, 80% 80%, 70% 90%, 50% 100%, 0 100%, 0 0); shape-outside: polygon(100% 0, 100% 50%, 90% 70%, 80...
File drag and drop - Web APIs
dragging and dropping files. One API is the DataTransfer interface and the second API is the DataTransferItem and DataTransferItemList interfaces. This example illustrates the use of both APIs (and does not use any Gecko specific interfaces). Define the drop zone The target element of the drop event needs an ondrop global event handler. ...
...opping files. One API is the DataTransfer interface and the second API is the DataTransferItem and DataTransferItemList interfaces. This example illustrates the use of both APIs (and does not use any Gecko specific interfaces). Define the drop zone The target element of the drop event needs an ondrop global event handler. ...
...ansferItemList interfaces. This example illustrates the use of both APIs (and does not use any Gecko specific interfaces). Define the drop zone The target element of the drop event needs an ondrop global event handler. ...
...ppet shows how this is done with a <
div> element: <
div id="drop_zone" ondrop="dropHandler(event);"> <p>Drag one or more files to this Drop Zone ...</p> </
div> Typically, an application will include a dragover event handler on the drop target element and that handler will turn off the browser's default drag behavior. To add this handler, you need to include a ondragover global event handler: <
div id="drop_zone" ondrop="dropHandler(event);" ondragover="dragOverHandler(event);"> <p>Drag one or more files to this Drop Zone ...</p> </
div> Lastly, an application may want to style the drop target element to visually indicate the element is a drop zone. In this example, the drop target element uses the following styling: #drop_zone { border: 5px solid blue; width: 200px; height: 100p...
KeyboardEvent: code values - Web APIs
"AudioVolumeDown" "VolumeDown" (was "VolumeDown" until Chrome 50) 0xE02F "Unidentified" "" 0xE030 "AudioVolumeUp" "VolumeUp" (was "VolumeUp" until Chrome 50) 0xE031 "Unidentified" "" 0xE032 "BrowserHome" "BrowserHome" 0xE033, 0xE034 "Unidentified" "" 0xE035 "Numpad
Divide" "Numpad
Divide" 0xE036 "Unidentified" "" 0xE037 "PrintScreen" "PrintScreen" 0xE038 "AltRight" "AltRight" 0xE039, 0xE03A "Unidentified" "" 0xE03B "Unidentified" "Help" 0xE03C~ 0xE044 "Unidentified" "" 0xE045 "NumLock" "NumLock" 0xE046 (Ctrl + P...
...lumeUp" (was "VolumeUp" until Firefox 48) "AudioVolumeUp" (was "VolumeUp" until Chrome 50) kVK_VolumeDown (0x49) "AudioVolumeDown" (was "VolumeDown" until Firefox 49) "AudioVolumeDown" (was "VolumeDown" until Chrome 50) kVK_Mute (0x4A) "AudioVolumeMute" (was "VolumeMute" until Firefox 49) "AudioVolumeMute" (was "VolumeMute" until Chrome 50) kVK_ANSI_Keypad
Divide (0x4B) "Numpad
Divide" "Numpad
Divide" kVK_ANSI_KeypadEnter (0x4C) "NumpadEnter" "NumpadEnter" kVK_ANSI_KeypadMinus (0x4E) "NumpadSubtract" "NumpadSubtract" kVK_F18 (0x4F) "F18" "F18" kVK_F19 (0x50) "F19" "F19" kVK_ANSI_KeypadEquals (0x51) "NumpadEqual" "NumpadEqual" kVK_ANSI_Keypad0 (0x52) "Numpad0" ...
... "F12" 0x0061 "IntlRo" "IntlRo" 0x0062, 0x0063 "Unidentified" "" 0x0064 "Convert" "Convert" 0x0065 "KanaMode" "KanaMode" 0x0066 "NonConvert" "NonConvert" 0x0067 "Unidentified" "" 0x0068 "NumpadEnter" "NumpadEnter" 0x0069 "ControlRight" "ControlRight" 0x006A "Numpad
Divide" "Numpad
Divide" 0x006B "PrintScreen" "PrintScreen" 0x006C "AltRight" "AltRight" 0x006D "Unidentified" "" 0x006E "Home" "Home" 0x006F "ArrowUp" "ArrowUp" 0x0070 "PageUp" "PageUp" 0x0071 "ArrowLeft" "ArrowLeft" 0x0072 "ArrowRight" "ArrowRight" 0x0073 "End" "En...
...ied" 0x0056 "IntlBackslash" 0x0057 "F11" 0x0058 "F12" 0x0059 "IntlRo" 0x005A, 0x005B "Unidentified" 0x005C "Convert" 0x005D "KanaMode" 0x005E "NonConvert" 0x005F "Unidentified" 0x0060 "NumpadEnter" 0x0061 "ControlRight" 0x0062 "Numpad
Divide" 0x0063 "PrintScreen" 0x0064 "AltRight" 0x0065 "Unidentified" 0x0066 "Home" 0x0067 "ArrowUp" 0x0068 "PageUp" 0x0069 "ArrowLeft" 0x006A "ArrowRight" 0x006B "End" 0x006C "ArrowDown" 0x006D "PageDown" 0x006E "Insert" 0x006F "Delete" ...
MouseEvent.initMouseEvent() - Web APIs
ftKey whether or not shift key was depressed during the Event. Sets the value of MouseEvent.shiftKey. metaKey whether or not meta key was depressed during the Event. Sets the value of MouseEvent.metaKey. button the event's mouse button. relatedTarget the event's related EventTarget. Only used with some event types (e.g., mouseover and mouseout). In other cases, pass null. ...
...ent. Sets the value of MouseEvent.shiftKey. metaKey whether or not meta key was depressed during the Event. Sets the value of MouseEvent.metaKey. button the event's mouse button. relatedTarget the event's related EventTarget. Only used with some event types (e.g., mouseover and mouseout). In other cases, pass null. ...
...alue of MouseEvent.shiftKey. metaKey whether or not meta key was depressed during the Event. Sets the value of MouseEvent.metaKey. button the event's mouse button. relatedTarget the event's related EventTarget. Only used with some event types (e.g., mouseover and mouseout). In other cases, pass null. ...
... metaKey whether or not meta key was depressed during the Event. Sets the value of MouseEvent.metaKey. button the event's mouse button. relatedTarget the event's related EventTarget. Only used with some event types (e.g., mouseover and mouseout). In other cases, pass null. ...
Online and offline events - Web APIs
References 'Online/Offline events' section from the WHATWG Web Applications 1.0 Specification The bug tracking online/offline even...
... References 'Online/Offline events' section from the WHATWG Web Applications 1.0 Specification The bug tracking online/offline events implementation ...
... References 'Online/Offline events' section from the WHATWG Web Applications 1.0 Specification The bug tracking online/offline events implementation in Fir...
... References 'Online/Offline events' section from the WHATWG Web Applications 1.0 Specification The bug tracking online/offline events implementation in Firefox and a foll...
Node.nodeName - Web APIs
However, in HTML, text_field's value would read "
DIV", because nodeName and tagName return in upper case on HTML eleme...
...However, in HTML, text_field's value would read "
DIV", because nodeName and tagName return in upper case on HTML elements in DOMs flagged as HT...
...However, in HTML, text_field's value would read "
DIV", because nodeName and tagName return in upper case on HTML elements in DOMs flagged as HTML documents. Read more details on nodeName case sensitivity in d...
...f entity reference Notation The notation name ProcessingInstruction The value of ProcessingInstruction.target Text "#text" Example Given the following markup: <
div id="d1">hello world</
div> <input type="text" id="t"> and the following script: var
div1 = document.getElementById("d1"); var text_field = document.getElementById("t"); text_field.value =
div1.nodeName; In XHTML (or any other XML format), text_field's value would read "
div". However, in HTML, text_field's value would read "
DIV", because nodeName and tagName return in upper case on HTML elements in DOMs flagged as HTML documents. Read more details on nodeName case sensitivity in different browsers. Note that the Element.tagName property could have been used instead, since nodeName h...
Node.textContent - Web APIs
n into any other element or into the same element after doing so. Differences from innerHTML Element.innerHTML returns HTML, as its name indicates. Sometimes people use innerHTML to retrieve or write text inside an element, but textContent has better performance because its value is not parsed as HTML. Moreover, using textContent can prevent XSS attacks. ...
...ny other element or into the same element after doing so. Differences from innerHTML Element.innerHTML returns HTML, as its name indicates. Sometimes people use innerHTML to retrieve or write text inside an element, but textContent has better performance because its value is not parsed as HTML. Moreover, using textContent can prevent XSS attacks. ...
...nt after doing so. Differences from innerHTML Element.innerHTML returns HTML, as its name indicates. Sometimes people use innerHTML to retrieve or write text inside an element, but textContent has better performance because its value is not parsed as HTML. Moreover, using textContent can prevent XSS attacks. Examples Given this HTML fragment: <
div id="
divA">This is <span>some</span> text!</
div> ... ...
...metimes people use innerHTML to retrieve or write text inside an element, but textContent has better performance because its value is not parsed as HTML. Moreover, using textContent can prevent XSS attacks. Examples Given this HTML fragment: <
div id="
divA">This is <span>some</span> text!</
div> ... you can use textContent to get the element's text content: let text = document.getElementById('
divA').textContent; // The text variable is now: 'This is some text!' ... or set the element's text content: document.getElementById('
divA').textContent = 'This text is different!'; // The HTML for
divA is now: // <
div id="
divA">This text is different!</
div> Specifications Specification Status Comment DOMThe definition of 'Node.textContent' in that specification. L...
Range.createContextualFragment() - Web APIs
belongs to a Document whose HTMLness bit is set. In the HTML case, if the context node would be html, for historical reasons the fragment parsing algorithm is invoked with body as the context instead. Syntax documentFragment = range.createContextualFragment(tagString) Parameters tagString Text that contains text and tags to be converted to a document fragment. ...
...a Document whose HTMLness bit is set. In the HTML case, if the context node would be html, for historical reasons the fragment parsing algorithm is invoked with body as the context instead. Syntax documentFragment = range.createContextualFragment(tagString) Parameters tagString Text that contains text and tags to be converted to a document fragment. ...
... whose HTMLness bit is set. In the HTML case, if the context node would be html, for historical reasons the fragment parsing algorithm is invoked with body as the context instead. Syntax documentFragment = range.createContextualFragment(tagString) Parameters tagString Text that contains text and tags to be converted to a document fragment. ...
...tml, for historical reasons the fragment parsing algorithm is invoked with body as the context instead. Syntax documentFragment = range.createContextualFragment(tagString) Parameters tagString Text that contains text and tags to be converted to a document fragment. Example var tagString = "<
div>I am a
div node</
div>"; var range = document.createRange(); // Make the parent of the first
div in the document becomes the context node range.selectNode(document.getElementsByTagName("
div").item(0)); var documentFragment = range.createContextualFragment(tagString); document.body.appendChild(documentFragment); Specification Specification Status Comment DOM Parsing and SerializationThe definition of 'Range.createContextualFragment()' in that specification. Worki...
Selection.setBaseAndExtent() - Web APIs
in between the two nodes. Next, we have two form inputs that allow you to set the anchorOffset and focusOffset -- they both have a default value of 0. We also have a button that when pressed invokes a function that runs the setBaseAndExtent() method with the specified offsets, and copies the selection into the output paragraph at the very bottom of the HTML. ...
... a function that runs the setBaseAndExtent() method with the specified offsets, and copies the selection into the output paragraph at the very bottom of the HTML. ...
...tion that runs the setBaseAndExtent() method with the specified offsets, and copies the selection into the output paragraph at the very bottom of the HTML. ...
...p> <p class="two"><span>Car</span><span>Bike</span><span>Boat</span><span>Plane</span></p> </
div> <
div> <p> <label for="aOffset">Anchor offset</label> <input id="aOffset" name="aOffset" type="number" value="0"> </p> <p> <label for="fOffset">Focus offset</label> <input id="fOffset" name="fOffset" type="number" value="0"> </p> <p><button>Capture selection</button></p> </
div> <p><strong>Output</strong>: <span class="output"></span></p> The JavaScript looks like so: var one = document.querySelector('.one'); var two = document.querySelector('.two'); var aOffset = document.getElementById('aOffset'); var fOffset = document.getElementById('fOffset'); var button = document.querySelector('button'); var output = document.querySelector('.output'); var selection; butto...
Matrix math for the web - Web APIs
, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ]; Place the distances along the three axes in the corresponding positions in the translation matrix, then multiply it by the point or matrix you need to move through 3D space. Manipulating the DOM with a matrix A really easy way to start using a matrix is to use the CSS matrix3d() transform. ...
...he corresponding positions in the translation matrix, then multiply it by the point or matrix you need to move through 3D space. Manipulating the DOM with a matrix A really easy way to start using a matrix is to use the CSS matrix3d() transform. First we'll set up a simple <
div> with some content. The style is not shown, but it's set to a fixed width and height and is centered on the page. The <
div> has a transition set for the transform so that matrix is animated in making it easy to see what is being done. ...
... 3D space. Manipulating the DOM with a matrix A really easy way to start using a matrix is to use the CSS matrix3d() transform. First we'll set up a simple <
div> with some content. The style is not shown, but it's set to a fixed width and height and is centered on the page. The <
div> has a transition set for the transform so that matrix is animated in making it easy to see what is being done. <
div id='move-me' class='transformable'> <h2>Move me with a matrix</h2> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> </
div> Finally, for each of the examples we will generate a 4x4 matrix, then update the <
div>'s style to have a transform applied to it, set to a matrix3d. Bear in mind that even though the matrix is made up of 4 rows and 4 columns, it collapses into a single...
...distance, Math.sin(rotationInRadians) * distance ]; It is possible to encode these type of steps into a matrix, and do it for each of the x, y, and z dimensions. Below is the representation of a rotation about the X axis: let sin = Math.sin; let cos = Math.cos; // NOTE: There is no perspective in these transformations, so a rotation // at this point will only appear to only shrink the
div let a = Math.PI * 0.3; //Rotation amount in radians // Rotate around Z axis let rotateZMatrix = [ cos(a), -sin(a), 0, 0, sin(a), cos(a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; View on JSFiddle Here are a set of functions that return rotation matrices for rotating around each of the three axes. One big note is that there is no perspective appl...
Signaling and video calling - Web APIs
essary to use WebSockets for signaling, but it is a common solution. You should, of course, select a mechanism for exchanging signaling information that is appropriate for your application. Let's update the chat client to support video calling. Updating the HTML The HTML for our client needs a location for video to be presented. ...
...s a common solution. You should, of course, select a mechanism for exchanging signaling information that is appropriate for your application. Let's update the chat client to support video calling. Updating the HTML The HTML for our client needs a location for video to be presented. This requires video elements, and a button to hang up the call: <
div class="flexChild" id="camera-container"> <
div class="camera-box"> <video id="received_video" autoplay></video> <video id="local_video" autoplay muted></video> <button id="hangup-button" onclick="hangUpCall();" disabled> Hang Up </button> </
div> </
div> The page structure defined here is using <
div> elements, giving us full control over the page layout by enabling the use of CSS. We'll skip layout detail in this guide,...
...o in this preview panel. Finally, the "hangup-button" <button>, to disconnect from a call, is defined and configured to start disabled (setting this as our default for when no call is connected) and apply the function hangUpCall() on click. This function's role is to close the call, and send a signalling server notification to the other peer, requesting it also close. The JavaScript code We'll
divide this code into functional areas to more easily describe how it works. The main body of this code is found in the connect() function: it opens up a WebSocket server on port 6503, and establishes a handler to receive messages in JSON object format. This code generally handles text chat messages as it did previously. Sending messages to the signaling server Throughout our code, we call sendToSe...
... item.appendChild(document.createTextNode(username)); item.addEventListener("click", invite, false); listElem.appendChild(item); }); } After getting a reference to the <ul> which contains the list of user names into the variable listElem, we empty the list by removing each of its child elements. Note: Obviously, it would be more efficient to update the list by adding and removing in
dividual users instead of rebuilding the whole list every time it changes, but this is good enough for the purposes of this example. Then we iterate over the array of user names using forEach(). For each name, we create a new <li> element, then create a new text node containing the user name using createTextNode(). That text node is added as a child of the <li> element. Next, we set a handler for t...
Window: error event - Web APIs
ject when a resource failed to load or couldn't be used -- for example if a script has an execution error. Bubbles No Cancelable No Interface Event or UIEvent Event handler property onerror The event object is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
...s No Cancelable No Interface Event or UIEvent Event handler property onerror The event object is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
... Cancelable No Interface Event or UIEvent Event handler property onerror The event object is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
... is a UIEvent instance if it was generated from a user interface element, or an Event instance otherwise. ...
Window.pageYOffset - Web APIs
his example, an <iframe> is created and filled with content, then a specific element within the document is scrolled into view in the frame. Once that's done, the vertical scroll position is checked by looking at the value of pageYOffset in the frame's contentWindow. ...
...to view in the frame. Once that's done, the vertical scroll position is checked by looking at the value of pageYOffset in the frame's contentWindow. HTML The HTML is extremely simple and has just two elements: an <iframe> that contains the document we're going to scroll, and a <
div> into which we'll output the value of pageYOffset when we've finished the scroll. ...
...ame. Once that's done, the vertical scroll position is checked by looking at the value of pageYOffset in the frame's contentWindow. HTML The HTML is extremely simple and has just two elements: an <iframe> that contains the document we're going to scroll, and a <
div> into which we'll output the value of pageYOffset when we've finished the scroll. ...
...It then gets a reference to the element we want to scroll into view calling getElementById() on the frame's HTMLIFrameElement.contentDocument. With the target element in hand, we set the scrollTop of the frame's scrollingElement to the offsetTop of the target element. By doing so, we set the vertical scrolling position of ...
XPathResult.invalidIteratorState - Web APIs
_NODE_ITERATOR_TYPE or ORDERED_NODE_ITERATOR_TYPE and the document has been modified since this result was returned. Note: This feature is available in Web Workers. Syntax var iteratorState = result.invalidIteratorState; Return value A boolean value indicating whether the iterator has become invalid. Example The following example shows the use of the invalidIteratorState property. ...
... or ORDERED_NODE_ITERATOR_TYPE and the document has been modified since this result was returned. Note: This feature is available in Web Workers. Syntax var iteratorState = result.invalidIteratorState; Return value A boolean value indicating whether the iterator has become invalid. Example The following example shows the use of the invalidIteratorState property. ...
...s result was returned. Note: This feature is available in Web Workers. Syntax var iteratorState = result.invalidIteratorState; Return value A boolean value indicating whether the iterator has become invalid. Example The following example shows the use of the invalidIteratorState property. ...
... boolean value indicating whether the iterator has become invalid. Example The following example shows the use of the invalidIteratorState property. HTML <
div>XPath example</
div> <p>Iterator state: <output></output></p> JavaScript var xpath = "//
div"; var result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null); // Invalidates the iterator state document.querySelector("
div").remove(); document.querySelector("output").textContent = result.invalidIteratorState ? "invalid" : "valid"; Result Specifications Specification Status Comment Document Object Model (DOM) Level 3 XPath SpecificationThe definition of 'XPathResult.invalidIteratorState' in that specification. Recommendation Initial definition ...
XPathResult.singleNodeValue - Web APIs
kers. Syntax var value = result.singleNodeValue; Return value The return value is the Node value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the singleNodeValue property. ...
...value = result.singleNodeValue; Return value The return value is the Node value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the singleNodeValue property. ...
...= result.singleNodeValue; Return value The return value is the Node value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the singleNodeValue property. ...
...hResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not ANY_UNORDERED_NODE_TYPE or FIRST_ORDERED_NODE_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the singleNodeValue property. ...
Using the alertdialog role - Accessibility
ole, name and optionally description before announcing the focused element. Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: A basic alert dialog The code snippet below shows how to mark up an alert dialog that only provides a message and an OK button. ...
...ons may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: A basic alert dialog The code snippet below shows how to mark up an alert dialog that only provides a message and an OK button. ...
...he code snippet below shows how to mark up an alert dialog that only provides a message and an OK button. ...
... snippet below shows how to mark up an alert dialog that only provides a message and an OK button. ...
Using the aria-describedby attribute - Accessibility
y Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Application Landmark Descriptions In the example below, an introductory paragraph describes a calendar application. aria-describedby is used to associate the paragraph with the application container. ...
...mark Descriptions In the example below, an introductory paragraph describes a calendar application. aria-describedby is used to associate the paragraph with the application container. <
div role="application" aria-labelledby="calendar" aria-describedby="info"> <h1 id="calendar">Calendar</h1> <p id="info"> This calendar shows the game schedule for the Boston Red Sox. </p> <
div role="grid"> ... </
div> </
div> Example 2: A Close Button In the example below, a link that functions as a 'close' button on a dialog is described elsewhere in the document. ...
... </p> <
div role="grid"> ... </
div> </
div> Example 2: A Close Button In the example below, a link that functions as a 'close' button on a dialog is described elsewhere in the document. The aria-describedby attribute is used to associate the description with the link. <button aria-label="Close" aria-describedby="descriptionClose" onclick="myDialog.close()">X</button> ... ...
... functions as a 'close' button on a dialog is described elsewhere in the document. The aria-describedby attribute is used to associate the description with the link. <button aria-label="Close" aria-describedby="descriptionClose" onclick="myDialog.close()">X</button> ... <
div id="descriptionClose">Closing this window will discard any information entered and return you back to the main page</
div> Working Examples: Checkbox example uses aria-describedby Tooltip example uses aria-describedby Notes The aria-describedby attributed is not designed to reference descriptions on an external resource--since it is an ID, it must reference an element in the same DOM document. Used by ARIA roles all elements of the base markup Related ARIA techniques Using the aria-labelledby att...
Using the article role - Accessibility
archy of any nested article elements. Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. ...
...sistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. ...
...chnology should handle this technique. The information provided above is one of those opinions and therefore not normative. ...
... one of those opinions and therefore not normative. ...
Using the log role - Accessibility
nterrupted. Screen magnifiers may visually indicate that a log update has occurred. Note: Opinons may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Adding the role in the HTML code The snippet below shows how the log role is added directly into the html source code. ...
...cate that a log update has occurred. Note: Opinons may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Adding the role in the HTML code The snippet below shows how the log role is added directly into the html source code. ...
...e. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Adding the role in the HTML code The snippet below shows how the log role is added directly into the html source code. <
div id="liveregion" class="region" role="log"></
div> Example 2: Snippet from an example application This snippet creates the chat log in an AJAX chat application. ...
... With an area that has scrolling text, such as a stock ticker, the marquee role should be used instead. ...
Using the progressbar role - Accessibility
ents and assistive technology Screen readers should announce the progress updates as they occur. If the progress bar is labeled, the label text should be mentioned as well. Note: Opinions may differ on how assistive technology should handle this. The information provided above is one of those opinions and therefore not normative. ...
... they occur. If the progress bar is labeled, the label text should be mentioned as well. Note: Opinions may differ on how assistive technology should handle this. The information provided above is one of those opinions and therefore not normative. ...
... the label text should be mentioned as well. Note: Opinions may differ on how assistive technology should handle this. The information provided above is one of those opinions and therefore not normative. Examples Example 1: Basic progressbar with percentage values <
div role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">20 %</
div> Example 2: Using aria-valuetext <
div role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuetext="Step 2: Copying files... ...
... one of those opinions and therefore not normative. Examples Example 1: Basic progressbar with percentage values <
div role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">20 %</
div> Example 2: Using aria-valuetext <
div role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuetext="Step 2: Copying files... " aria-valuemax="100"> Step 2: Copying files... ...
Using the slider role - Accessibility
e(vol) { document.querySelector('#volume').value = vol; } Example 2: Text Values Sometimes, a slider is used to choose a value that is not, semantically, a number. In these cases, the aria-valuetext attribute is used to provide the appropriate text name for the currently selected value. In the example below, the slider is used to select a day of the week. ...
...lector('#volume').value = vol; } Example 2: Text Values Sometimes, a slider is used to choose a value that is not, semantically, a number. In these cases, the aria-valuetext attribute is used to provide the appropriate text name for the currently selected value. In the example below, the slider is used to select a day of the week. ...
...used to provide the appropriate text name for the currently selected value. In the example below, the slider is used to select a day of the week. ...
... provide the appropriate text name for the currently selected value. In the example below, the slider is used to select a day of the week. ...
ARIA: banner role - Accessibility
Description A banner landmark role converts the container element upon which it is applied into a header. ...
... Description A banner landmark role converts the container element upon which it is applied into a header. ...
...includes more than one banner landmark, each should have a unique label. Associated ARIA roles, states, and properties None Keyboard interactions None Required JavaScript features None Examples Here's a fake simple banner with a skip to navigation link, a logo, a title and a subtitle. As this is the main header for the site, we've added the banner landmark role to the container element. ...
... skip to navigation link, a logo, a title and a subtitle. As this is the main header for the site, we've added the banner landmark role to the container element. ...
ARIA: Complementary role - Accessibility
Description The complementary role is a landmark role. ...
... Description The complementary role is a landmark role. ...
...y identify and navigate to large sections of the document. Content listed within a container with the complementary landmark role should make sense if separated from the main content of the document. Using the <aside> element will automatically communicate a section has a role of complementary. Developers should always prefer using the correct semantic HTML element over using ARIA. ...
...Using too many landmark roles can create "noise" in screen readers, making it difficult to understand the overall layout of the page. Best practices Prefer HTML Using the <aside> element will automatically communicate a section has a role of complementary. If at all...
ARIA: contentinfo role - Accessibility
Using the <footer> element instead is recommended: <footer> <h2>Footer</h2> <!-- footer content --> </footer> Description The contentinfo role is a landmark used to identify a page footer. ...
...Using the <footer> element instead is recommended: <footer> <h2>Footer</h2> <!-- footer content --> </footer> Description The contentinfo role is a landmark used to identify a page footer. ...
...o". contentinfo landmarks present in content embedded via <iframe> elements do not count towards this limit. Using the <footer> element will automatically communicate a section has a role of contentinfo. Developers should always prefer using the correct semantic HTML element over using ARIA, making sure to test for known issues in VoiceOver. ...
...ng ARIA, making sure to test for known issues in VoiceOver. Examples <body> <!-- other page content --> <
div role="contentinfo"> <h2>MDN Web Docs</h2> <ul> <li><a href="#">Web Technologies</a></li> <li><a href="#">Learn Web Development</a></li> <li><a href="#">About MDN</a></li> <li><a href="#">Feedback</a></li> </ul> <p>(C) 2005-2018 Mozilla and in
dividual contributors. Content is available under <a href="#">these licenses</a>.</p> </
div> </body> Accessibility concerns Use sparingly Landmark roles are intended to identify larger overall sections of the document. Using too many landmark roles can create "noise" in screen readers, making it difficult to understand the overall layout of the page. One contentinfo landmark per page The <bod...
ARIA: form role - Accessibility
Important: Use an HTML <form> element to contain your form controls, rather than the ARIA form role, unless you have a very good reason. The HTML <form> element is sufficient to tell assistive technologies that there is a form. ...
... states or properties. Keyboard Interactions No role specific keyboard interactions Required JavaScript features onsubmit The onSubmit event handler handles the event raised when the form is submitted. Anything that is not a <form> cannot be submitted, therefore you would have to use JavaScript to build an alternative data submission mechanism, for example with XMLHTTPRequest. ...
... <form id="send-comment" aria-label="Add a comment"> .... </form> Accessibility concerns Use sparingly Landmark roles are intended to identify larger overall sections of the document. Using too many landmark roles can create "noise" in screen readers, making it difficult to understand the overall layout of the page. Inputs are not forms You do n...
...ue. Labeling landmarks Each <form> element and form role that needs to be exposed as a landmark must be given an accessible name. This name will allow an assitive technology user to be able to quickly understand the purpose of the form landmark. Use an aria-labelledby, aria-label or title on the same element that was given the role="form" to provide it an accessible name. Using role="form" <
div role="form" id="gift-cards" aria-label="Purchase a gift card"> <!-- form content --> </
div> Redundant descriptions Screen readers will announce the type of role the landmark is. Because of this, you do not need to describe what the landmark is in its label. For example, a declaration of role="form" with an of aria-label="Contact form" may be announced redundantly as, "contact form form". Bes...
ARIA: Main role - Accessibility
Subsections of this document could discuss their history, the different types, regions where they grow, etc. ...
...Subsections of this document could discuss their history, the different types, regions where they grow, etc. ...
...le of main. Developers should always prefer using the correct semantic HTML element over using ARIA. Documents and applications can be nested in the DOM, which may lead to having more than one main element as DOM descendants. If this is the case, include aria-owns to identify the relationship of the main to it's document or application ancestor. Example <body> <!-- primary navigation --> <
div role="main"> <h1>The The First Indochina War</h1> <!-- article content --> </
div> <!-- sidebar and footer --> </body> Accessibility concerns Use only one main role per document The main landmark role should only be used once per document. If a document contains two main roles, say updating page content when triggered by JavaScript, the inactive main role's presence should be remo...
...logy user to quickly bypass large sections of repeated content (main navigation, info banners, etc.). This allows the user to access the main content of the page faster. Adding an id attribute to the element with a declaration of role="main" allows it to be a target of a skip navigation link. <body> <a href="#main-content">Skip to main content</a> <!-- navigation and header content --> <
div id="main-content" role="main"> <!-- main page content --> </
div> </body> WebAIM: "Skip Navigation" Links Added benefits Certain technologies such as browser extensions can generate lists of all landmark roles present on a page, allowing non-screen reader users to also quickly identify and navigate to large sections of the document. Landmarks browser extension Specifications ...
ARIA: Navigation Role - Accessibility
Description The navigation role is a landmark role. Landmark roles provide a way to identify the organization and structure of a web page. By classifying and labeling sections of a page, structural information conveyed visually through layout is represented programmatically. Screen readers use landmark roles to provide keyboard navigation to important sections of a page. ...
.... Developers should always prefer using the correct semantic HTML element over using ARIA. Associated WAI-ARIA Roles, States, and Properties aria-label A brief description of the purpose of the navigation, omitting the term "navigation", as the screen reader will read both the role and the contents of the label. Keyboard Interactions None. Required JavaScript features None. ...
...Using too many landmark roles can create "noise" in screen readers, making it difficult to understand the overall layout of the page. ...
...<nav> element will automatically communicate a section has a role of navigation. If at all possible, prefer using it instead. Labeling landmarks Multiple landmarks If there is more than one navigation landmark role or <nav> element in a document, provide a label for each landmark. This label will allow an assitive technology user to be able to quickly understand the purpose of each landmark. <
div id="main-nav" role="navigation" aria-label="Main"> <!-- content --> </
div> ... <nav id="footer-nav" aria-label="Footer"> <!-- content --> </nav> Repeated landmarks If a navigation landmark role or <nav> element in a document is repeated in a document, and both landmarks have identical content, use the same label for each landmark. An example of this would be repeating the main navigation...
ARIA: tab role - Accessibility
ys to build tab-like functionality without JavaScript, there are no substitute combination of HTML and CSS only that will provide the same set of functionality that's required above for accessible tabs with content. Example This example combines the role tab with tablist and elements with tabpanel to create an interactive group of tabbed content. Here we are enclosing our group of content in a
div, with our tablist having an aria-label to label it for assistive technology. Each tab is a button with the attributes previously mentioned. The first tab has tabindex=0 on it, which we will later change to whatever tab has aria-selected=true. All of the tabpanel elements have tabindex=0 to make them tabbable, and all but the currently active one have the hidden attribute, which we will change wit...
...ents have tabindex=0 to make them tabbable, and all but the currently active one have the hidden attribute, which we will change with JavaScript. There is some basic styling applied that restyles the buttons and changes the z-index to of tab elements to give the illusion of it connecting to the tabpanel for active elements, and the illusion that inactive elements are behind the active tabpanel. ...
...to make them tabbable, and all but the currently active one have the hidden attribute, which we will change with JavaScript. There is some basic styling applied that restyles the buttons and changes the z-index to of tab elements to give the illusion of it connecting to the tabpanel for active elements, and the illusion that inactive elements are behind the active tabpanel. ...
... <button role="tab" aria-selected="true" aria-controls="panel-1" id="tab-1" tabindex="0"> First Tab </button> <button role="tab" aria-selected="false" aria-controls="panel-2" id="tab-2" tabindex="-1"> Second Tab </button> <button role="tab" aria-selected="false" aria-controls="panel-3" id="tab-3" tabindex="-1"> Third Tab </button> </
div> <
div id="panel-1" role="tabpanel" tabindex="0" aria-labelledby="tab-1"> <p>Content for the first panel</p> </
div> <
div id="panel-2" role="tabpanel" tabindex="0" aria-labelledby="tab-2" hidden> <p>Content for the second panel</p> </
div> <
div id="panel-3" role="tabpanel" tabindex="0" aria-labelledby="tab-3" hidden> <p>Content for the third panel</p> </
div> </
div> .tabs { ...
ARIA: listbox role - Accessibility
ing an ARIA role, state or property to make it accessible, then do so. The <select> element with descendant <option> elements handles all the needed interactions natively. Examples Example 1: A single select listbox that uses aria-activedescendant The snippet below shows how the listbox role is added directly into the html source code. ...
... snippet below shows how the listbox role is added directly into the html source code. ...
...e code. ...
...<p id="listbox1label" role="label">Select a color:</p> <
div role="listbox" tabindex="0" id="listbox1" aria-labelledby="listbox1label" onclick="return listItemClick(event);" onkeydown="return listItemKeyEvent(event);" onkeypress="return listItemKeyEvent(event);" aria-activedescendant="listbox1-1"> <
div role="option" id="listbox1-1" class="selected" aria-selected="true">Green</
div> <
div role="option" id="listbox1-2">Orange</
div> <
div role="option" id="listbox1-3">Red</
div> <
div role="option" id="listbox1-4">Blue</
div> <
div role="option" id="listbox1-5">Violet</
div> <
div role="option" id="listbox1-6">Periwinkle</
div> </
div> This could have more easily been handled with the native HTML <select> and <label> elements <label for="listbox1">Select a color:</label> <...
Web accessibility for seizures and physical reactions - Accessibility
rns, especially stripes of contrasting colors. That same article continues that many factors must combine to trigger the photosensitive reaction. Of note is that it includes the wavelength of light as a possible factor; wavelengths in the red part of the spectrum seem to be especially problematic. ...
...ly that: "In
dividuals who have photosensitive seizure disorders can have a seizure triggered by content that flashes at certain frequencies for more than a few flashes" and goes on to note, very specifically that: "People are even more sensitive to red flashing than to other colors, so a special test is provided for saturated red flashing". You don't even need an image or video to cause harm. A <
div> element set to change color and luminosity at high frequency, easily done via JavaScript, can cause real harm. And, flickering can occur everywhere. For example, "spinners" commonly used to display while pages load, can easily "flicker" while spinning. Additional concerns exist for in
dividuals with motor-skills problems. For example, the page for Trace Research & Development Center's Photosensi...
...er 2015) Computers and Epilepsy (pdf) describes more of the details on refresh rates. A very old article, Tech Republic's Epilepsy and CRT/LCD screen flicker, had an interesting response concerning the refresh rates in Hz. "This effect is noticable, and documented, up to 70 Hz." "These studies would seem to indicate that you should stay away from refresh rates under 70 Hz, and use a rate not
divisible by 10." Eric Bailey, of CSS-Tricks, found an innovative use the update feature which, used in combination with animation-duration or transition-duration, to conclude at a rate that is imperceptible to the human eye. In other words, Eric's techniques address the refresh-rate problem. The CSS below is from the article, CSS-TRICKS Revisiting prefers-reduced-motion, the reduced motion media q...
... How the Color Red Influences Our Behavior Scientific American By Susana Martinez-Conde, Stephen L. Macknik on November 1, 2014 Discussions Problems with WCAG 2.0 Flash Definition #553 WCAG 2.1 Understanding 2.3.1 - missing/vague dimension definitions #585 Epilepsy and Seizures Shedding Light on Photosensitivity, One of Epilepsy's Most Complex Conditions Epilepsy Foundation Certain in
dividuals are born with special sensitivity to flashing lights or contrasting visual patterns, such as stripes, grids and checkerboards. Because of this condition, their brain will produce seizure-like discharges when exposed to this type of visual stimulation Gamma oscillations and photosensitive epilepsy Current Biology Volume 27, Issue 9, 8 May 2017, Pages R336-R338 Certain visual images, even in...
Text labels and names - Accessibility
a descriptive label or name, so that assistive technology users can easily discover what its purpose is. A dialog box is generally denoted by an ARIA role="dialog" or role="alertdialog"; you can use the aria-label or aria-labelledby attributes to provide a label. Examples The following example shows a simple dialog box, defined as such using role="dialog" and labelled using aria-labelledby. ...
... following example shows a simple dialog box, defined as such using role="dialog" and labelled using aria-labelledby. <
div role="dialog" aria-labelledby="dialog1Title" aria-describedby="dialog1Desc"> <h2 id="dialog1Title">Your personal details were successfully updated</h2> <p id="dialog1Desc">You can change your details at any time in the user account section.</p> <button>Close</button> </
div> If the dialog box doesn't have a heading, you can instead use aria-label to contain the label text: <
div role="dialog" aria-label="Personal details updated confirmation"> <p>Your personal details were successfully updated. ...
...ime in the user account section.</p> <button>Close</button> </
div> If the dialog box doesn't have a heading, you can instead use aria-label to contain the label text: <
div role="dialog" aria-label="Personal details updated confirmation"> <p>Your personal details were successfully updated. You can change your details at any time in the user account section.</p> <button>Close</button> </
div> See also role="dialog" role="alertdialog" aria-label aria-labelledby WAI-ARIA: dialog role Dialog authoring practices Documents must have a title It is important on each HTML document to include a <title> that describes the page's purpose. A common navigation technique for users of assistive technology is to infer what content a page contains by reading its title. If the title is not...
... fieldset. Use a legend to label a fieldset When grouping a set of form elements together with a <fieldset> element, you should include a nested <legend> element inside it, containing a clear description of the group. Users of assistive technology find this description helpful when trying to work out the overall purpose of the group. Without the legend, they would have to navigate around the in
dividual form controls in the group to infer an idea of the overall purpose, which could result in confusion. Examples <form> <fieldset> <legend>Choose your favorite monster</legend> <input type="radio" id="kraken" name="monster"> <label for="kraken">Kraken</label><br/> <input type="radio" id="sasquatch" name="monster"> <label for="sasquatch">Sasquatch</label><br/> <inp...
-webkit-border-before - CSS: Cascading Style Sheets
/* Border values */ -webkit-border-before: 1px; -webkit-border-before: 2px dotted; -webkit-border-before: medium dashed blue; /* Global values */ -webkit-border-before: inherit; -webkit-border-before: initial; -webkit-border-before: unset; -webkit-border-before can be used to set the values for one or more of: -webkit-border-before-width, -webkit-border-before-style, and -webkit-border-before-color. It maps to a physical border depending on the element's writing mode, directionality, and text orientation. ...
... ...
... ...
... ...
::-webkit-scrollbar - CSS: Cascading Style Sheets
Proin at nulla elementum, consectetur ex eget, commodo ante. Sed eros mi, bibendum ut dignissim et, maximus eget nibh. Phasellus blandit quam turpis, at mollis velit pretium ut. Nunc consequat efficitur ultrices. Nullam hendrerit posuere est. Nulla libero sapien, egestas ac felis porta, cursus u...
...a libero sapien, egestas ac felis porta, cursus ultricies quam. Vestibulum tincidunt accumsan sapien, a fringilla dui semper in. Vivamus consectetur ipsum a ornare blandit. Aenean tempus at lorem sit amet faucibus. Curabitur nibh justo, faucibus sed velit cursus, mattis cursus dolor. Pellentesque id pretium est. Quisque convallis nisi a diam malesuada mollis. Aliquam at enim ligula. ...
...o sapien, egestas ac felis porta, cursus ultricies quam. Vestibulum tincidunt accumsan sapien, a fringilla dui semper in. Vivamus consectetur ipsum a ornare blandit. Aenean tempus at lorem sit amet faucibus. Curabitur nibh justo, faucibus sed velit cursus, mattis cursus dolor. Pellentesque id pretium est. Quisque convallis nisi a diam malesuada mollis. Aliquam at enim ligula. ...
... in. Vivamus consectetur ipsum a ornare blandit. Aenean tempus at lorem sit amet faucibus. Curabitur nibh justo, faucibus sed velit cursus, mattis cursus dolor. Pellentesque id pretium est. Quisque convallis nisi a diam malesuada mollis. Aliquam at enim ligula. </
div> <
div class="invisible-scrollbar"> Thisisaveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword </
div> <
div class="mostly-customized-scrollbar"> Thisisaveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerylongword<br> And pretty tall<br> thing with weird scrollbars.<br> Who thought scrollbars could be made weeeeird? </
div> Specifications Not part of any standard. ...
:defined - CSS: Cascading Style Sheets
c custom element */ simple-custom:defined { display: block; } Syntax :defined Examples Hiding elements until they are defined The following snippets are taken from our defined-pseudo-class demo (see it live also). ...
...defined { display: block; } Syntax :defined Examples Hiding elements until they are defined The following snippets are taken from our defined-pseudo-class demo (see it live also). ...
...isplay: block; } Syntax :defined Examples Hiding elements until they are defined The following snippets are taken from our defined-pseudo-class demo (see it live also). ...
... defined-pseudo-class demo (see it live also). ...
:first-child - CSS: Cascading Style Sheets
The :first-child CSS pseudo-class represents the first element among a group of sibling elements. /* Selects any <p> that is the first element among its siblings */ p:first-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...a group of sibling elements. /* Selects any <p> that is the first element among its siblings */ p:first-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
... of sibling elements. /* Selects any <p> that is the first element among its siblings */ p:first-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...first-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
:indeterminate - CSS: Cascading Style Sheets
type="checkbox"> elements whose indeterminate property is set to true by JavaScript <input type="radio"> elements, when all radio buttons with the same name value in the form are unchecked <progress> elements in an indeterminate state Syntax :indeterminate Examples Checkbox & radio button This example applies special styles to the labels associated with indeterminate form fields. ...
...elements, when all radio buttons with the same name value in the form are unchecked <progress> elements in an indeterminate state Syntax :indeterminate Examples Checkbox & radio button This example applies special styles to the labels associated with indeterminate form fields. ...
...ts, when all radio buttons with the same name value in the form are unchecked <progress> elements in an indeterminate state Syntax :indeterminate Examples Checkbox & radio button This example applies special styles to the labels associated with indeterminate form fields. ...
... in an indeterminate state Syntax :indeterminate Examples Checkbox & radio button This example applies special styles to the labels associated with indeterminate form fields. ...
:invalid - CSS: Cascading Style Sheets
S pseudo-class represents any <input> or other <form> element whose contents fail to validate. /* Selects any invalid <input> */ input:invalid { background-color: pink; } This pseudo-class is useful for highlighting field errors for the user. Syntax :invalid Examples This example presents a simple form that colors elements green when they validate and red when they don't. ...
...y invalid <input> */ input:invalid { background-color: pink; } This pseudo-class is useful for highlighting field errors for the user. Syntax :invalid Examples This example presents a simple form that colors elements green when they validate and red when they don't. ...
... <input> */ input:invalid { background-color: pink; } This pseudo-class is useful for highlighting field errors for the user. Syntax :invalid Examples This example presents a simple form that colors elements green when they validate and red when they don't. ...
...x :invalid Examples This example presents a simple form that colors elements green when they validate and red when they don't. ...
:lang() - CSS: Cascading Style Sheets
ceptable values are specified in the HTML spec. Examples In this example, the :lang() pseudo-class is used to match the parents of quote elements (<q>) using child combinators. Note that this doesn't illustrate the only way to do this, and that the best method to use depends on the type of document. Also note that Unicode values are used to specify some of the special quote characters. ...
..., the :lang() pseudo-class is used to match the parents of quote elements (<q>) using child combinators. Note that this doesn't illustrate the only way to do this, and that the best method to use depends on the type of document. Also note that Unicode values are used to specify some of the special quote characters. ...
...:lang() pseudo-class is used to match the parents of quote elements (<q>) using child combinators. Note that this doesn't illustrate the only way to do this, and that the best method to use depends on the type of document. Also note that Unicode values are used to specify some of the special quote characters. ...
...using child combinators. Note that this doesn't illustrate the only way to do this, and that the best method to use depends on the type of document. Also note that Unicode values are used to specify some of the special quote characters. HTML <
div lang="en"><q>This English quote has a <q>nested</q> quote inside.</q></
div> <
div lang="fr"><q>This French quote has a <q>nested</q> quote inside.</q></
div> <
div lang="de"><q>This German quote has a <q>nested</q> quote inside.</q></
div> CSS :lang(en) > q { quotes: '\201C' '\201D' '\2018' '\2019'; } :lang(fr) > q { quotes: '<< ' ' >>'; } :lang(de) > q { quotes: '>>' '<<' '\2039' '\203A'; } Result Specifications Specification Status Comment Selectors Level 4The definition of ':lang()' in that specification. Work...
:last-child - CSS: Cascading Style Sheets
The :last-child CSS pseudo-class represents the last element among a group of sibling elements. /* Selects any <p> that is the last element among its siblings */ p:last-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...ong a group of sibling elements. /* Selects any <p> that is the last element among its siblings */ p:last-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...roup of sibling elements. /* Selects any <p> that is the last element among its siblings */ p:last-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
... p:last-child { color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
:only-of-type - CSS: Cascading Style Sheets
siblings of the same type. /* Selects each <p>, but only if it is the */ /* only <p> element inside its parent */ p:only-of-type { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
...f the same type. /* Selects each <p>, but only if it is the */ /* only <p> element inside its parent */ p:only-of-type { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
... type. /* Selects each <p>, but only if it is the */ /* only <p> element inside its parent */ p:only-of-type { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. ...
.../* only <p> element inside its parent */ p:only-of-type { background-color: lime; } Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. Syntax :only-of-type Examples Styling elements with no siblings of the same type HTML <main> <
div>I am `
div` #1.</
div> <p>I am the only `p` among my siblings.</p> <
div>I am `
div` #2.</
div> <
div>I am `
div` #3. <i>I am the only `i` child.</i> <em>I am `em` #1.</em> <em>I am `em` #2.</em> </
div> </main> CSS main :only-of-type { color: red; } Result Specifications Specification Status Comment Selectors Level 4The definition of ':only-of-type' in that specification. Working Draft Matching elements are not ...
:scope - CSS: Cascading Style Sheets
HTML <p id="para"> This is a paragraph. It is not an interesting paragraph. Sorry about that. </p> <p id="output"></p> Result Direct children A situation where the :scope pseudo-class prove to be useful is when you need to get direct descendant of an already retrieved Element. ...
... pseudo-class prove to be useful is when you need to get direct descendant of an already retrieved Element. ...
...be useful is when you need to get direct descendant of an already retrieved Element. ...
... get direct descendant of an already retrieved Element. JavaScript var context = document.getElementById('context'); var selected = context.querySelectorAll(':scope >
div'); document.getElementById('results').innerHTML = Array.prototype.map.call(selected, function (element) { return '#' + element.getAttribute('id'); }).join(', '); HTML <
div id="context"> <
div id="element-1"> <
div id="element-1.1"></
div> <
div id="element-1.2"></
div> </
div> <
div id="element-2"> <
div id="element-2.1"></
div> </
div> </
div> <p> Selected elements ids : <span id="results"></span> </p> Result Specifications Specification Status Comment Selectors Level 4The definition of ':scope' in that specification. Working Draft Initial ...
orientation - CSS: Cascading Style Sheets
the browser to use landscape styles instead of portrait. Syntax The orientation feature is specified as a keyword value chosen from the list below. Keyword values portrait The viewport is in a portrait orientation, i.e., the height is greater than or equal to the width. landscape The viewport is in a landscape orientation, i.e., the width is greater than the height. ...
...r to use landscape styles instead of portrait. Syntax The orientation feature is specified as a keyword value chosen from the list below. Keyword values portrait The viewport is in a portrait orientation, i.e., the height is greater than or equal to the width. landscape The viewport is in a landscape orientation, i.e., the width is greater than the height. ...
...se landscape styles instead of portrait. Syntax The orientation feature is specified as a keyword value chosen from the list below. Keyword values portrait The viewport is in a portrait orientation, i.e., the height is greater than or equal to the width. landscape The viewport is in a landscape orientation, i.e., the width is greater than the height. ...
...e styles instead of portrait. Syntax The orientation feature is specified as a keyword value chosen from the list below. Keyword values portrait The viewport is in a portrait orientation, i.e., the height is greater than or equal to the width. landscape The viewport is in a landscape orientation, i.e., the width is greater than the height. Examples HTML <
div>Box 1</
div> <
div>Box 2</
div> <
div>Box 3</
div> CSS body { display: flex; }
div { background: yellow; } @media (orientation: landscape) { body { flex-direction: row; } } @media (orientation: portrait) { body { flex-direction: column; } } Result Specifications Specification Status Comment Media Queries Level 4The definition of 'orientation' in that specification. Ca...
Aligning Items in a Flex Container - CSS: Cascading Style Sheets
this example below. Change the size of the container or nested element and the nested element always remains centered. Properties that control alignment The properties we will look at in this guide are as follows. justify-content -- controls alignment of all items on the main axis. align-items -- controls alignment of all items on the cross axis. align-self -- controls alignment of an in
dividual flex item on the cross axis. align-content -- described in the spec as for "packing flex lines"; controls space between flex lines on the cross axis. We will also discover how auto margins can be used for alignment in flexbox. Note: The alignment properties in Flexbox have been placed into their own specification -- CSS Box Alignment Level 3. It is expected that this spec will ultimatel...
...ample, the flex container has align-items: flex-start, which means the items are all aligned to the start of the cross axis. I have targeted the first item using a first-child selector and set that item to align-self: stretch; another item has been selected using its class of selected and given align-self: center. You can change the value of align-items or change the values of align-self on the in
dividual items to see how this works. Changing the main axis So far we have looked at the behaviour when our flex-direction is row, and while working in a language written top to bottom. This means that the main axis runs along the row horizontally, and our cross axis alignment moves the items up and down. If we change our flex-direction to column, align-items and align-self will align the ite...
...own. If we change our flex-direction to column, align-items and align-self will align the items to the left and right. You can try this out in the example below, which has a flex container with flex-direction: column yet otherwise is exactly the same as the previous example. Aligning content on the cross axis -- the align-content property So far we have been aligning the items, or an in
dividual item inside the area defined by the flex-container. If you have a wrapped multiple-line flex container then you might also want to use the align-content property to control the distribution of space between the rows. In the specification this is described as packing flex lines. For align-content to work you need more height in your flex container than is required to display the items. It th...
...l then change to the end of that axis -- so to the location where your lines would wrap if working in rows, or at the end of your last paragraph of text in the block direction. Using auto margins for main axis alignment We don't have a justify-items or justify-self property available to us on the main axis as our items are treated as a group on that axis. However it is possible to do some in
dividual alignment in order to separate an item or a group of items from others by using auto margins along with flexbox. A common pattern is a navigation bar where some key items are aligned to the right, with the main group on the left. You might think that this should be a use case for a justify-self property, however consider the image below. I have three items on one side and two on the other. ...
Using Media Queries for Accessibility - CSS: Cascading Style Sheets
Indicates that the user has made no preference known to the system. reduce Indicates that user has notified the system that they prefer an interface that minimizes the amount of movement or animation, preferably to the point where all non-essential movement is removed. Example This example has an annoying animation unless you turn on Reduce Motion in your accessibility preferences. ...
...o preference known to the system. reduce Indicates that user has notified the system that they prefer an interface that minimizes the amount of movement or animation, preferably to the point where all non-essential movement is removed. Example This example has an annoying animation unless you turn on Reduce Motion in your accessibility preferences. ...
...e-on-black color variation. ...
...displayed in high contrast mode with any color variation, a black-on-white color variation, and a white-on-black color variation, respectively. ...
animation-timing-function - CSS: Cascading Style Sheets
If no animation-timing-function is specified on a keyframe, the corresponding value of animation-timing-function from the element to which the animation is applied is used for that keyframe. A keyframe's timing function is applied on a property-by-property basis from the keyframe on which it is specified until the next keyframe specifying that property, or un...
...n the 100% or to keyframe will never be used. Values <timing-function> The timing function that corresponds to a given animation, as determined by animation-name. The non-step keyword values (ease, linear, ease-in-out, etc.) each represent cubic Bezier curve with fixed four point values, with the cubic-bezier() function value allowing for a non-predefined value. The step timing functions
divides the input time into a specified number of intervals that are equal in length. It is defined by a number of steps and a step position. ease Equal to cubic-bezier(0.25, 0.1, 0.25, 1.0), the default value, increases in velocity towards the middle of the animation, slowing back down at the end. linear Equal to cubic-bezier(0.0, 0.0, 1.0, 1.0), animates at an even speed. ease-in Equal to c...
...>, <number <a href="/docs/CSS/Value_definition_syntax#Brackets" title="Brackets: enclose several entities, combinators, and multipliers to transform them as a single component">[0,1]>, <number>)<step-timing-function> = step-start | step-end | steps(<integer>[, <step-position>]?)where <step-position> = jump-start | jump-end | jump-none | jump-both | start | end Examples Cubic-Bezier examples <
div class="parent"> <
div class="ease">ease</
div> <
div class="easein">ease-in</
div> <
div class="easeout">ease-out</
div> <
div class="easeinout">ease-in-out</
div> <
div class="linear">linear</
div> <
div class="cb">cubic-bezier(0.2,-2,0.8,2)</
div> </
div> .parent >
div[class] { animation-name: changeme; animation-duration: 10s; animation-iteration-count: infinite; margin-bottom:...
...or: yellow; border: 1px solid orange; } } .ease { animation-timing-function: ease; } .easein { animation-timing-function: ease-in; } .easeout { animation-timing-function: ease-out; } .easeinout { animation-timing-function: ease-in-out; } .linear { animation-timing-function: linear; } .cb { animation-timing-function: cubic-bezier(0.2,-2,0.8,2); } Step examples <
div class="parent"> <
div class="jump-start">jump-start</
div> <
div class="jump-end">jump-end</
div> <
div class="jump-both">jump-both</
div> <
div class="jump-none">jump-none</
div> <
div class="start">start</
div> <
div class="end">end</
div> <
div class="step-start">step-start</
div> <
div class="step-end">step-end</
div> </
div> .parent >
div[class] { animation-name: changeme; animation-...
background-repeat - CSS: Cascading Style Sheets
ion Initial valuerepeatApplies toall elements. ...
...repeatApplies toall elements. ...
...t also applies to ::first-letter and ::first-line.InheritednoComputed valuea list, each item consisting of two keywords, one per dimensionAnimation typediscrete Formal syntax <repeat-style>#where <repeat-style> = repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2} Examples Setting background-repeat HTML <ol> <li>no-repeat <
div class="one"></
div> </li> <li>repeat <
div class="two"></
div> </li> <li>repeat-x <
div class="three"></
div> </li> <li>repeat-y <
div class="four"></
div> </li> <li>space <
div class="five"></
div> </li> <li>round <
div class="six"></
div> </li> <li>repeat-x, repeat-y (multiple images) <
div class="seven"></
div> </li> </ol> CSS /* Shared for all
DIVS in example */ ol, li { margin: 0; padding: 0; } li...
... <li>repeat-x <
div class="three"></
div> </li> <li>repeat-y <
div class="four"></
div> </li> <li>space <
div class="five"></
div> </li> <li>round <
div class="six"></
div> </li> <li>repeat-x, repeat-y (multiple images) <
div class="seven"></
div> </li> </ol> CSS /* Shared for all
DIVS in example */ ol, li { margin: 0; padding: 0; } li { margin-bottom: 12px; }
div { background-image: url(https://mdn.mozillademos.org/files/12005/starsolid.gif); width: 160px; height: 70px; } /* Background repeats */ .one { background-repeat: no-repeat; } .two { background-repeat: repeat; } .three { background-repeat: repeat-x; } .four { background-repeat: repeat-y; } .five { background-repeat: space; } .six { background-repeat: round; } /* Multiple ...
border-block-end - CSS: Cascading Style Sheets
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
... ...
... Editor's Draft Initial definition ...
... Editor's Draft Initial definition ...
border-block-start - CSS: Cascading Style Sheets
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
... Edito...
... Editor's Draft Initial definition ...
... Editor's Draft Initial definition ...
border-block - CSS: Cascading Style Sheets
border-block: 1px; border-block: 2px dotted; border-block: medium dashed blue; border-block can be used to set the values for one or more of border-block-width, border-block-style, and border-block-color setting both the start and end in the block dimension at once. The physical borders to which it maps depends on the element's writing mode, directionality, and text orientation. ...
... Editor's...
... Editor's Draft Initial definition ...
... Editor's Draft Initial definition ...
border-inline-end - CSS: Cascading Style Sheets
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
... Editor'...
... Editor's Draft Initial definition ...
... Editor's Draft Initial definition ...
border-inline-start - CSS: Cascading Style Sheets
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
... Edi...
... Editor's Draft Initial definition ...
... Editor's Draft Initial definition ...
border-inline - CSS: Cascading Style Sheets
border-inline: 1px; border-inline: 2px dotted; border-inline: medium dashed blue; The physical borders to which border-inline maps depends on the element's writing mode, directionality, and text orientation. It corresponds to the border-top and border-bottom or border-right, and border-left properties, depending on the values defined for writing-mode, direction, and text-orientation. The borders in the other dimension can be set with border-block, which sets border-block-start, and border-block-end. ...
... Editor...
... Editor's Draft Initial definition ...
... Editor's Draft Initial definition ...
<display-inside> - CSS: Cascading Style Sheets
or display: grid is specified, will set their outer value to block. This will result in expected behavior; for example if you specify an element to be display: grid, you would expect that the box created on the grid container would be a block level box. Examples In this example the parent box has been given display: flow-root and so establishes a new BFC and contains the floated item. ...
... specified, will set their outer value to block. This will result in expected behavior; for example if you specify an element to be display: grid, you would expect that the box created on the grid container would be a block level box. Examples In this example the parent box has been given display: flow-root and so establishes a new BFC and contains the floated item. ...
...to block. This will result in expected behavior; for example if you specify an element to be display: grid, you would expect that the box created on the grid container would be a block level box. Examples In this example the parent box has been given display: flow-root and so establishes a new BFC and contains the floated item. ...
...r example if you specify an element to be display: grid, you would expect that the box created on the grid container would be a block level box. Examples In this example the parent box has been given display: flow-root and so establishes a new BFC and contains the floated item. ...
display - CSS: Cascading Style Sheets
splay CSS property sets whether an element is treated as a block or inline element and the layout used for its children, such as flow layout, grid or flex. Formally, the display property sets an element's inner and outer display types. The outer type sets an element's participation in flow layout; the inner type sets the layout of children. Some values of display are fully defined in their own in
dividual specifications; for example the detail of what happens when display: flex is declared is defined in the CSS Flexible Box Model specification. See the table at the end of this document for all of the in
dividual specifications. Syntax The CSS display property is specified using keyword values. Keyword values are grouped into six value categories: .container { display: [ <display-outside>...
...an inline flex container as follows: .container { display: inline flex; } This can currently be specified using a single value. .container { display: inline-flex; } For more information on these changes to the specification, see the article Adapting to the new two-value syntax of display. Global /* Global values */ display: inherit; display: initial; display: unset; Description The in
dividual pages for the different types of value that display can have set on it feature multiple examples of those values in action -- see the Syntax section. In addition, see the following material, which covers the various values of display in depth. Adapting to the new two-value syntax of display CSS Flow Layout (display: block, display: inline) Block and Inline Layout in Normal Flow Flow...
...ren, so that it is easier to see the effect the display values are having. Note: We've not included any of the modern two-value syntax, as support for that is still fairly limited. ...
... <
div> <label for="display">Choose a display value:</label> <select id="display"> <option selected>block</option> <option>inline</option> <option>inline-block</option> <option>none</option> <option>flex</option> <option>inline-flex</option> <option>grid</option> <option>inline-grid</option> <option>table</option> <option>list-item</option> </select> </
div> CSS html { font-family: helvetica, arial, sans-serif; letter-spacing: 1px; padding-top: 10px; } article { background-color: red; } article span { background-color: black; color: white; margin: 1px; } article, span { padding: 10px; border-radius: 7px; } article,
div { margin: 20px; } JavaScript const articles = document.querySelectorAll('.container'); const select = do...
font-weight - CSS: Cascading Style Sheets
t. For TrueType or OpenType variable fonts, the "wght" variation is used to implement varying widths. For the example below to work, you'll need a browser that supports the CSS Fonts Level 4 syntax in which font-weight can be any number between 1 and 1000. ...
...onts Level 4 syntax in which font-weight can be any number between 1 and 1000. ...
...*/ span { font-weight: lighter; } Result Specifications Specification Status Comme...
...Setting font weights HTML <p> Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice "without pictures or conversations?" </p> <
div>I'm heavy<br/> <span>I'm lighter</span> </
div> CSS /* Set paragraph text to be bold. */ p { font-weight: bold; } /* Set
div text to two steps heavier than normal but less than a standard bold. */
div { font-weight: 600; } /* Set span text to be one step lighter than its parent. */ span { font-weight: lighter; } Result Specifications Specification Status Comment CSS Fonts Module Level 4The defi...
margin - CSS: Cascading Style Sheets
er (clockwise). Values <length> The size of the margin as a fixed value. <percentage> The size of the margin as a percentage, relative to the width of the containing block. auto The browser selects a suitable margin to use. For example, in certain cases this value can be used to center an element. ...
... of the margin as a fixed value. <percentage> The size of the margin as a percentage, relative to the width of the containing block. auto The browser selects a suitable margin to use. For example, in certain cases this value can be used to center an element. ...
... margin as a fixed value. <percentage> The size of the margin as a percentage, relative to the width of the containing block. auto The browser selects a suitable margin to use. For example, in certain cases this value can be used to center an element. ...
...ntage, relative to the width of the containing block. auto The browser selects a suitable margin to use. For example, in certain cases this value can be used to center an element. ...
mask-border - CSS: Cascading Style Sheets
mask-border-source'> | <'mask-border-slice'> [ / <'mask-border-width'>? [ / <'mask-border-outset'> ]? ]? | <'mask-border-repeat'> | <'mask-border-mode'> Examples Setting a bitmap-based mask border In this example, we will mask an element's border with a diamond pattern. ...
... ]? ]? | <'mask-border-repeat'> | <'mask-border-mode'> Examples Setting a bitmap-based mask border In this example, we will mask an element's border with a diamond pattern. ...
...bitmap-based mask border In this example, we will mask an element's border with a diamond pattern. The source for the mask is a ".png" file of 90 by 90 pixels, with three diamonds going vertically and horizontally: HTML <
div id="bitmap">This element is surrounded by a bitmap-based mask border! ...
...ree diamonds going vertically and horizontally: HTML <
div id="bitmap">This element is surrounded by a bitmap-based mask border! ...
place-items - CSS: Cascading Style Sheets
lignment container. ...
...nt container. ...
...0px; } #item2 { background-color: #a0c8ff; min-height: 50px; } #item3 { background-color: #ffa08c; min-height: 40px; } #item4 { background-color: #ffff8c; min-height: 60px; } #item5 { background-color: #ff8cff; min-height: 70px; } #item6 { background-color: #8cffff; min-height: 50px; font-size: 30px; } select { font-size: 16px; } .row { margin-top: 10px; } HTML <
div id="container" class="flex"> <
div id="item1">1</
div> <
div id="item2">2</
div> <
div id="item3">3</
div> <
div id="item4">4</
div> <
div id="item5">5</
div> <
div id="item6">6</
div> </
div> <
div class="row"> <label for="display">display: </label> <select id="display"> <option value="flex">flex</option> <option value="grid">grid</option> </select> </
div> <
div class="row"> <labe...
...>flex-end normal</option> <option value="left auto">left auto</option> <option value="right normal">right normal</option> <option value="baseline normal">baseline normal</option> <option value="first baseline auto">first baseline auto</option> <option value="last baseline normal">last baseline normal</option> <option value="stretch auto">stretch auto</option> </select> </
div> JavaScript var values = document.getElementById('values'); var display = document.getElementById('display'); var container = document.getElementById('container'); values.addEventListener('change', function (evt) { container.style.placeItems = evt.target.value; }); display.addEventListener('change', function (evt) { container.className = evt.target.value; }); CSS #container { heigh...
repeating-radial-gradient() - CSS: Cascading Style Sheets
ops where <extent-keyword> = closest-corner | closest-side | farthest-corner | farthest-side and <color-stop-list> = [ <linear-color-stop> [, <color-hint>? ]? ]#, <linear-color-stop> and <linear-color-stop> = <color> [ <color-stop-length> ]? ...
...closest-corner | closest-side | farthest-corner | farthest-side and <color-stop-list> = [ <linear-color-stop> [, <color-hint>? ]? ]#, <linear-color-stop> and <linear-color-stop> = <color> [ <color-stop-length> ]? ...
...lor> [ <color-stop-length> ]? ...
... and <color-stop-length> = [ <percentage> | <length> ]{1,2} and <color-hint> = [ <percentage> | <length> ] Examples Black and white gradient <
div class="radial-gradient"></
div> .radial-gradient { width: 120px; height: 120px; } .radial-gradient { background: repeating-radial-gradient(black, black 5px, white 5px, white 10px); } Farthest-corner <
div class="radial-gradient"></
div> .radial-gradient { width: 240px; height: 120px; } .radial-gradient { background: repeating-radial-gradient(ellipse farthest-corner at 20% 20%, red, black 5%, blue 5%, green 10%); background: repeating-radial-gradient(ellipse farthest-corner at 20% 20%, red 0 5%, green 5% 10%); } The elliptical gradient will be centered 20% from the top left, and will repeat 10 times b...
rotate - CSS: Cascading Style Sheets
This maps better to typical user interface usage, and saves having to remember the exact order of transform functions to specify in the transform property. Syntax /* Keyword values */ rotate: none; /* Angle value */ rotate: 90deg; rotate: 0.25turn; rotate: 1.57rad; /* x, y, or z axis name plus angle */ rotate: x 90deg; rotate: y 0.25turn; rotate: z 1.57rad; /* Vector plus angle value */ rotate: 1 1 1 90deg; Values angle value An <angle> specifying the angle to rotate the affected element through, around the Z axis. Equivalent to a rotate() (2D rotation) function. ...
... element through. Equivalent to a rotate3d() (3D rotation) function. none Specifies that no rotation should be applied. ...
...3d() (3D rotation) function. none Specifies that no rotation should be applied. ...
... Formal definition Initial valuenoneApplies totransformable elementsInheritednoComputed valueas specifiedAnimation typea transformCreates stacking contextyes Formal syntax none | <angle> | [ x | y | z | <number>{3} ] && <angle> Examples Rotate an element on hover HTML <
div> <p class="rotate">Rotation</p> </
div> CSS * { box-sizing: border-box; } html { font-family: sans-serif; }
div { width: 150px; margin: 0 auto; } p { padding: 10px 5px; border: 3px solid black; border-radius: 20px; width: 150px; font-size: 1.2rem; text-align: center; } .rotate { transition: rotate 1s; }
div:hover .rotate { rotate: 1 -0.5 1 180deg; } Result Specifications Specification Status Comment CSS Transforms Level 2The definition of 'in
dividua...
scroll-margin-inline-end - CSS: Cascading Style Sheets
length> Examples Simple demonstration This example implements something very similar to the interactive example above, except that here we'll explain to you how it's implemented. The aim here is to create four horizontally-scrolling blocks, the second and third of which snap into place, near but not quite at the right of each block. HTML The HTML that represents the blocks is very simple: <
div class="scroller"> <
div>1</
div> <
div>2</
div> <
div>3</
div> <
div>4</
div> </
div> CSS Let's walk through the CSS. the outer container is styled like this: .scroller { text-align: left; width: 250px; height: 250px; overflow-x: scroll; display: flex; box-sizing: border-box; border: 1px solid #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping...
... #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping are overflow-x: scroll, which makes sure the contents will scroll and not be hidden, and scroll-snap-type: x mandatory, which dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
...ich dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
... scroll-snap-align: end; } .scroller >
div:nth-child(2n) { background-color: #fff; color: #663399; } The most relevant part here is scroll-snap-align: end, which specifies that the right-hand edges (the "ends" along the x axis, in our case) are the designated snap points. Last of all we specify the scroll margin values, a different one for the second and third child elements: .scroller >
div:nth-child(2) { scroll-margin-inline-end: 1rem; } .scroller >
div:nth-child(3) { scroll-margin-inline-end: 2rem; } This means that when scrolling past the middle child elements, the scrolling will snap to 1rem outside the inline end edge of the second <
div>, and 2rems outside the inline end edge of the third <
div>. Result Try it for yourself: Specifications Specification St...
scroll-margin-inline-start - CSS: Cascading Style Sheets
<length> Examples Simple demonstration This example implements something very similar to the interactive example above, except that here we'll explain to you how it's implemented. The aim here is to create four horizontally-scrolling blocks, the second and third of which snap into place, near but not quite at the left of each block. HTML The HTML that represents the blocks is very simple: <
div class="scroller"> <
div>1</
div> <
div>2</
div> <
div>3</
div> <
div>4</
div> </
div> CSS Let's walk through the CSS. the outer container is styled like this: .scroller { text-align: left; width: 250px; height: 250px; overflow-x: scroll; display: flex; box-sizing: border-box; border: 1px solid #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping...
... #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping are overflow-x: scroll, which makes sure the contents will scroll and not be hidden, and scroll-snap-type: x mandatory, which dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
...h dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
...oll-snap-align: start; } .scroller >
div:nth-child(2n) { background-color: #fff; color: #663399; } The most relevant part here is scroll-snap-align: start, which specifies that the left-hand edges (the "starts" along the x axis, in our case) are the designated snap points. Last of all we specify the scroll margin-values, a different one for the second and third child elements: .scroller >
div:nth-child(2) { scroll-margin-inline-start: 1rem; } .scroller >
div:nth-child(3) { scroll-margin-inline-start: 2rem; } This means that when scrolling past the middle child elements, the scrolling will snap to 1rem outside the inline start edge of the second <
div>, and 2rems outside the inline start edge of the third <
div>. Result Try it for yourself: Specifications Specificati...
scroll-margin-inline - CSS: Cascading Style Sheets
h>{1,2} Examples Simple demonstration This example implements something very similar to the interactive example above, except that here we'll explain to you how it's implemented. The aim here is to create four horizontally-scrolling blocks, the second and third of which snap into place, near but not quite at the right of each block. HTML The HTML that represents the blocks is very simple: <
div class="scroller"> <
div>1</
div> <
div>2</
div> <
div>3</
div> <
div>4</
div> </
div> CSS Let's walk through the CSS. the outer container is styled like this: .scroller { text-align: left; width: 250px; height: 250px; overflow-x: scroll; display: flex; box-sizing: border-box; border: 1px solid #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping...
... #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping are overflow-x: scroll, which makes sure the contents will scroll and not be hidden, and scroll-snap-type: x mandatory, which dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
...ich dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
... scroll-snap-align: end; } .scroller >
div:nth-child(2n) { background-color: #fff; color: #663399; } The most relevant part here is scroll-snap-align: end, which specifies that the right-hand edges (the "ends" along the x axis, in our case) are the designated snap points. Last of all we specify the scroll margin values, a different one for the second and third child elements: .scroller >
div:nth-child(2) { scroll-margin-inline: 1rem; } .scroller >
div:nth-child(3) { scroll-margin-inline: 2rem; } This means that when scrolling past the middle child elements, the scrolling will snap to 1rem outside the inline end edge of the second <
div>, and 2rems outside the inline end edge of the third <
div>. Note: Here we are setting scroll-margin on the start and end of the inline axis (x ...
scroll-margin - CSS: Cascading Style Sheets
th>{1,4} Examples Simple demonstration This example implements something very similar to the interactive example above, except that here we'll explain to you how it's implemented. The aim here is to create four horizontally-scrolling blocks, the second and third of which snap into place, near but not quite at the left of each block. HTML The HTML that represents the blocks is very simple: <
div class="scroller"> <
div>1</
div> <
div>2</
div> <
div>3</
div> <
div>4</
div> </
div> CSS Let's walk through the CSS. the outer container is styled like this: .scroller { text-align: left; width: 250px; height: 250px; overflow-x: scroll; display: flex; box-sizing: border-box; border: 1px solid #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping...
... #000; scroll-snap-type: x mandatory; } The main parts relevant to the scroll snapping are overflow-x: scroll, which makes sure the contents will scroll and not be hidden, and scroll-snap-type: x mandatory, which dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
...h dictates that scroll snapping must occur along the horizontal axis, and the scrolling will always come to rest on a snap point. ...
...oll-snap-align: start; } .scroller >
div:nth-child(2n) { background-color: #fff; color: #663399; } The most relevant part here is scroll-snap-align: start, which specifies that the left-hand edges (the "starts" along the x axis, in our case) are the designated snap points. Last of all we specify the scroll margin-values, a different one for the second and third child elements: .scroller >
div:nth-child(2) { scroll-margin: 1rem; } .scroller >
div:nth-child(3) { scroll-margin: 2rem; } This means that when scrolling past the middle child elements, the scrolling will snap to 1rem outside the left edge of the second <
div>, and 2rems outside the left edge of the third <
div>. Note: Here we are setting scroll-margin on all sides at once, but only the start edge is really relevant. It ...
Specified value - CSS: Cascading Style Sheets
: If the document's style sheet explicitly specifies a value for the property, the given value will be used. If the document's style sheet doesn't specify a value but it is an inherited property, the value will be taken from the parent element. If none of the above pertain, the element's initial value will be used. ...
...t's style sheet doesn't specify a value but it is an inherited property, the value will be taken from the parent element. If none of the above pertain, the element's initial value will be used. ...
...le sheet doesn't specify a value but it is an inherited property, the value will be taken from the parent element. If none of the above pertain, the element's initial value will be used. Examples HTML <p>My specified color is given explicitly in the CSS.</p> <
div>The specified values of all my properties default to their initial values, because none of them are given in the CSS.</
div> <
div class="fun"> <p>The specified value of my font family is not given explicitly in the CSS, so it is inherited from my parent. ...
...HTML <p>My specified color is given explicitly in the CSS.</p> <
div>The specified values of all my properties default to their initial values, because none of them are given in the CSS.</
div> <
div class="fun"> <p>The specified value of my font family is not given explicitly in the CSS, so it is inherited from my parent. However, the border is not an inheriting property.</p> </
div> CSS .fun { border: 1px dotted pink; font-family: fantasy; } p { color: green; } Result Specifications Specification Status Comment CSS Level 2 (Revision 2)The definition of 'cascaded value' in that specification. Working Draft CSS Level 2 (Revision 1)The definition of 'cascaded value' in that specification. Recommendation Initial d...
rotate3d() - CSS: Cascading Style Sheets
an't be represented on the plane. ...
...esented on the plane. ...
...d on the plane. ...
...geneous coordinates on RP2 Cartesian coordinates on R3 1+(1-cos(a))(x2-1)z.sin(a)+xy(1-cos(a))-y.sin(a)+xz.(1-cos(a))-z.sin(a)+xy.(1-cos(a))1+(1-cos(a))(y2-1)x.sin(a)+yz.(1-cos(a))ysin(a) + xz(1-cos(a))-xsin(a)+yz(1-cos(a))1+(1-cos(a))(z2-1)t0001 Homogeneous coordinates on RP3 Examples Rotating on the y-axis HTML <
div>Normal</
div> <
div class="rotated">Rotated</
div> CSS body { perspective: 800px; }
div { width: 80px; height: 80px; background-color: skyblue; } .rotated { transform: rotate3d(0, 1, 0, 60deg); background-color: pink; } Result Rotating on a custom axis HTML <
div>Normal</
div> <
div class="rotated">Rotated</
div> CSS body { perspective: 800px; }
div { width: 80px; height: 80px; background-color: skyblue; } .rotated...
Used value - CSS: Cascading Style Sheets
und) are consistent with those of their component properties (e.g., background-color or background-size) and with position and float. Note: The getComputedStyle() DOM API returns the resolved value, which may either be the computed value or the used value, depending on the property. ...
... background-size) and with position and float. Note: The getComputedStyle() DOM API returns the resolved value, which may either be the computed value or the used value, depending on the property. ...
...he resolved value, which may either be the computed value or the used value, depending on the property. ...
...ample This example computes and displays the used width value of three elements (updates on resize): HTML <
div id="no-width"> <p>No explicit width.</p> <p class="show-used-width">..</p> <
div id="width-50"> <p>Explicit width: 50%.</p> <p class="show-used-width">..</p> <
div id="width-inherit"> <p>Explicit width: inherit.</p> <p class="show-used-width">..</p> </
div> </
div> </
div> CSS #no-width { width: auto; } #width-50 { width: 50%; } #width-inherit { width: inherit; } /* Make results easier to see */
div { border: 1px solid red; padding: 8px; } JavaScript function updateUsedWidth(id) { var
div = document.querySelector(`#${id}`); var par =
div.querySelector('.show-used-width'); var wid = window.getComputedStyle(
div)["width"]; pa...
Media buffering, seeking, and time ranges - Developer guides
nge requests are enabled this value usually becomes the duration of the media almost instantly. It is better perhaps to give an indication of how much media has actually downloaded -- this what the browser's native players seem to display. So let's build this. ...
...ion of the media almost instantly. It is better perhaps to give an indication of how much media has actually downloaded -- this what the browser's native players seem to display. So let's build this. ...
... the media almost instantly. It is better perhaps to give an indication of how much media has actually downloaded -- this what the browser's native players seem to display. So let's build this. ...
...n indication of how much media has actually downloaded -- this what the browser's native players seem to display. So let's build this. ...
Rich-Text Editing in Mozilla - Developer guides
property of a document to "On", such as the document inside an iframe. Once designMode has been set to "On", the document becomes a rich-text editing area and the user can type into it as if it were a textarea. The most basic keyboard commands such as copy and paste are available, all others need to be implemented by the website. Similarly, setting contentEditable to "true" allows you to make in
dividual elements of a document editable. Executing Commands When an HTML document has been switched to designMode, the document object exposes the document.execCommand method which allows one to run commands to manipulate the contents of the editable region. Most commands affect the document's selection (bold, italics, etc), while others insert new elements (adding a link) or affect an entire line...
...lid; padding: 12px; overflow: scroll; } #textBox #sourceText { padding: 0; margin: 0; min-width: 498px; min-height: 200px; } #editMode label { cursor: pointer; } </style> </head> <body onload="initDoc();"> <form name="compForm" method="post" action="sample.php" onsubmit="if(validateMode()){this.myDoc.value=oDoc.innerHTML;return true;}return false;"> <input type="hidden" name="myDoc"> <
div id="toolBar1"> <select onchange="formatDoc('formatblock',this[this.selectedIndex].value);this.selectedIndex=0;"> <option selected>- formatting -</option> <option value="h1">Title 1 <h1></option> <option value="h2">Title 2 <h2></option> <option value="h3">Title 3 <h3></option> <option value="h4">Title 4 <h4></option> <option value="h5">Title 5 <h5></option> <option va...
.../option> <option value="blue">Blue</option> <option value="green">Green</option> <option value="black">Black</option> </select> <select onchange="formatDoc('backcolor',this[this.selectedIndex].value);this.selectedIndex=0;"> <option class="heading" selected>- background -</option> <option value="red">Red</option> <option value="green">Green</option> <option value="black">Black</option> </select> </
div> <
div id="toolBar2"> <img class="intLink" title="Clean" onclick="if(validateMode()&&confirm('Are you sure?')){oDoc.innerHTML=sDefTxt};" src="data:image/gif;base64,R0lGODlhFgAWAIQbAD04KTRLYzFRjlldZl9vj1dusY14WYODhpWIbbSVFY6O7IOXw5qbms+wUbCztca0ccS4kdDQjdTLtMrL1O3YitHa7OPcsd/f4PfvrvDv8Pv5xv///////////////////yH5BAEKAB8ALAAAAAAWABYAAAV84CeOZGmeaKqubMteyzK547QoBcFWTm/jgsHq4rhMLoxFIehQQSAWR+Z4IAyaJ0kE...
..." src="data:image/gif;base64,R0lGODlhFgAWAIQUAD04KTRLY2tXQF9vj414WZWIbXmOrpqbmpGjudClFaezxsa0cb/I1+3YitHa7PrkIPHvbuPs+/fvrvv8/f///////////////////////////////////////////////yH5BAEAAB8ALAAAAAAWABYAAAWN4CeOZGmeaKqubGsusPvBSyFJjVDs6nJLB0khR4AkBCmfsCGBQAoCwjF5gwquVykSFbwZE+AwIBV0GhFog2EwIDchjwRiQo9E2Fx4XD5R+B0DDAEnBXBhBhN2DgwDAQFjJYVhCQYRfgoIDGiQJAWTCQMRiwwMfgicnVcAAAMOaK+bLAOrtLUyt7i5uiUhADs=" /> </
div> <
div id="textBox" contenteditable="true"><p>Lorem ipsum</p></
div> <p id="editMode"><input type="checkbox" name="switchMode" id="switchBox" onchange="setDocMode(this.checked);" /> <label for="switchBox">Show HTML</label></p> <p><input type="submit" value="Send" /></p> </form> </body> </html> Note: if you want to see how to standardize the creation and the insertion of your editor in your page,...
User input and controls - Developer guides
te: To find more out about adding fullscreen functionality your application, read our documentation about using fullscreen mode. Drag & Drop Drag & Drop allows your application's users to click and hold the mouse button down over an element, drag it to another location, and release the mouse button to drop the element there. Here is an example that allows a section of content to be dragged. ...
... This text <strong>may</strong> be dragged. ...
... Examples Tracking multiple touch points at a time This example tracks multiple touch points at a time, allowing the user to draw in a <canvas> with more than one finger at a time. ...
...on the element that you wish to make draggable Add a listener for the dragstart event and set the drag data within this listener Note: You can find more information in the MDN Drag & Drop documentation. contentEditable In open web apps any DOM element can be made directly editable using the contenteditable attribute. <
div contenteditable="true">? This text can be edited by the user. </
div> Note: Compatibility information, examples and other resources can be found in the Content Editable guide. Examples Tracking multiple touch points at a time This example tracks multiple touch points at a time, allowing the user to draw in a <canvas> with more than one finger at a time. It will only work on a browser that supports touch events. Simple pointer lock demo We've written a si...
The HTML autocomplete attribute - HTML: Hypertext Markup Language
bute and login fields. "on" The browser is allowed to automatically complete the input. No guidance is provided as to the type of data expected in the field, so the browser may use its own judgement. "name" The field expects the value to be a person's full name. Using "name" rather than breaking the name down into its components is generally preferred because it avoids dealing with the wide
diversity of human names and how they are structured; however, you can use the following autocomplete values if you do need to break the name down into its components: "honorific-prefix" The prefix or title, such as "Mrs.", "Mr.", "Miss", "Ms.", "Dr.", or "Mlle.". "given-name" The given (or "first") name. "additional-name" The middle name. "family-name" The family (or "last") name. ...
...zation name, such as "Acme Widget Company" or "Girl Scouts of America". "street-address" A street address. This can be multiple lines of text, and should fully identify the location of the address within its second administrative level (typically a city or town), but should not include the city name, ZIP or postal code, or country name. "address-line1", "address-line2", "address-line3" Each in
dividual line of the street address. These should only be present if the "street-address" is not present. "address-level4" The finest-grained administrative level, in addresses which have four levels. "address-level3" The third administrative level, in addresses with at least three administrative levels. "address-level2" The second administrative level, in addresses with at least two of them. I...
...ist the dynamic disabled state and (if applicable) dynamic checkedness of an <input> element, <textarea> element, or entire <form> across page loads. The persistence feature is enabled by default. Setting the value of the autocomplete attribute to off disables this feature. This works even when the autocomplete attribute would normally not apply by virtue of its type. See bug 654072. Examples <
div> <label for="cc-number">Enter your credit card number</label> <input name="cc-number" id="cc-number" autocomplete="off"> </
div> Administrative levels in addresses The four administrative level fields (address-level1 through address-level4) describe the address in terms of increasing levels of precision within the country in which the address is located. Each country has its own system of ad...
... addresses The four administrative level fields (address-level1 through address-level4) describe the address in terms of increasing levels of precision within the country in which the address is located. Each country has its own system of administrative levels, and may arrange the levels in different orders when addresses are written. address-level1 always represents the broadest administrative
division; it is the least-specific portion of the address short of the country name. Form layout flexibility Given that different countries write their address in different ways, with each field in different places within the address, and even different sets and numbers of fields entirely, it can be helpful if, when possible, your site is able to switch to the layout expected by your users when pre...
HTML attribute: required - HTML: Hypertext Markup Language
that specification. Recommendation Accessibility concerns Provide an indication to users informing them the form control is required. ...
... Provide an indication to users informing them the form control is required. ...
... an indication to users informing them the form control is required. ...
...lti-faceted, such as thru text, color, markings, and attribute, so that all users understand the requirements whether they have color blindness, cognitive differences, or are using a screen reader. ...
<dl>: The Description List element - HTML: Hypertext Markup Language
ve-examples and send us a pull request. Content categories Flow content, and if the <dl> element's children include one name-value group, palpable content. Permitted content Either: Zero or more groups each consisting of one or more <dt> elements followed by one or more <dd> elements, optionally intermixed with <script> and <template> elements. Or: One or more <
div> elements, optionally intermixed with <script> and <template> elements. Tag omission None, both the starting and ending tag are mandatory. Permitted parents Any element that accepts flow content. Implicit ARIA role No corresponding role Permitted ARIA roles group, list, none, presentation DOM interface HTMLDListElement Attribu...
...mples above. Metadata Description lists are useful for displaying metadata as a list of key-value pairs. ...
... key-value pairs. <dl> <dt>Name</dt> <dd>Godzilla</dd> <dt>Born</dt> <dd>1952</dd> <dt>Birthplace</dt> <dd>Japan</dd> <dt>Color</dt> <dd>Green</dd> </dl> Tip: It can be handy to define a key-value separator in the CSS, such as: dt::after { content: ": "; } Wrapping name-value groups in <
div> elements WHATWG HTML allows wrapping each name-value group in a <dl> element in a <
div> element. ...
...lor</dt> <dd>Green</dd> </dl> Tip: It can be handy to define a key-value separator in the CSS, such as: dt::after { content: ": "; } Wrapping name-value groups in <
div> elements WHATWG HTML allows wrapping each name-value group in a <dl> element in a <
div> element. This can be useful when using microdata, or when global attributes apply to a whole group, or for styling purposes. <dl> <
div> <dt>Name</dt> <dd>Godzilla</dd> </
div> <
div> <dt>Born</dt> <dd>1952</dd> </
div> <
div> <dt>Birthplace</dt> <dd>Japan</dd> </
div> <
div> <dt>Color</dt> <dd>Green</dd> </
div> </dl> Notes Do not use this element (nor <ul> elements) to merely create indentation on a page. Although it works, this is a bad practice and obscures the meaning of description ...
<input type="date"> - HTML: Hypertext Markup Language
browser way is to have the user enter the day, month, and year in separate controls, or to use a JavaScript library such as jQuery date picker. Examples In this example, we create 2 sets of UI elements for choosing dates: a native <input type="date"> picker and a set of 3 <select> elements for older browsers that don't support the native date input. ...
... create 2 sets of UI elements for choosing dates: a native <input type="date"> picker and a set of 3 <select> elements for older browsers that don't support the native date input. ...
...t type="date"> picker and a set of 3 <select> elements for older browsers that don't support the native date input. ...
... <option>June</option> <option>July</option> <option>August</option> <option>September</option> <option>October</option> <option>November</option> <option>December</option> </select> </span> <span> <label for="year">Year:</label> <select id="year" name="year"> </select> </span> </
div> </form> The months are hardcoded (as they are always the same), while the day and year values are dynamically generated depending on the currently selected month and year, and the current year (see the code comments below for detailed explanations of how these functions work.) span { padding-left: 5px; } input:invalid + span::after { content: '?'; } input:valid + span::after { content...
itemtype - HTML: Hypertext Markup Language
he exact meaning of a global identifier is determined by the vocabulary's specification. It is left to such specifications to define whether multiple items of the same global identifier (whether on the same page or different pages) are allowed to exist, and what processing rules for that vocabulary are, with respect to handling the case of multiple items with the same ID. ...
...er multiple items of the same global identifier (whether on the same page or different pages) are allowed to exist, and what processing rules for that vocabulary are, with respect to handling the case of multiple items with the same ID. ...
...items with the same ID. ...
..."seller" itemscope itemtype="http://schema.org/Organization"> <span itemprop="name">Executive Objects<br></span> </span> Condition: <link itemprop="itemCondition" href="http://schema.org/UsedCondition"/>Previously owned, in excellent condition<br> <link itemprop="availability" href="http://schema.org/InStock"/>In stock! Order now! ...
Inline elements - HTML: Hypertext Markup Language
from block-level elements. An inline element does not start on a new line and only takes up as much width as necessary. Inline vs. block-level elements: a demonstration This is most easily demonstrated with a simple example. First, some simple CSS that we'll be using: .highlight { background-color:#ee3; } Inline Let's look at the following example which demonstrates an inline element: <
div>The following span is an <span class="highlight">inline element</span>; its background has been colored to display both the beginning and end of the inline element's influence.</
div> In this example, the <
div> block-level element contains some text. Within that text is a <span> element, which is an inline element. Because the <span> element is inline, the paragraph correctly renders as a single,...
...line element. ...
...The <p> element totally changes the layout of the text, splitting it into three segments: the text before the <p>, then the <p>'s text, and finally the tex...
...display property. For example, by changing the value of display from "inline" to "block", you can tell the browser to render the inline element in a block box rather than an inline box, and vice versa. However, doing this will not change the category and the content model of the element. For example, even if the display of the span element is changed to "block", it still would not allow to nest a
div element inside it. Conceptual differences In brief, here are the basic conceptual differences between inline and block-level elements: Content model Generally, inline elements may contain only data and other inline elements. You can't put block elements inside inline elements. Formatting By default, inline elements do not force a new line to begin in the document flow. Block elements, on ...
Details of the object model - JavaScript
ng methods and fields in Java, or members in C++, to be properties). A class is abstract rather than any particular member in a set of objects it describes. For example, the Employee class could represent the set of all employees. An instance, on the other hand, is the instantiation of a class; that is. For example, Victoria could be an instance of the Employee class, representing a particular in
dividual as an employee. An instance has exactly the same properties of its parent class (no more, no less). A prototype-based language, such as JavaScript, does not make this distinction: it simply has objects. A prototype-based language has the notion of a prototypical object, an object used as a template from which to get the initial properties for a new object. Any object can specify its own pr...
...eritance model Inherit properties by following the class chain. Inherit properties by following the prototype chain. Extension of properties Class definition specifies all properties of all instances of a class. Cannot add properties dynamically at run time. Constructor function or prototype specifies an initial set of properties. Can add or remove properties dynamically to in
dividual objects or to the entire set of objects. The employee example The remainder of this chapter uses the employee hierarchy shown in the following figure. A simple object hierarchy with the following objects: Employee has the properties name (whose value defaults to the empty string) and dept (whose value defaults to "general"). Manager is based on Employee. It adds the report...
...ng machine = ""; } Using these definitions, you can create instances of these objects that get the default values for their properties. The next figure illustrates using these JavaScript definitions to create new objects and shows the property values for the new objects. Note: The term instance has a specific technical meaning in class-based languages. In these languages, an instance is an in
dividual instantiation of a class and is fundamentally different from a class. In JavaScript, "instance" does not have this technical meaning because JavaScript does not have this difference between classes and instances. However, in talking about JavaScript, "instance" can be used informally to mean an object created using a particular constructor function. So, in this example, you could informally ...
...ou could informally say that jane is an instance of Engineer. Similarly, although the terms parent, child, ancestor, and descendant do not have formal meanings in JavaScript; you can use them informally to refer to objects higher or lower in the prototype chain. Creating objects with simple definitions Object hierarchy The following hierarchy is created using the code on the right side. In
dividual objects = Jim, Sally, Mark, Fred, Jane, etc. "Instances" created from constructor var jim = new Employee; // Parentheses can be omitted if the // constructor takes no arguments. // jim.name is '' // jim.dept is 'general' var sally = new Manager; // sally.name is '' // sally.dept is 'general' // sally.reports is [] var mark = new WorkerBee; // mark.name is '' // mark.dept is 'general' // ...
dx - SVG: Scalable Vector Graphics
xis --> <text dx="50%" x="10%" y="50%">SVG</text> </svg> line { stroke: red; stroke-width: .5px; stroke-dasharray: 3px; } altGlyph Warning: As of SVG2 <altGlyph> is deprecated and shouldn't be used. For <altGlyph>, if it contains a single value, dx defines a shift along the x-axis for all alternate glyph. If there are multiple values, dx defines a shift along the x-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphs, the remaining glyphs use a value of 0. If there are more values than glyphs, extra values are ignored. Value List of <length> Default value none Animatable Yes feDropShadow For <feDropShadow>, dx defines the x offset of the droped shadow. The unit used to resolve the valu...
... <glyphRef> is deprecated and shouldn't be used. For <glyphRef>, dx defines the x offset of the glyph, in the font metric system. Value <number> Default value 0 Animatable Yes text For <text>, if it contains a single value, dx defines a shift along the x-axis for all glyphs. If there are multiple values, dx defines a shift along the x-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphs, the remaining glyphs use a value of 0. If there are more values than glyphs, extra values are ignored. Value List of <length> Default value none Animatable Yes Example html,body,svg { height:100% } <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <!-- L...
...10%" y="50%">SVG</text> <text dx="0 10% 20%" x="10%" y="75%">SVG</text> </svg> line { stroke: red; stroke-width: .5px; stroke-dasharray: 3px; } tref Warning: As of SVG2 <tref> is deprecated and shouldn't be used. For <tref>, if it contains a single value, dx defines a shift along the x-axis for all glyphs. If there are multiple values, dx defines a shift along the x-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphes, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes tspan For <tspan>, if it contains a single value, dx defines a shift along the x-axis for all alternate glyph...
...es, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes tspan For <tspan>, if it contains a single value, dx defines a shift along the x-axis for all alternate glyph. If there are multiple values, dx defines a shift along the x-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphs, the remaining glyphs use a value of 0. If there are more values than glyphs, extra values are ignored. Value List of <length> Default value none Animatable Yes Specifications Specification Status Comment Filter Effects Module Level 1The definit...
dy - SVG: Scalable Vector Graphics
xis --> <text dy="50%" x="10%" y="30%">SVG</text> </svg> line { stroke: red; stroke-width: .5px; stroke-dasharray: 3px; } altGlyph Warning: As of SVG2 <altGlyph> is deprecated and shouldn't be used. For <altGlyph>, if it contains a single value, dy defines a shift along the y-axis for all alternate glyph. If there are multiple values, dy defines a shift along the y-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphes, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes feDropShadow For <feDropShadow>, dy defines the y offset of the dropped shadow. The unit used to resolve the ...
... <glyphRef> is deprecated and shouldn't be used. For <glyphRef>, dy defines the y offset of the glyph, in the font metric system. Value <number> Default value 0 Animatable Yes text For <text>, if it contains a single value, dy defines a shift along the y-axis for all glyphs. If there are multiple values, dy defines a shift along the y-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphes, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes Example html,body,svg { height:100% } <svg viewBox="0 0 150 100" xmlns="http://www.w3.org/2000/svg"> <!-...
... x="50" y="30">SVG</text> <text dy="0 10 20" x="90" y="30">SVG</text> </svg> line { stroke: red; stroke-width: .5px; stroke-dasharray: 3px; } tref Warning: As of SVG2 <tref> is deprecated and shouldn't be used. For <tref>, if it contains a single value, dy defines a shift along the y-axis for all glyphs. If there are multiple values, dy defines a shift along the y-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphes, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes tspan For <tspan>, if it contains a single value, dy defines a shift along the y-axis for all alternate glyph...
...es, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes tspan For <tspan>, if it contains a single value, dy defines a shift along the y-axis for all alternate glyph. If there are multiple values, dy defines a shift along the y-axis for each in
dividual glyph relative to the preceding glyph. If there are less values than glyphes, the remaining glyphes use a value of 0. If there are more values than glyphes, extra values are ignored. Value List of <length> Default value none Animatable Yes Specifications Specification Status Comment Filter Effects Module Level 1The defi...
<feConvolveMatrix> - SVG: Scalable Vector Graphics
trix to the corresponding source pixel and its neighboring pixels. ...
...+I * kernelMatrixorderX-J-1, orderY-I-1 } } ) /
divisor + bias * ALPHAX,Y where "orderX" and "orderY" represent the X and Y values for the 'order' attribute, "targetX" represents the value of the 'targetX' attribute, "targetY" represents the value of the 'targetY' attribute, "kernelMatrix" represents the value of the 'kernelMatrix' attribute, "
divisor" represents the value of the '
divisor' attribute, and "bias" represents the value of the 'bias' attribute. Note in the above formulas that the values in the kernel matrix are applied such that the kernel matrix is rotated 180 degrees relative to the source and destination images in order to match convolution theory as described in many computer graphics textbooks. To illustrate, suppose you...
...00 220 240 235 235 225 225 255 255 255 225 225 255 255 255 and you define a 3-by-3 convolution kernel as follows: 1 2 3 4 5 6 7 8 9 Let's focus on the color value at the second row and second column of the image (source pixel value is 120). ...
... Example SVG <svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <filter id="emboss"> <feConvolveMatrix kernelMatrix="3 0 0 ...
Using custom elements - Web Components
t an example of these in use. The code below is taken from the life-cycle-callbacks example (see it running live). This is a trivial example that simply generates a colored square of a fixed size on the page. ...
...ing live). This is a trivial example that simply generates a colored square of a fixed size on the page. The custom element looks like this: <custom-square l="100" c="red"></custom-square> The class constructor is really simple -- here we attach a shadow DOM to the element, then attach empty <
div> and <style> elements to the shadow root: const shadow = this.attachShadow({mode: 'open'}); const
div = document.createElement('
div'); const style = document.createElement('style'); shadow.appendChild(style); shadow.appendChild(
div); The key function in this example is updateStyle() -- this takes an element, gets its shadow root, finds its <style> element, and adds width, height, and background-color to the style. function updateStyle(elem) { const shadow = elem.shadowRoot; shadow.querySele...
...const style = document.createElement('style'); shadow.appendChild(style); shadow.appendChild(
div); The key function in this example is updateStyle() -- this takes an element, gets its shadow root, finds its <style> element, and adds width, height, and background-color to the style. function updateStyle(elem) { const shadow = elem.shadowRoot; shadow.querySelector('style').textContent = `
div { width: ${elem.getAttribute('l')}px; height: ${elem.getAttribute('l')}px; background-color: ${elem.getAttribute('c')}; } `; } The actual updates are all handled by the life cycle callbacks, which are placed inside the class definition as methods. The connectedCallback() runs each time the element is added to the DOM -- here we run the updateStyle() function to make sure ...
...from the DOM, or moved to a different page: disconnectedCallback() { console.log('Custom square element removed from page.'); } adoptedCallback() { console.log('Custom square element moved to new page.'); } The attributeChangedCallback() callback is run whenever one of the element's attributes is changed in some way. As you can see from its properties, it is possible to act on attributes in
dividually, looking at their name, and old and new attribute values. In this case however, we are just running the updateStyle() function again to make sure that the square's style is updated as per the new values: attributeChangedCallback(name, oldValue, newValue) { console.log('Custom square element attributes changed.'); updateStyle(this); } Note that to get the attributeChangedCallback() ca...
HTML to DOM - Archive of obsolete content
The returned <body> object is of type Element Here is a sample that counts the number of paragraphs in a string: var DOMPars = HTMLParser('<p>foo</p><p>bar</p>'); alert(DOMPars.getElementsByTagName('p').length); If HTMLPar...
...nt.appendChild(body); body.appendChild(Components.classes["@mozilla.org/feed-unescapehtml;1"] .getService(Components.interfaces.nsIScriptableUnescapeHTML) .parseFragment(aHTMLString, false, null, body)); return body; } It works by creating a content-level (this is safer than chrome-level) <
div> in the current page, then parsing the HTML fragment and attaching that fragment to the <
div>. The <
div> is returned, and it is never actually appended to the current page. The returned <body> object is of type Element Here is a sample that counts the number of paragraphs in a string: var DOMPars = HTMLParser('<p>foo</p><p>bar</p>'); alert(DOMPars.getElementsByTagName('p').length); If HTMLParser() returns the element name html (instead of body), you have all document object with its ...
...he current page. The returned <body> object is of type Element Here is a sample that counts the number of paragraphs in a string: var DOMPars = HTMLParser('<p>foo</p><p>bar</p>'); alert(DOMPars.getElementsByTagName('p').length); If HTMLParser() returns the element name html (instead of body), you have all document object with its complete functions list, therefore you can retrieve info within
div tag like this: var DOMPars = HTMLParser("<
div id='userInfo'>John was a mediocre programmer, but people liked him <strong>anyway</strong>.</
div>"); alert(DOMPars.getElementById('userInfo').innerHTML); To parse a complete HTML page, load it into an iframe whose type is content (not chrome). See Using a hidden iframe element to parse HTML to a window's DOM below. Parsing Complete HTML to DOM Lo...
Metro browser chrome tests - Archive of obsolete content
results using the same functions as the Mochitest test framework. Running the metro browser chrome tests To run Mochitest, first build Mozilla with your changes; then run ./mach mochitest-metro This will launch metro browser chrome tests in the default immersive browser. For information on setting your local build as the default, visit the Windows 8 Integration wiki page. It is possible to run in
dividual tests as well. As with Mochitest, the path given as an argument is the path to a test file within the Mozilla source tree. If the path points to the root tests directory, then all metro browser chrome tests will be run. For example, to run a specific test the command would be: ./mach mochitest-metro browser/metro/base/tests/mochitest/(testfile) Writing browser chrome tests Metro browser chr...
...e tests make use of a common framework for defining and running tests. A simple test looks like this: gTests.push({ desc: "Test loading about:blank", setUp: function () { }, tearDown: function () { }, run: function () { yield addTab("about:blank"); is(tab.browser.currentURI.spec, "about:blank", "about:blank is loaded"); } }); function test() { runTests(); } gTests contains in
dividual tests that make up the library of tests your test file will contain. Each test can have start up and tear down logic, plus the body of the test contained in run(). The test file can contain other functions which will be ignored unless invoked by test(). gTests make use of Promises and Tasks for managing execution. Test comparison functions used in metro browser chrome tests are identical to ...
...changes may impact tests in other libraries. Static content for tests Static content (html files, images, etc.) should be stored in sub directories to avoid polluting the main test directory. Sub directories for larger test suites may also be created. Exceptions in tests Any exceptions thrown under test() will be caught and reported as a general failure. setUp(), tearDown(), and run() each have in
dividual exception handlers to prevent one method from interfering with the execution of another. An exception in any of these methods will cause a test failure. Additional built-in framework test checks will run after the completion of each in
dividual test insuring tests clean up properly. For more information on test execution see the main test exectuon loop in head.js. Adding a new browser chrome ...
Elements - Archive of obsolete content
isplay CDATA #IMPLIED inheritstyle true #IMPLIED > The binding element describes a single XBL binding. A XBL binding can add anonymous content, fields, properties, methods, and event handlers to HTML/XML elements. A single XBL binding can be attached to an element by using style sheets or by scripting. (See bug 83830 for <table> specifics). ...
...an element by using style sheets or by scripting. (See bug 83830 for <table> specifics). ...
...ng> </bindings> Only CSS declarations provide an easy way to attach bindings to any set of elements. It also makes your binding partially functional if scripting is disabled. In the latter case all methods and handlers will be blocked, but the anonymous content and styling will be still used. Given that the CSS declarations should be always used - unless you need to add bindings at runtime to in
dividual elements. A binding element may contain a resources tag, a content tag, a implementation tag and a handlers tag. id - The id attribute is a document-unique identifier. For the binding element, this attribute is required, since it is used to attach bindings. extends - The extends attribute is used to specify the URL of a binding that this binding inherits from (see Inheritance of Impleme...
Things I've tried to do with XUL - Archive of obsolete content
along with the window, with the green, red, and blue inside boxes always maintaining a 30%-20%-50% ratio to the height of the parent vbox. ...
...red, and blue inside boxes always maintaining a 30%-20%-50% ratio to the height of the parent vbox. ...
...So, as soon as you add a label or some other element inside, there will be a different amount of "empty space" to allocate in different boxes. ...
-ms-scrollbar-arrow-color - Archive of obsolete content
> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples The following example shows how to use -ms-scrollbar-arrow-color and -ms-scrollbar-face-color to display a scroll bar with a blue scroll box and arrows, and a scroll bar with a green scroll box and arrows. ...
...nd a scroll bar with a green scroll box and arrows.
div { width: 150px; height: 150px; overflow-y: scroll; border-style: solid; border-width: thin; font-family: sans-serif; float: left; margin-right: 10px; } .blueScrollBox { scrollbar-face-color: blue; scrollbar-arrow-color: blue; } .greenScrollBox { scrollbar-face-color: green; scrollbar-arrow-color: green; } <body> <
div class="blueScrollBox"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. ...
...erif; float: left; margin-right: 10px; } .blueScrollBox { scrollbar-face-color: blue; scrollbar-arrow-color: blue; } .greenScrollBox { scrollbar-face-color: green; scrollbar-arrow-color: green; } <body> <
div class="blueScrollBox"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> <
div class="greenScrollBox"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> </body> The following image shows the result: Specifications Not part of any specification. ...
-ms-scrollbar-face-color - Archive of obsolete content
<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples This example uses -ms-scrollbar-face-color and -ms-scrollbar-arrow-color to display a scroll bar with a blue scroll box and arrows, and a scroll bar with a green scroll box and arrows. ...
...nd a scroll bar with a green scroll box and arrows.
div { width: 150px; height: 150px; overflow-y: scroll; border-style: solid; border-width: thin; font-family: sans-serif; float: left; margin-right: 10px; } .blueScrollBox { scrollbar-face-color: blue; scrollbar-arrow-color: blue; } .greenScrollBox { scrollbar-face-color: green; scrollbar-arrow-color: green; } <body> <
div class="blueScrollBox"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. ...
...erif; float: left; margin-right: 10px; } .blueScrollBox { scrollbar-face-color: blue; scrollbar-arrow-color: blue; } .greenScrollBox { scrollbar-face-color: green; scrollbar-arrow-color: green; } <body> <
div class="blueScrollBox"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> <
div class="greenScrollBox"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> </body> This image shows the result: Specifications Not part of any specification. ...
-ms-scrollbar-highlight-color - Archive of obsolete content
e> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...a-value>? ...
...h: thin; overflow-y: scroll; font-family: sans-serif; float: left; margin-right: 10px; } .blueScroll { -ms-scrollbar-highlight-color: aqua; -ms-scrollbar-face-color: blue; -ms-scrollbar-arrow-color: blue; border-color: blue; } .redScroll { -ms-scrollbar-highlight-color: bisque; -ms-scrollbar-face-color: red; -ms-scrollbar-arrow-color: red; border-color: red; } <body> <
div class="blueScroll"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> <
div class="redScroll"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> </body> This image shows the resul...
-ms-scrollbar-track-color - Archive of obsolete content
value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...lpha-value>? ...
...: thin; overflow-y: scroll; font-family: sans-serif; float: left; margin-right: 10px; } .blueScroll { -ms-scrollbar-highlight-color: aqua; -ms-scrollbar-face-color: blue; -ms-scrollbar-arrow-color: blue; border-color: blue; } .redScroll { -ms-scrollbar-highlight-color: bisque; -ms-scrollbar-face-color: red; -ms-scrollbar-arrow-color: red; border-color: red; } <body> <
div class="blueScroll"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> <
div class="redScroll"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </
div> </body> The following image shows...
XForms Custom Controls Examples - Archive of obsolete content
Introduction Here is a collection of misc. custom control examples. Please feel free to add your own examples. A full example showing a complete form can be found on XForms:Custom_Controls. ...
... Introduction Here is a collection of misc. custom control examples. Please feel free to add your own examples. A full example showing a complete form can be found on XForms:Custom_Controls. ...
...refresh"> <body> var img = document.getAnonymousElementByAttribute(this, "anonid", "content"); img.setAttribute("src", this.stringValue); return true; </body> </method> </implementation> </binding> Output Showing XHTML <binding id="output-xhtml" extends="chrome://xforms/content/xforms-xhtml.xml#xformswidget-output"> <content> <children includes="label"/> <xhtml:
div class="xf-value" anonid="content"></xhtml:
div> <children/> </content> <implementation implements="nsIXFormsUIWidget"> <field name="_domparser">null</field> <property name="domparser" readonly="true"> <getter> if (!this._domparser) this._domparser = new DOMParser(); return this._domparser; </getter> </property> <method name="refresh"> <body> // Get...
2D collision detection - Game development
Green means collision, blue means no collision.</p> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crafty/0.5.4/crafty-min.js"></script> Crafty.init(200, 200); var dim1 = {x: 5, y: 5, w: 50, h: 50} var dim2 = {x: 20, y: 10, w: 60, h: 40} var rect1 = Crafty.e("2D, Canvas, Color").attr(dim1).color("red"); v...
...Green means collision, blue means no collision.</p> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crafty/0.5.4/crafty-min.js"></script> Crafty.init(200, 200); var dim1 = {x: 5, y: 5, w: 50, h: 50} var dim2 = {x: 20, y: 10, w: 60, h: 40} var rect1 = Crafty.e("2D, Canvas, Color").attr(dim1).color("red"); var rect2 = Crafty.e(...
... // no collision this.color("blue"); } }); Note: Another example without Canvas or external libraries. Circle Collision Another simple shape for collision detection is between two circles. This algorithm works by taking the centre points of the two circles and ensuring the distance between the centre points are less than the two radii added together. Playable code <
div id="cr-stage"></
div> <p>Move the circle with arrow keys. Green means collision, blue means no collision.</p> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crafty/0.5.4/crafty-min.js"></script> #cr-stage { position: static !important; height: 200px !important; } Crafty.init(200, 200); var dim1 = {x: 5, y: 5} var dim2 = {x: 20, y: 20} Crafty.c("Circle", { ...
Audio for Web games - Game development
can prime one piece of audio and have our sprites ready to go. To do this we can just play and instantly pause the larger piece of audio. You'll also reduce the number of server requests and save bandwidth. var myAudio = document.createElement("audio"); myAudio.src = "mysprite.mp3"; myAudio.play(); myAudio.pause(); You'll need to sample the current time to know when to stop. If you space your in
dividual sounds by at least 500ms then using the timeUpdate event (which fires every 250ms) should be sufficient. Your files may be slightly longer than they strictly need to be, but silence compresses well. Here's an example of an audio sprite player -- first let's set up the user interface in HTML: <audio id="myAudio" src="https://udn.realityripple.com/samples/f0/2909c16512.mp3"></audio> <button ...
...d out as appropriate. You can also apply filters or effects to music. Is your character in a cave? Increase the echo. Maybe you have underwater scenes, during which you could apply a filter that muffles the sound. Let's look at some Web Audio API techniques for dynamically adjusting music from its base tracks. Loading your tracks With the Web Audio API you can load separate tracks and loops in
dividually using XMLHttpRequest or the Fetch API, which means you can load them synchronously or in parallel. Loading synchronously might mean parts of your music are ready earlier and you can start playing them while others load. Either way you may want to synchronize tracks or loops. The Web Audio API contains the notion of an internal clock that starts ticking the moment you create an audio conte...
...sure they start at the correct point that other tracks might be playing at, so they sync up. Let's create our audio context: // for cross browser compatibility const AudioContext = window.AudioContext || window.webkitAudioContext; const audioCtx = new AudioContext(); Now let's select all the <li> elements; later we can harness these elements to give us access to the track file path and each in
dividual play button. const trackEls = document.querySelectorAll('li'); We want to make sure each file has loaded and been decoded into a buffer before we use it, so let's create an async function to allow us to do this: async function getFile(filepath) { const response = await fetch(filepath); const arrayBuffer = await response.arrayBuffer(); const audioBuffer = await audioCtx.decodeAudioD...
Grid - MDN Web Docs Glossary: Definitions of Web-related terms
d outside of the tracks defined. In the example below I have created an explicit grid of three columns and two rows. The third row on the grid is an implicit grid row track, formed due to their being more than the six items which fill the explicit tracks. ...
...xplicit tracks. ...
...-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 100px 100px; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> <
div>Six</
div> <
div>Seven</
div> <
div>Eight</
div> </
div> ...
Grid Tracks - MDN Web Docs Glossary: Definitions of Web-related terms
-template-columns and grid-template-rows you may use any length unit, and also the flex unit, fr which indicates a portion of the available space in the grid container. The example below demonstrates a grid with three column tracks, one of 200 pixels, the second of 1fr, the third of 3fr. ...
...th three column tracks, one of 200 pixels, the second of 1fr, the third of 3fr. Once the 200 pixels has been subtracted from the space available in the grid container, the remaining space is
divided by 4. One part is given to column 2, 3 parts to column 3. ...
... part is given to column 2, 3 parts to column 3. * {box-sizing: border-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: 200px 1fr 3fr; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> </
div> Track sizing in the implicit grid Tracks created in the implicit grid are auto-sized by default, however you can define a size for these tracks using the grid-auto-rows and grid-auto-columns properties. ...
Index - MDN Web Docs Glossary: Definitions of Web-related terms
labeled audio/ogg, or an image file image/png). 259 MVC Glossary, Infrastructure, Intro, MVC, Model View Controller MVC (Model-View-Controller) is a pattern in software design commonly used to implement user interfaces, data, and controlling logic. It emphasizes a separation between the software's business logic and display. This "separation of concerns" provides for a better
division of labor and improved maintenance. Some other design patterns are based on MVC, such as MVVM (Model-View-Viewmodel), MVP (Model-View-Presenter), and MVW (Model-View-Whatever). 260 Main Axis CSS, Glossary, Main axis, flexbox The main axis in flexbox is defined by the direction set by the flex-direction property. There are four possible values for flex-direction. These are...
...r") is a device that converts digital information to analog signals and vice-versa, for sending data through networks. 275 Modern web apps Composing, Glossary, Modern web apps See Progressive web apps 276 Modularity CodingScripting, Glossary The term Modularity refers to the degree to which a system's components may be separated and recombined, it is also
division of a software package into logical units. The advantage of a modular system is that one can reason the parts independently 277 Mozilla Firefox Browser, Firefox, Glossary, Infrastructure, Mozilla, Mozilla Firefox Mozilla Firefox is a free open-source browser whose development is overseen by the Mozilla Corporation. Firefox runs on Windows, OS X, Linux, and Android. ...
...erform conditional requests; others like Cookie, User-Agent, or Referer precise the context so that the server can tailor the answer. 373 Resource Timing Glossary, Timings, Web Performance Diagnosing performance issues requires performance data at the granularity of the resource. The Resource Timing API is a JavaScript API that is able to capture timing information for each in
dividual resource that is fetched when a page is loaded. 374 Response header Glossary, WebMechanics A response header is an HTTP header that can be used in an HTTP response and that doesn't relate to the content of the message. Response headers, like Age, Location or Server are used to give a more detailed context of the response. 375 Responsive web design Accessib...
Property (CSS) - MDN Web Docs Glossary: Definitions of Web-related terms
A CSS property is a characteristic (like color) whose associated value defines one aspect of how the browser should display the element. ...
... A CSS property is a characteristic (like color) whose associated value defines one aspect of how the browser should display the element. ...
... A CSS property is a characteristic (like color) whose associated value defines one aspect of how the browser should display the element. ...
What is accessibility? - Learn web development
ics and morals, which improves your public image. Other good practices that improve accessibility also make your site more usable by other groups, such as mobile phone users or those on low network speed. In fact, everyone can benefit from many such improvements. Did we mention it is also the law in some places? What kinds of disability are we looking at? People with disabilities are just as
diverse as people without disabilities, and so are their disabilities. The key lesson here is to think beyond your own computer and how you use the web, and start learning about how others use it -- you are not your users. The main types of disability to consider are explained below, along with any special tools they use to access web content (known as assistive technologies, or ATs). Note: The Wor...
...lities, from people with intellectual disabilities who have the most-limited capabilities, to all of us as we age and have difficulty thinking and remembering. The range includes people with mental illnesses, such as depression and schizophrenia. It also includes people with learning disabilities, such as dyslexia and attention deficit hyperactivity disorder. Importantly, though there is a lot of
diversity within clinical definitions of cognitive impairments, people with them experience a common set of functional problems. These include difficulty with understanding content, remembering how to complete tasks, and confusion caused by inconsistent webpage layouts. A good foundation of accessibility for people with cognitive impairments includes: delivering content in more than one way, such...
... Notes Designing with cognitive accessibility will lead to good design practices. They will benefit everyone. Many people with cognitive impairments al...
Beginner's guide to media queries - Learn web development
0px; } .sidebar { background-color: rgba(207, 232, 220, 0.5); padding: 10px; } article { margin-bottom: 1em; } We've made no layout changes, however the source of the document is ordered in a way that makes the content readable. This is an important first step and one which ensures that if the content were to be read out by a screen reader, it would be understandable. ...
...ead out by a screen reader, it would be understandable. <body> <
div class="wrapper"> <header> <nav> <ul> <li><a href="">About</a></li> <li><a href="">Contact</a></li> <li><a href="">Meet the team</a></li> <li><a href="">Blog</a></li> </ul> </nav> </header> <main> <article> <
div class="content"> <h1>Veggies!</h1> <p> ... </p> </
div> <aside class="related"> <p> ... </p> </aside> </article> <aside class="sidebar"> <h2>External vegetable-based links</h2> <ul> <li> ... </li> ...
...If we view the layout in Responsive Design Mode in DevTools we can see that it works pretty well as a straightforward mobile view of the site. Open step 1 in the browser, or view the source. If you want to follow on and implement this example as we go, make a local copy of step1.html on your computer. ...
Fundamental text and font styling - Learn web development
e careful about how you style things. It is best to use rem where you can, to keep things simple, and avoid setting the font-size of container elements where possible. A simple sizing example When sizing your text, it is usually a good idea to set the base font-size of the document to 10 px, so that then the maths is a lot easier to work out -- required (r)em values are then the pixel font size
divided by 10, not 16. After doing that, you can easily size the different types of text in your document to what you want. It is a good idea to list all your font-size rulesets in a designated area in your stylesheet, so they are easy to find. Our new result is like so: <h1>Tommy the cat</h1> <p>Well I remember it as though it were a meal ago...</p> <p>Said Tommy the Cat as he reeled back to cl...
... text In this active learning session, we don't have any specific exercises for you to do: we'd just like you to have a good play with some font/text layout properties, and see what you can produce! You can either do this using offline HTML/CSS files, or enter your code into the live editable example below. If you make a mistake, you can always reset it using the Reset button. ...
...,Helvetica,Arial,sans-serif;"> <h2>HTML Input</h2> <textarea id="code" class="html-input" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"> <p>Some sample text for your delight</p> </textarea> <h2>CSS Input</h2> <textarea id="code" class="css-input" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"> p { } </textarea> <h2>Output</h2> <
div class="output" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"></
div> <
div class="controls"> <input id="reset" type="button" value="Reset" style="margin: 10px 10px 0 0;"> </
div> </
div> const htmlInput = document.querySelector(".html-input"); const cssInput = document.querySelector(".css-input"); const reset = document.getElementById("reset"); let htmlCode = html...
Styling links - Learn web development
our empty set of rules and add your own declarations to make the links look really cool. Use your imagination, go wild. We are sure you can come up with something cooler and just as functional as our example above. If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to insert the example we showed above. ...
... several browsers available, such as <a href="#">Mozilla Firefox</a>, <a href="#">Google Chrome</a>, and <a href="#">Microsoft Edge</a>.</p></textarea> <h2>CSS Input</h2> <textarea id="code" class="css-input" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;">a { } a:link { } a:visited { } a:focus { } a:hover { } a:active { }</textarea> <h2>Output</h2> <
div class="output" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"></
div> <
div class="controls"> <input id="reset" type="button" value="Reset" style="margin: 10px 10px 0 0;"> <input id="solution" type="button" value="Show solution" style="margin: 10px 0 0 10px;"> </
div> </
div> var htmlInput = document.querySelector(".html-input"); var cssInput = document.querySe...
...right: 19px; } So what's going on here? We'll skip over most of the CSS, as it's just the same information you've looked at before. The last rule however is interesting -- here we are inserting a custom background image on external links in a similar manner to how we handled custom bullets on list items in the last article -- this time however we are using background shorthand instead of the in
dividual properties. We set the path to the image we want to insert, specify no-repeat so we only get one copy inserted, and then specify the position as 100% of the way over to the right of the text content, and 0 pixels from the top. We also use background-size to specify the size we want the background image to be shown at -- it is useful to have a larger icon and then resize it like this as need...
Styling lists - Learn web development
the page. Rules 2 and 3 set relative font sizes for the headings, different list types (the children of the list elements inherit these), and paragraphs. This means that each paragraph and list will have the same font size and top and bottom spacing, helping to keep the vertical rhythm consistent. Rule 4 sets the same line-height on the paragraphs and list items -- so the paragraphs and each in
dividual list item will have the same spacing between lines. This will also help to keep the vertical rhythm consistent. Rules 5 and 6 apply to the description list -- we set the same line-height on the description list terms and descriptions as we did with the paragraphs and list items. Again, consistency is good! We also make the description terms have bold font, so they visually stand out easier.
... line-height of 1.5 of their font-size. Give the ordered list lower alphabetical bullets. Feel free to play with the list example as much as you like, experimenting with bullet types, spacing, or whatever else you can find. If you make a mistake, you can always reset it using the Reset button. If you get really stuck, press the Show solution button to see a potential answer. ...
...nally, place the three magic items in the box, in this exact order, to complete the spell: <ol> <li>The book of spells</li> <li>The shiny rod</li> <li>The goblin statue</li> </ol> </li> </ul></textarea> <h2>CSS Input</h2> <textarea id="code" class="css-input" style="width: 90%;height: 10em;padding: 10px;border: 1px solid #0095dd;"></textarea> <h2>Output</h2> <
div class="output" style="width: 90%;height: 12em;padding: 10px;border: 1px solid #0095dd;overflow: auto;"></
div> <
div class="controls"> <input id="reset" type="button" value="Reset" style="margin: 10px 10px 0 0;"> <input id="solution" type="button" value="Show solution" style="margin: 10px 0 0 10px;"> </
div> </
div> var htmlInput = document.querySelector(".html-input"); var cssInput = d...
Advanced form styling - Learn web development
imple styling to make sizing consistent, uniform styling of things like background-colors, and usage of appearence to get rid of some system-level styling. ...
...e: none; } We then created our own icon using generated content. ...
...select> elements (this is because generated content is placed relative to an element's formatting box, but form inputs work more like replaced elements -- their display is generated by the browser and put in place -- and therefore don't have one): <
div class="select-wrapper"><select id="select" name="select"> <option>Banana</option> <option>Cherry</option> <option>Lemon</option> </select></
div> We then use generated content to generate a little down arrow, and put it in the right place using positioning: .select-wrapper { position: relative; } .select-wrapper::after { content: "?"; font-size: 1rem; top: 6px; right: 10px; position: absolute; } The second, slightly more major issue is that you don't have control over the box that appears containing the options when you cl...
Client-side form validation - Learn web development
ning the values of your entries For number fields (i.e. <input type="number">), the min and max attributes can be used to provide a range of valid values. If the field contains a value outside this range, it will be invalid. Let's look at another example. Create a new copy of the fruit-start.html file. ...
...d contains a value outside this range, it will be invalid. Let's look at another example. Create a new copy of the fruit-start.html file. Now delete the contents of the <body> element, and replace it with the following: <form> <
div> <label for="choose">Would you prefer a banana or a cherry?</label> <input type="text" id="choose" name="i_like" required minlength="6" maxlength="6"> </
div> <
div> <label for="number">How many would you like?</label> <input type="number" id="number" name="amount" value="1" min="1" max="10"> </
div> <
div> <button>Submit</button> </
div> </form> Here you'll see that we've given the text field a minlength and maxlength of six, which is the same length as banana and cherry. We've also given the number field a min of one and a max of...
... outside this range will show as invalid; users won't be able to use the increment/decrement arrows to move the value outside of this range. If the user manually enters a number outside of this range, the data is invalid. The number is not required, so removing the value will still result in a valid value. ...
Example 2 - Learn web development
This is the second example that explain how to build custom form widgets. ...
... <option>Banana</option> <option>Strawberry</option> <option>Apple</option> </select> <
div class="select"> <span class="value">Cherry</span> <ul class="optList hidden"> <li class="option">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> <form> CSS Content .widget select, .no-widget .select { position : absolute; left : -5000em; height : 0; overflow : hidden; } /* --------------- */ /* Required Styles */ /* --------------- */ .select { position: relative; display : inline-block; } .select.active, .select:focus { box-shadow: 0 0 3px 1px #227755; outline: none; } .select .optList { position: absolute; ...
...ener("load", function () { var form = document.querySelector('form'); form.classList.remove("no-widget"); form.classList.add("widget"); }); Result for JS No JS HTML Content <form class="no-widget"> <select name="myFruit"> <option>Cherry</option> <option>Lemon</option> <option>Banana</option> <option>Strawberry</option> <option>Apple</option> </select> <
div class="select"> <span class="value">Cherry</span> <ul class="optList hidden"> <li class="option">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> <form> CSS Content .widget select, .no-widget .select { position : absolute; left : -5000em; heig...
Styling web forms - Learn web development
rm has changed to make this more possible. For some form widgets, it is still difficult to rebuild controls to make them stylable, but we can now use CSS to style many form features, though we do need to take extra care to ensure we don't break usability. Not all widgets are created equal when CSS is involved At present, some difficulties remain when using CSS with forms. These problems can be
divided into three categories: The good Some elements can be styled with few if any problems across platforms. These include the following elements: <form> <fieldset> and <legend> Single-line text <input>s (e.g. type text, url, email...), except for <input type="search">. Multi-line <textarea>s Buttons (both <input> and <button>s) <label> <output> The bad Some elements are more difficul...
...a fancy-looking "postcard" contact form; see here for the finished version. If you want to follow along with this example, make a local copy of our postcard-start.html file, and follow the below instructions. The HTML The HTML is only slightly more involved than the example we used in the first article of this guide; it just has a few extra IDs and a heading. ...
...ith this example, make a local copy of our postcard-start.html file, and follow the below instructions. The HTML The HTML is only slightly more involved than the example we used in the first article of this guide; it just has a few extra IDs and a heading. <form> <h1>to: Mozilla</h1> <
div id="from"> <label for="name">from:</label> <input type="text" id="name" name="user_name"> </
div> <
div id="reply"> <label for="mail">reply:</label> <input type="email" id="mail" name="user_email"> </
div> <
div id="message"> <label for="msg">Your message:</label> <textarea id="msg" name="user_message"></textarea> </
div> <
div class="button"> <button type="submit">Send your message</button> </
div> </form> Add the above code into the body of your HTML. Organiz...
Index - Learn web development
alter the font, color, size, and spacing of your content, split it into multiple columns, or add animations and other decorative features. 103 CSS building blocks Beginner, CSS, Learn, building blocks This module carries on where CSS first steps left off -- now you've gained familiarity with the language and its syntax, and got some basic experience with using it, its time to
dive a bit deeper. This module looks at the cascade and inheritance, all the selector types we have available, units, sizing, styling backgrounds and borders, debugging, and lots more. 104 A cool-looking box Assessment, Beginner, CSS, Learn, backgrounds, borders, box, box model, effects In this assessment, you'll get some more practice in creating cool-looking boxes by trying to ...
...n, Module, Multiple column, Positioning, alignment, flexbox, float, table At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so we can now
dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about. 141 Beginner's guide to media queries Beginner, CSS, Layout, Learn, media query In this lesson you have learned about media queries, and also discovered how to use them in practice to c...
...our designs. To dig further into the specification, read our guides to Grid Layout, which can be found below. 145 Introduction to CSS layout Article, Beginner, CSS, Floats, Grids, Introduction, Layout, Learn, Positioning, Tables, flexbox, flow This article has provided a brief summary of all the layout technologies you should know about. Read on for more information on each in
dividual technology! 146 Legacy layout methods Beginner, CSS, Floats, Guide, Layout, Learn, grid system, legacy You now understand how various grid systems are created, which will be useful in working with older sites and in understanding the difference between the native grid of CSS Grid Layout and these older systems. 147 Multiple-column layout Beginner, CSS, Gui...
Drawing graphics - Learn web development
en takes charge of calling requestAnimationFrame(loop) to run the next frame of the animation, again and again. Note that on each frame we are completely clearing the canvas and redrawing everything. For every ball present we draw it, update its position, and check to see if it is colliding with any other balls. Once you've drawn a graphic to a canvas, there's no way to manipulate that graphic in
dividually like you can with DOM elements. You can't move each ball around on the canvas, because once it's drawn, it's part of the canvas, and is not an in
dividual accessible element or object. Instead, you have to erase and redraw, either by erasing the entire frame and redrawing everything, or by having code that knows exactly what parts need to be erased and only erases and redraws the minimum ar...
...h draw -- well, after some of them anyway. Add the following block to the bottom of the draw() function: if (posX % 13 === 0) { if (sprite === 5) { sprite = 0; } else { sprite++; } } We are wrapping the whole block in if (posX % 13 === 0) { ... }. We use the modulo (%) operator (also known as the remainder operator) to check whether the posX value can be exactly
divided by 13 with no remainder. If so, we move on to the next sprite by incrementing sprite (wrapping to 0 after we're done with sprite #5). This effectively means that we are only updating the sprite on every 13th frame, or roughly about 5 frames a second (requestAnimationFrame() calls us at up to 60 frames per second if possible). We are deliberately slowing down the frame rate because we only ha...
...dd the following lines next: const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); camera.position.z = 5; The PerspectiveCamera() constructor takes four arguments: The field of view: How wide the area in front of the camera is that should be visible onscreen, in degrees. The aspect ratio: Usually, this is the ratio of the scene's width
divided by the scene's height. Using another value will distort the scene (which might be what you want, but usually isn't). The near plane: How close to the camera objects can be before we stop rendering them to the screen. Think about how when you move your fingertip closer and closer to the space between your eyes, eventually you can't see it anymore. The far plane: How far away things are f...
Third-party APIs - Learn web development
pquest-js/v1.3.2/mapquest.css"/> You can then start using the objects available in that library. For example: let map = L.mapquest.map('map', { center: [53.480759, -2.242631], layers: L.mapquest.tileLayer('map'), zoom: 12 }); Here we are creating a variable to store the map information in, then creating a new map using the mapquest.map() method, which takes as its parameters the ID of a <
div> element you want to display the map in ('map'), and an options object containing the details of the particular map we want to display. In this case we specify the coordinates of the center of the map, a map layer of type map to show (created using the mapquest.tileLayer() method), and the default zoom level. This is all the information the Mapquest API needs to plot a simple map. The server you...
...{ for(var i = 0; i < articles.length; i++) { const article = document.createElement('article'); const heading = document.createElement('h2'); const link = document.createElement('a'); const img = document.createElement('img'); const para1 = document.createElement('p'); const para2 = document.createElement('p'); const clearfix = document.createElement('
div'); let current = articles[i]; console.log(current); link.href = current.web_url; link.textContent = current.headline.main; para1.textContent = current.snippet; para2.textContent = 'Keywords: '; for(let j = 0; j < current.keywords.length; j++) { const span = document.createElement('span'); span.textContent += current.keywords[j].value + '...
... keywords associated with each article, and insert each one inside its own <span>, inside a <p>. This was done to make it easy to style each one. We used an if() block (if(current.multimedia.length > 0) { ... }) to check whether each article has any images associated with it (some stories don't.) We display the first image only if it exists (otherwise an error would be thrown). We gave our <
div> element a class of "clearfix", so we can easily apply clearing to it. Wiring up the pagination buttons To make the pagination buttons work, we will increment (or decrement) the value of the pageNumber variable, and then re-rerun the fetch request with the new value included in the page URL parameter. This works because the NYTimes API only returns 10 results at a time -- if more than 10 ...
Introduction to the server side - Learn web development
d how it differs from client-side programming. Most large-scale websites use server-side code to dynamically display different data when needed, generally pulled out of a database stored on a server and sent to the client to be displayed via some code (e.g. HTML and JavaScript). Perhaps the most significant benefit of server-side code is that it allows you to tailor website content for in
dividual users. Dynamic sites can highlight content that is more relevant based on user preferences and habits. It can also make sites easier to use by storing personal preferences and information -- for example reusing stored credit card details to streamline subsequent payments. It can even allow interaction with users of the site, sending notifications and updates via email or through other chann...
...ide component of a web app without a framework -- implementing a vital feature like an HTTP server is really hard to do from scratch in say Python, but Python web frameworks like Django provide one out of the box, along with other very useful tools. What can you do on the server-side? Server-side programming is very useful because it allows us to efficiently deliver information tailored for in
dividual users and thereby create a much better user experience. Companies like Amazon use server-side programming to construct search results for products, make targeted product suggestions based on client preferences and previous buying habits, simplify purchases, etc. Banks use server-side programming to store account information and allow only authorized users to view and make transactions. Ot...
...server-side programming. You've now learned that server-side code is run on a web server and that its main role is to control what information is sent to the user (while client-side code mainly handles the structure and presentation of that data to the user). You should also understand that it is useful because it allows us to create websites that efficiently deliver information tailored for in
dividual users and have a good idea of some of the things you might be able to do when you're a server-side programmer. Lastly, you should understand that server-side code can be written in a number of programming languages and that you should use a web framework to make the whole process easier. In a future article we'll help you choose the best web framework for your first site. Here we'll take ...
Introduction to client-side frameworks - Learn web development
started in the SproutCore project. It is an older framework that has less users than more modern alternatives such as React and Vue, but it still enjoys a fair amount of popularity due to its stability, community support, and some clever coding principles. Start learning Ember Angular Angular is an open-source web application framework led by the Angular Team at Google and by a community of in
dividuals and corporations. It is a complete rewrite from the same team that built AngularJS. Angular was officially released on the 14th of September 2016. Angular is a component-based framework which uses declarative HTML templates. At build time, transparently to developers, the framework's compiler translates the templates to optimized JavaScript instructions. Angular uses TypeScript, a superset...
...es not. Thanks to Vue, we didn't have to write our own functions for building the UI; the framework will handle that for us in an optimized, efficient way. Our only role here was to describe to Vue what each item should look like. Developers who are familiar with Vue can join our project and quickly work out what is going on. Vue is not alone in this: using a framework improves team as well as in
dividual efficiency. It's possible to do things similar to this in vanilla JavaScript. Template literal strings make it easy to write strings of HTML that represent what the final element would look like. That might be a useful idea for something as simple as our to-do list application, but it's not maintainable for large applications that manage thousands of records of data, and could render just a...
... not dependent upon it. Static site generators take time to learn, just like any other tool, which can be a barrier to your development process. Static sites can have as few or as many unique pages as you want. Just as frameworks empower you to quickly write client-side JavaScript applications, static site generators allow you a way to quickly create HTML files you would otherwise have written in
dividually. Like frameworks, static site generators allow developers to write components that define common pieces of your web pages, and to compose those components together to create a final page. In the context of static site generators, these components are called templates. Web pages built by static site generators can even be home to framework applications: if you want one specific page of your...
Advanced Svelte: Reactivity, lifecycle, accessibility - Learn web development
of the completed todos should be removed. Put the following content into your MoreActions.svelte file: <script> import { createEventDispatcher } from 'svelte' const dispatch = createEventDispatcher() let completed = true const checkAll = () => { dispatch('checkAll', completed) completed = !completed } const removeCompleted = () => dispatch('removeCompleted') </script> <
div class="btn-group"> <button type="button" class="btn btn__primary" on:click={checkAll}>{completed ? 'Check' : 'Uncheck'} all</button> <button type="button" class="btn btn__primary" on:click={removeCompleted}>Remove completed</button> </
div> We've also included a completed variable to toggle between checking and unchecking all tasks. Back over in Todos.svelte, we are going to import ou...
... To find...
...e component like this: <script> import { createEventDispatcher } from 'svelte' const dispatch = createEventDispatcher() export let todos let completed = true const checkAll = () => { dispatch('checkAll', completed) completed = !completed } const removeCompleted = () => dispatch('removeCompleted') $: completedTodos = todos.filter(t => t.completed).length </script> <
div class="btn-group"> <button type="button" class="btn btn__primary" disabled={todos.length === 0} on:click={checkAll}>{completed ? 'Check' : 'Uncheck'} all</button> <button type="button" class="btn btn__primary" disabled={completedTodos === 0} on:click={removeCompleted}>Remove completed</button> </
div> We've also declared a reactive completedTodos variable to enable or disable the Re...
Deploying our app - Learn web development
he repository. Push the changes to GitHub. To add changes, run the following command: git add . Note the period at the end, it means "everything in this directory". The git add . command is a bit of a sledgehammer approach -- it will add all local changes you've worked on in one go. If you want finer control over what you add, then use git add -p for an interactive process, or add in
dividual files using git add path/to/file. Now all the code is staged, we can commit; run the following command: git commit -m 'committing initial code' Note: Although you're free to write whatever you wish in the commit message, there's some useful tips around the web on good commit messages. Keep them short, concise, and descriptive, so they clearly describe what the change does. ...
... does not include a test framework, as with all things in the front-end development world, there are a slew of framework options. The test itself isn't what is important. What is important is how the failure or success is handled. Some deployment platforms will include a specific method for testing as part of their pipeline. Products like GitHub, GitLab, etc., all support running tests against in
dividual commits. As this project is deploying to Netlify, and Netlify only asks about the build command, we will have to make the tests part of the build. If the test fails, the build fails, and Netlify won't deploy. Let's get started. Go to your package.json file and open it up. Find your scripts member, and update it so that it contains the following test and build commands: "scri...
...en build the code. You'll have to upload your new code to GitHub, using similar commands to what you used before: git add . git commit -m 'adding test' git push github master In some cases you might want to test the result of the built code (since this isn't quite the original code we wrote), so the test might need to be run after the build command. You'll need to consider all these in
dividual aspects whilst you're working on your own projects. Now, finally, a minute or so after pushing, Netlify will deploy the project update. But only if it passes the test that was introduced. Summary That's it for our sample case study, and for the module! We hope you found it useful. While there is a long way to go before you can consider yourself a client-side tooling wizard, we are hopi...
Overview of Mozilla embedding APIs
ts the nsIWeakReference interface. Global Services nsServiceManager The Service Manager is the central repository for accessing instances of the various XPCOM services. Each service is represented by a singleton object which is instantiated the first time it is requested and remains alive until the Service Manager is shut down, or the service is explicitly unloaded. Through the Service Manager, in
dividual services can be loaded, unloaded and accessed. Implemented Interfaces: nsIServiceManager Related Interfaces: nsIShutdownListener nsMemory The nsMemory service provides the global memory manager implementation for XPCOM. In addition to memory allocation and release, this service provides low memory notifications, called a memory pressure observers, which are notified when memory is lo...
...ner Public Components nsWebBrowser The nsWebBrowser is the main embedding component which Gecko exposes. Conceptually, each nsWebBrowser instance represents a HTML content area. Conceptually, for each document being rendered, Gecko creates a container called a DOMWindow. Each WebBrowser exposes a tree of DOMWindows - representing the frame hierarchy for the current document. As such, access to in
dividual document frames is done via the DOMWindow interfaces. Manipulation of the entire document structure is done via the various WebBrowser interfaces. Contract-id: NS_WEBBROWSER_CONTRACTID Implemented Interfaces: nsIWebBrowser nsIWebNavigation nsIWebBrowserSetup nsIWebBrowserPersist nsIWebBrowserFind nsIWebBrowserPrint nsIWebBrowserFocus nsIBaseWindow Requestor Interfaces: n...
...rface exposes the web navigation functionality of the nsWebBrowser component. Interface status... being reviewed Interface definition: nsIWebNavigation.idl nsIWebBrowserPersist This interface exposes the save-as functionality of the nsWebBrowser component. Interface status... being reviewed Interface definition: nsIWebBrowserPersist.idl nsIWebBrowserPrint This interface allows printing of in
dividual (or a collection of) DOM Windows within a nsWebBrowser component. Interface status... being reviewed Interface definition: nsIWebBrowserPrint.idl nsIWebBrowserFind This interface exposes the searching capabilities of the nsWebBrowser component. Interface status... none Interface definition: nsIWebBrowserFind.idl nsIWebBrowserFocus This interface provides access to the focus information...
Translation phase
At Mozilla, we localize many different projects that can be categorized into three different groups. Each group of projects employs a different type of l10n tool for, you guessed it, localizing the projects. ...
...ith them. Along the way we'll point you to basic, technical tutorials on localizing for that particular project group. It's up to you and your community to determine which l10n tool will best suit your needs. As you gain more experience, you may want to localize independent of Mozilla-developed l10n tools, which we'll also discuss here. Projects The Mozilla projects and their l10n workflows are
divided into these groups: Mozilla applications, Mozilla websites, and Add-ons. Below you'll find the list of all Mozilla projects, their associated l10n tools, and links to tutorials outlining their workflows. Mozilla applications So you're interested in localizing Mozilla applications. Each l10n tool follows a different workflow for localizing Mozilla application projects. We've linked a brief tu...
...cations. Read the guidelines on localizing AMO, straight from the AMO team. developer.mozilla.org (MDN) Where you are now! Help localize the MDN user interface for everyone in your region. support.mozilla.com (SUMO) A portal for anyone who needs technical support for their Mozilla applications. Help localize the SUMO user interface for everyone in your region. Mozilla Engagement Campaigns In
dividual campaigns created by Mozilla to attract new contributors. hacks.mozilla.org For everyone interested in the leading-edge stuff that people are doing with Mozilla Firefox and the open web. In-product pages A set of pages used to interact with and give information to the end-user as part of their first experience with their Mozilla applications. If you are creating your own localization, ...
An overview of NSS Internals
you safely keep your own secret keys that belong to your own certificates. You might want to protect the storage of your secret keys with PBE. You might decide to modify the default trust provided by NSS. All of this requires storing, looking up, and retrieving data. NSS simplifies performing these operations by offering storage and management APIs. NSS doesn't require the programmer to manage in
dividual files containing in
dividual certificates or keys. Instead, NSS offers to use its own database(s). Once you have imported certificates and keys into the NSS database, you can easily look them up and use them again. Because of NSS's expectation to operate with an NSS database, it's mandatory that you perform an initialization call, where you tell NSS which database you will be using. In the...
... store such an untyped block is SECItem, which contains a size and an untyped C pointer variable. When dealing with memory, NSS makes use of arenas, which are an attempt to simplify management with the limited offerings of C (because there are no destructors). The idea is to group multiple memory allocations in order to simplify cleanup. Performing an operation often involves allocating many in
dividual data items, and the code might be required to abort a task at many positions in the logic. An arena is requested once processing of a task starts, and all memory allocations that are logically associated to that task are requested from the associated arena. The implementation of arenas makes sure that all in
dividual memory blocks are tracked. Once a task is done, regardless whether it comple...
...ns in the logic. An arena is requested once processing of a task starts, and all memory allocations that are logically associated to that task are requested from the associated arena. The implementation of arenas makes sure that all in
dividual memory blocks are tracked. Once a task is done, regardless whether it completed or was aborted, the programmer simply needs to release the arena, and all in
dividually allocated blocks will be released automatically. Often freeing is combined with immediately erasing (zeroing, zfree) the memory associated to the arena, in order to make it more difficult for attackers to extract keys from a memory dump. NSS uses many C data structures. Often NSS has multiple implementations for the same or similar concepts. For example, there are multiple presentations...
Secure Development Guidelines
a/b : 0; } Writing Secure Code: Memo...
... new_size = size; printf("0x%08x\r\n", new_size); } Casting Issues: Sign Extension Prevention Be careful with signed integers Use unsigned integers for sizes, offsets, and indexes Denial of Service:
Divide by Zero Example: int main() { int a, b; if (argc != 3) return 1; a = atoi(argv[1]); b = atoi(argv[2]); return a/b; } Denial of Service:
Divide INT_MIN by -1 Example: int main(int argc, char **argv) { int a, b; if (argc != 3) return 1; a = atoi(argv[1]); b = atoi(argv[2]); return b ? a/b : 0; } Writing Secure Code: Memory Management String Handling C-style strings are byte arrays that end with a \0 byte Some string handling functions won't perform any kind of length checking, so don't use the...
... ~foo() { if (ptr) free(ptr); } }; Constructor/Destructor Issues: Prevention Initialize the data members of an object in the constructor Writing Secure Code: Miscellaneous File I/O A lot can go wrong because a lot can be done with file input and output Filenames Permissions File handles and descriptors File I/O: Filename
Divided in directories, subdirectories, and the file itself '/' is separator; in Windows '\' would work too int openfile(char *file) { HANDLE fh; if (strstr(file, "\")) return -1; fh = CreateFileA(file, ...); WriteFile(fh, data, sizeofdata, NULL, NULL); } Could be a normal file, directory, device, or link Directory traversal (../../../../) File I/O: File Per...
Building the WebLock UI
. weblock.js provides JavaScript functions for both of the XUL files. Each of these files is described briefly in the sections below. In the following chapter we'll describe how you can take these files and create a package, an installable archive that includes the WebLock component and the new UI. Because this step (particularly the overlay section) is so dependent on Mozilla, the chapter is
divided up into a couple of different sections. The second section, XUL, describes the XML-based User Interface Language (XUL) and how you can use it to create a dialog that provides access to the WebLock component and its services. The third section, Overlaying New User Interface Into Mozilla, describes how to create an overlay into the browser that will make this dialog accessible from a Mozilla bu...
...or the web lock manager dialog is defined in weblock.xul below. The Locking UI Once you have the basic XUL wrapper set up for your interface, the next step is to define that part of the interface that locks and unlocks the browser. One of the most efficient ways to expose this is to use radio buttons, which allow the user to toggle a particulart state, as the figure above illustrates. In XUL in
dividual <radio/> elements are contained within a parent element called <radiogroup/>. Grouping radio elements together creates the toggling UI by requiring that one or another of the elements be selected, but not both. The XUL that defines the radiogroup in the web lock manager dialog is this: <radiogroup> <radio label="lock"/> <radio label="unlock" selected="true"/> </radiogroup> Since th...
... validity) and passing it through to the AddSite API we defined in the earlier part of the tutorial. <separator class="thin"/> <hbox align="center"> <textbox id="url.input" flex="1"/> <button label="Add this URL" oncommand="addThisSite();"/> </hbox> This snippet introduces a couple of new general layout widgets in XUL. The separator that appears at the top of this snippet creates a little
divider between widgets like the kind you see in menus that
divide sets of functionality available there. The parent of the textbox that users enter an URL into is something called an <hbox/>, which is a layout widget - often invisible - that controls the way its child elements are rendered. In this case the <hbox/> centers the textbox and the button children, and it orients them horizontally (in con...
jsdIStackFrame
ook which gave it to you. After you return from that handler the bottom frame, and any frame you found attached through it, are invalidated via the jsdIEphemeral interface. Once a jsdIStackFrame has been invalidated all method and property accesses will throw a NS_ERROR_NOT_AVAILABLE exception. Method overview boolean eval(in AString bytes, in AUTF8String fileName, in unsigned long line, out js
dIValue result); Attributes Attribute Type Description callee js
dIValue Function object running in this stack frame. Read only. callingFrame jsdIStackFrame Link to the caller's stack frame. Read only. executionContext jsdIContext Executon context. Read only. functionName AUTF8String Function name executing in this stack frame. Read only. isConstructing boolean True if stack frame is c...
... JSDContext Internal use only. Read only. Native code only! JSDStackFrameInfo JSDStackFrameInfo Internal use only. Read only. Native code only! JSDThreadState JSDThreadState Internal use only. Read only. Native code only! line unsigned long Current line number (using the script's pc to line map.) Read only. pc unsigned long Current program counter in this stack frame. Read only. ...
...adState JSDThreadState Internal use only. Read only. Native code only! line unsigned long Current line number (using the script's pc to line map.) Read only. pc unsigned long Current program counter in this stack frame. Read only. scope js
dIValue Top object in the scope chain. Read only. script jsdIScript Script running in this stack frame, null for native frames. Read only. thisValue js
dIValue |this| object for this stack frame. Read only. Methods eval() Evaluate arbitrary JavaScript in this stack frame. boolean eval( in AString bytes, in AUTF8String fileName, in unsigned long line, out js
dIValue result ); Parameters bytes Script to be evaluated. fileName Filename to compile this script under. This is the filename you'll see in error messages, and so on. line result ...
Tutorial: Set a breakpoint - Firefox Developer Tools
loper tools, click on the options gear at the upper right of the toolbox, and make sure that both "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" are checked. These are located at the bottom right of the options panel; you may need to scroll to see them. Once they're checked, you can close the developer tools. Save the following text to an HTML file: <
div onclick="report('the best
div');">Click me!</
div> <
div onclick="report('another great
div');">Or me!</
div> <script> function report(what) { console.log('clicked: ' + what); } </script> Visit the HTML file in your browser, and open the Browser Content Toolbox by opening the Firefox menu, choosing "Web Developer", and then "Browser Content Toolbox". If that item doesn't appear in the "Web D...
...O.script.setBreakpoint(0, { hit: function (frame) { console.log('hit breakpoint in ' + frame.callee.name); console.log('what = ' + frame.eval('what').return); } }); console.log('Finished setting breakpoint!'); In the Scratchpad, ensure that no text is selected, and press the "Run" button. Now, click on the text that says "Click me!" in the web page. This runs the
div element's onclick handler. When control reaches the start of the report function, Debugger calls the breakpoint handler's hit method, passing a Debugger.Frame instance. The hit method logs the breakpoint hit to the browser content toolbox's console. Then it evaluates the expression what in the given stack frame, and logs its result. The toolbox's console now looks like this: You can also c...
...ray as the debuggee. Press "Run" in the Scratchpad again. Now, clicking on "Click me!" causes the breakpoint hit to be logged twice--one for each Debugger instance. Multiple Debugger instances can observe the same debuggee. Re-running the code in the Scratchpad creates a fresh Debugger instance, adds the same web page as its debuggee, and then sets a new breakpoint. When you click on the
div element, both Debuggers' breakpoints are hit, and both handlers run. This shows how any number of Debugger-based tools can observe a single web page simultaneously. In fact, you can use the Browser Content Toolbox's Debugger panel to set its own breakpoint in report, and it will trigger along with the first two. Keep in mind, however, that when multiple Debuggers share a debuggee, the order in...
DOM allocation example - Firefox Developer Tools
(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function createToolbarButton() { var toolbarButton = document.createElement("span"); toolbarButton.classList.add("toolbarbutton"); // stop Spidermonkey from sharing instances toolbarButton[getRandomInt(0,5000)] = "foo"; return toolbarButton; } function createToolbar() { var toolbar = document.createElement("
div"); // stop Spidermonkey from sharing instances toolbar[getRandomInt(0,5000)] = "foo"; for (var i = 0; i < toolbarButtonCount; i++) { var toolbarButton = createToolbarButton(); toolbar.appendChild(toolbarButton); } return toolbar; } function createToolbars() { var container = document.getElementById("container"); for (var i = 0; i < toolbarCount; i++) { var toolbar = cre...
... ...
... ...
Tree map view - Firefox Developer Tools
in Firefox 48. The Tree map view provides a visual representation of the snapshot, that helps you quickly get an idea of which objects are using the most memory. A treemap displays "hierarchical (tree-structured) data as a set of nested rectangles". The size of the rectangles corresponds to some quantitative aspect of the data. For the treemaps shown in the Memory tool, things on the heap are
divided at the top level into four categories: objects: JavaScript and DOM objects, such as Function, Object, or Array, and DOM types like Window and HTML
DivElement. scripts: JavaScript sources loaded by the page. strings other: this includes internal SpiderMonkey objects. Each category is represented with a rectangle, and the size of the rectangle corresponds to the proportion of the heap oc...
...e page. strings other: this includes internal SpiderMonkey objects. Each category is represented with a rectangle, and the size of the rectangle corresponds to the proportion of the heap occupied by items in that category. This means you can quickly get an idea of roughly what sorts of things allocated by your site are using the most memory. Within top-level categories: objects is further
divided by the object's type. scripts is further sub
divided by the script's origin. It also includes a separate rectangle for code that can't be correlated with a file, such as JIT-optimized code. other is further sub
divided by the object's type. Here are some example snapshots, as they appear in the Tree map view: This treemap is from the DOM allocation example, which simply runs a script tha...
...sub
divided by the script's origin. It also includes a separate rectangle for code that can't be correlated with a file, such as JIT-optimized code. other is further sub
divided by the object's type. Here are some example snapshots, as they appear in the Tree map view: This treemap is from the DOM allocation example, which simply runs a script that creates a large number of DOM nodes (200 HTML
DivElement objects and 4000 HTMLSpanElement objects). You can see how almost all the heap usage is from the HTMLSpanElement objects that it creates. This treemap is from the monster allocation example, which creates three arrays, each containing 5000 monsters, each monster having a randomly-generated name. You can see that most of the heap is occupied by the strings used for the monsters' names, a...
Migrating from Firebug - Firefox Developer Tools
he Rules side panel. The second one is to right-click and element within the node view and toggle the pseudo-classes via the context menu. Examine CSS shorthand properties CSS shorthand properties can be split into their related longhand properties by setting the option Expand Shorthand Properties within the Style side panel. The DevTools' Rules panel is a bit smarter and allows you to expand in
dividual shorthand properties by clicking the twisty besides them. Only show applied styles The Style side panel in Firebug has an option to display only the properties of a CSS rule that are applied to the selected element and hide all overwritten styles. There is no such feature in the Rules side panel of the DevTools, but it is requested in bug 1335327. Inspect box model In Firebug the box mod...
...also a request to add an Events side panel to them like the one in Firebug (see bug 1226640). Stop script execution on DOM mutation In Firebug you can break on DOM mutations, that means that when an element is changed, the script execution is stopped at the related line within the JavaScript file, which caused the change. This feature can globally be enabled via the Break On Mutate button, or in
dividually for each element and for different types of changes like attribute changes, content changes or element removal. Unfortunately, the DevTools do not have this feature yet (see bug 1004678). To stop the script execution there, you need to set a breakpoint on the line with the modification within the Debugger panel. Search for elements via CSS selectors or XPaths Firebug allows to search for...
...ou can inspect that object either via the DOM property viewer or via the Web Console. Style Editor The Style Editor in the Firefox DevTools allows you to examine and edit the different CSS style sheets of a page like Firebug's CSS panel does it. In addition to that it allows to create new style sheets and to import existing style sheets and apply them to the page. It also allows you to toggle in
dividual style sheets. Switch between sources The CSS panel of Firebug allows to switch between different CSS sources using the CSS Location Menu. The Style Editor has a sidebar for this purpose. Edit a style sheet Firebug's CSS panel offers three different ways for editing style sheets. The default one is to edit them inline like within the Style side panel. Furthermore it has a Source and a Liv...
Examine and edit HTML - Firefox Developer Tools
s the last child of this node. Scroll Into View Scrolls the web page so the selected node is visible. From Firefox 44, pressing the keyboard shortcut S will also scroll the selected node into view. Screenshot Node Takes a screenshot of the selected node, saved to your Downloads directory. See Taking screenshots. Create New Node Create a new empty <
div> as the last child of the currently selected element. See Inserting new nodes. Duplicate Node Create a copy of this element, and insert the copy immediately after this element. Delete Node Delete the element from the DOM. Attribute/Add Attribute Add an attribute to the element. Attribute/Edit Attribute (only when invoked on an attribute) Edit the at...
... the HTML content of a page by moving nodes in the HTML tree. Just click and hold on any element and drag it up or down in the tree. When you release the mouse button, the element will be inserted at the corresponding position: You can cancel the drag and drop by pressing the Esc key. Inserting new nodes There's a "+" icon at the top of the markup view: Click this icon to insert an empty <
div> into the document as the last child of the currently selected element. You can then edit the new node's content and styling just as you would any other node in the document. You can access the same functionality using the "Create New Node" popup menu item. Note that this button is disabled if the selected element's type is such that adding a last-child would have no effect (for example, if i...
... content and styling just as you would any other node in the document. You can access the same functionality using the "Create New Node" popup menu item. Note that this button is disabled if the selected element's type is such that adding a last-child would have no effect (for example, if is is an <html> or <iframe> element). However, it is enabled in places where it is not valid to insert a <
div>, such as <style> or <link>. In these cases the element is added as text. ...
AudioNode - Web APIs
The AudioNode interface is a generic interface for representing an audio processing module. Examples include: an audio source (e.g. an HTML <audio> or <video> element, an OscillatorNode, etc.), the audio destination, intermediate processing module (e.g. ...
... Description The audio routing graph Each AudioNode has inputs and outputs, and multiple audio nodes are connected to build a processing graph. This graph is contained in an AudioContext, and each audio node can only belong to one audio ...
... You can sub-class an audio node. While the actual processing is done internally by the browser and cannot be altered, you could write a wrapper around an audio node to provide custom properties and methods. Slightly better performance: In both Chrome and Firefox, the factory methods call the constructors internally. Keep in mind that Microsoft Edge does not yet appear to support the c...
BaseAudioContext - Web APIs
oContext interface of the Web Audio API acts as a base definition for online and offline audio-processing graphs, as represented by AudioContext and OfflineAudioContext respectively. You wouldn't use BaseAudioContext directly -- you'd use its features via one of these two inheriting interfaces. A BaseAudioContext can be a target of events, therefore it implements the EventTarget interface. ...
... BaseAudioContext.currentTime Read only Returns a doubl...
...object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value. BaseAudioContext.createChannelMerger() Creates a ChannelMergerNode, which is used to combine channels from multiple audio streams into a single audio stream. BaseAudioContext.createChannelSplitter() Creates a ChannelSplitterNode, which is used to access the in
dividual channels of an audio stream and process them separately. BaseAudioContext.createConvolver() Creates a ConvolverNode, which can be used to apply convolution effects to your audio graph, for example a reverberation effect. BaseAudioContext.createDelay() Creates a DelayNode, which is used to delay the incoming audio signal by a certain amount. This node is also useful to create feedback loo...
BroadcastChannel: message event - Web APIs
es on that channel. Bubbles No Cancelable No Interface MessageEvent Event handler property onmessage Examples Live example In this example there's a "sender" <iframe> that broadcasts the contents of a <textarea> when the user clicks a button. There are two "receiver" iframes that listen to the broadcast message and write the result into a <
div> element. Sender <h1>Sender</h1> <label for="message">Type a message to broadcast:</label><br/> <textarea id="message" name="message" rows="1" cols="40">Hello</textarea> <button id="broadcast-message" type="button">Broadcast message</button> body { border: 1px solid black; padding: .5rem; height: 150px; font-family: "Fira Sans", sans-serif; } h1 { font: 1.6em "Fira Sa...
...; } button { vertical-align: top; height: 1.5rem; } const channel = new BroadcastChannel('example-channel'); const messageControl = document.querySelector('#message'); const broadcastMessageButton = document.querySelector('#broadcast-message'); broadcastMessageButton.addEventListener('click', () => { channel.postMessage(messageControl.value); }) Receiver 1 <h1>Receiver 1</h1> <
div id="received"></
div> body { border: 1px solid black; padding: .5rem; height: 100px; font-family: "Fira Sans", sans-serif; } h1 { font: 1.6em "Fira Sans", sans-serif; margin-bottom: 1rem; } const channel = new BroadcastChannel('example-channel'); channel.addEventListener('message', (event) => { received.textContent = event.data; }); Receiver 2 <h1>Receiver 2</h1> ...
...id="received"></
div> body { border: 1px solid black; padding: .5rem; height: 100px; font-family: "Fira Sans", sans-serif; } h1 { font: 1.6em "Fira Sans", sans-serif; margin-bottom: 1rem; } const channel = new BroadcastChannel('example-channel'); channel.addEventListener('message', (event) => { received.textContent = event.data; }); Receiver 2 <h1>Receiver 2</h1> <
div id="received"></
div> body { border: 1px solid black; padding: .5rem; height: 100px; font-family: "Fira Sans", sans-serif; } h1 { font: 1.6em "Fira Sans", sans-serif; margin-bottom: 1rem; } const channel = new BroadcastChannel('example-channel'); channel.addEventListener('message', (event) => { received.textContent = event.data; }); Result Specifications ...
CSSKeywordValue.CSSKeywordValue() - Web APIs
esents CSS keywords and other identifiers. Syntax var cssKeywordValue = new CSSKeywordValue(val) Parameters value Sets or returns the value of the new CSSKeywordValue. Examples The following example resets the CSS display property to its defaults, setting the inline style attribute to style="display: initial" if viewed in the developer tools inspector. ...
...e Sets or returns the value of the new CSSKeywordValue. Examples The following example resets the CSS display property to its defaults, setting the inline style attribute to style="display: initial" if viewed in the developer tools inspector. ...
...s or returns the value of the new CSSKeywordValue. Examples The following example resets the CSS display property to its defaults, setting the inline style attribute to style="display: initial" if viewed in the developer tools inspector. #myElement { display: flex; } <
div id="myElement">Check the developer tools to see the log in the console and to inspect the style attribute on this
div.</
div> let keyword = new CSSKeywordValue('initial'); let myElement = document.getElementById('myElement').attributeStyleMap; myElement.set('display', keyword); console.log( myElement.get('display').value); // 'initial' console.dir( keyword ); Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSKeywordValue' in that specification. ...
Manipulating video using canvas - Web APIs
erform chroma-keying (also known as the "green screen effect") using JavaScript code. The document content The HTML document used to render this content is shown below. ...
...TYPE html> <html> <head> <style> body { background: black; color:#CCCCCC; } #c2 { background-image: url(media/foo.png); background-repeat: no-repeat; }
div { float: left; border :1px solid #444444; padding:10px; margin: 10px; background:#3B3B3B; } </style> </head> <body> <
div> <video id="video" src="media/video.mp4" controls="true" crossorigin="anonymous"/> </
div> <
div> <canvas id="c1" width="160" height="96"></canvas> <canvas id="c2" width="160" height="96"></canvas> </
div> <script type="text/javascript" src="processor.js"></script> </body> </html> The key bits to take away from this are: This document establishes two canvas ele...
... can simply pass the video element into the context's drawImage() method to draw the current video frame into the context. The result is: Line 3 fetches a copy of the raw graphics data for the current frame of video by calling the getImageData() method on the first context. This provides raw 32-bit pixel image data we can then manipulate. Line 4 computes the number of pixels in the image by
dividing the total size of the frame's image data by four. The for loop that begins on line 6 scans through the frame's pixels, pulling out the red, green, and blue values for each pixel, and compares the values against predetermined numbers that are used to detect the green screen that will be replaced with the still background image imported from foo.png. Every pixel in the frame's image data tha...
Optimizing canvas - Web APIs
yer your items using multiple <canvas> elements. For example, let's say you have a game with a UI on top, the gameplay action in the middle, and a static background on the bottom. In this case, you could split your game into three <canvas> layers. The UI would change only upon user input, the gameplay layer would change with every new frame, and the background would remain generally unchanged. ...
...split your game into three <canvas> layers. The UI would change only upon user input, the gameplay layer would change with every new frame, and the background would remain generally unchanged. ...
...This will negate the need to render the background to the canvas on every tick. Scaling canvas using CSS transforms CSS transforms are faster since they use the GPU. The best case is to not scale the canvas, or have a smaller canvas and scale up rather than a bigger canvas and scale down. ...
Using images - Web APIs
en you want to make compositions. You could have all elements in a single image file and use this method to composite a complete drawing. For instance, if you want to make a chart you could have a PNG image containing all the necessary text in a single file and depending on your data could change the scale of your chart fairly easily. Another advantage is that you don't need to load every image in
dividually, which can improve load performance. Example: Framing an image In this example, we'll use the same rhino as in the previous example, but we'll slice out its head and composite it into a picture frame. The picture frame image is a 24-bit PNG which includes a drop shadow. Because 24-bit PNG images include a full 8-bit alpha channel, unlike GIF and 8-bit PNG images, it can be placed onto an...
... we'll slice out its head and composite it into a picture frame. The picture frame image is a 24-bit PNG which includes a drop shadow. Because 24-bit PNG images include a full 8-bit alpha channel, unlike GIF and 8-bit PNG images, it can be placed onto any background without worrying about a matte color. ...
... any background without worrying about a matte color. <html> <body onload="draw();"> <canvas id="canvas" width="150" height="150"></canvas> <
div style="display:none;"> <img id="source" src="https://udn.realityripple.com/samples/db/f374e9c6fc.jpg" width="300" height="227"> <img id="frame" src="https://udn.realityripple.com/samples/57/952c634159.png" width="132" height="150"> </
div> </body> </html> function draw() { var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); // Draw slice ctx.drawImage(document.getElementById('source'), 33, 71, 104, 124, 21, 20, 87, 104); // Draw frame ctx.drawImage(document.getElementById('frame'), 0, 0); } We took a different approach to loading the images this time. Instead of load...
DataTransfer.items - Web APIs
ng DataTransferItem objects representing the items being dragged in a drag operation, one list item for each object being dragged. If the drag operation had no data, the list is empty. Example This example shows the use of the items and types properties. ...
... Living Standard HTML 5.1The definition of 'items' in that specification. Recommendation Initial definition ...
... Living Standard HTML 5.1The definition of 'items' in that specification. Recommendation Initial definition ...
DataTransfer.types - Web APIs
ach format is string. If the drag operation included no data, this list will be empty. If any files are included in the drag operation, then one of the types will be the string Files. Example This example shows the use of the types and items properties. ...
... Living Standard HTML 5.1The definition of 'types' in that specification. Recommendation Initial definition ...
... Living Standard HTML 5.1The definition of 'types' in that specification. Recommendation Initial definition ...
Document.createElementNS() - Web APIs
tag name. Custom elements are an experimental feature only available in some browsers. Return value The new Element. Important Namespace URIs HTML http://www.w3.org/1999/xhtml SVG http://www.w3.org/2000/svg MathML http://www.w3.org/1998/Math/MathML XUL http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul XBL http://www.mozilla.org/xbl Example This creates a new <
div> element in the XHTML namespace and appends it to the vbox element. Although this is not an extremely useful XUL document, it does demonstrate the use of elements from two different namespaces within a single document: <?xml version="1.0"?> <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" title="||Working with eleme...
...useful XUL document, it does demonstrate the use of elements from two different namespaces within a single document: <?xml version="1.0"?> <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" title="||Working with elements||" onload="init()"> <script type="application/javascript"><![CDATA[ let container; let new
div; let txtnode; function init(){ container = document.getElementById("ContainerBox"); new
div = document.createElementNS("http://www.w3.org/1999/xhtml", "
div"); txtnode = document.createTextNode("This is text that was constructed dynamically with createElementNS and createTextNode then inserted into the document using appendChild."); new
div.appendChild(txtnode); container.appendChi...
... txtnode; function init(){ container = document.getElementById("ContainerBox"); new
div = document.createElementNS("http://www.w3.org/1999/xhtml", "
div"); txtnode = document.createTextNode("This is text that was constructed dynamically with createElementNS and createTextNode then inserted into the document using appendChild."); new
div.appendChild(txtnode); container.appendChild(new
div); } ]]></script> <vbox id="ContainerBox" flex="1"> <html:
div> The script on this page will add dynamic content below: </html:
div> </vbox> </page> The example given above uses inline script which is not recommended in XHTML documents. This particular example is actually an XUL document with embedded XHTML, however, the recommendation still applies. Specifications Specif...
Document.getBoxObjectFor() - Web APIs
Returns a boxObject (x, y, width, height) for a specified element. Note: This method is obsolete. You should use the element.getBoundingClientRect() method instead. ...
... Returns a boxObject (x, y, width, height) for a specified element. Note: This method is obsolete. You should use the element.getBoundingClientRect() method instead. ...
... Returns a boxObject (x, y, width, height) for a specified element. Note: This method is obsolete. You should use the element.getBoundingClientRect() method instead. ...
Introduction to the DOM - Web APIs
this book. The document and window objects are the objects whose interfaces you generally use most often in DOM programming. In simple terms, the window object represents something like the browser, and the document object is the root of the document itself. Element inherits from the generic Node interface, and together these two interfaces provide many of the methods and properties you use on in
dividual elements. These elements may also have specific interfaces for dealing with the kind of data those elements hold, as in the table object example in the previous section. The following is a brief list of common APIs in web and XML page scripting using the DOM. document.getElementById(id) document.getElementsByTagName(name) document.createElement(name) parentNode.appendChild(node) elem...
... interested in and see how they work on the browser platform. You can update the contents of the test() function as needed, create more buttons, or add elements as necessary. ...
...The following screenshot gives you some idea of how interfaces can be grouped together for testing. Figure 0.1 Sample DOM Test Page In this example, t...
Element: fullscreenchange event - Web APIs
an Element switches into or out of full-screen mode. Bubbles Yes Cancelable No Interface Event Event handler property onfullscreenchange This event is sent to the Element which is transitioning into or out of full-screen mode. Examples In this example, a handler for the fullscreenchange event is added to the element whose ID is fullscreen-
div. If the user clicks on the "Toggle Fullscreen Mode" button, the click handler will toggle full-screen mode for the
div. If document.fullscreenElement has a value it will exit full-screen mode. If not, the
div will be placed into full-screen mode. Remember that by the time the fullscreenchange event is handled, the status of the element has already changed. So if the change is to full-screen mod...
...fullscreenElement is null, full-screen mode has been canceled. What that means to the example code is that, if an element is currently in full-screen mode, the fullscreenchange handler logs the id of the full-screen element to the console. If document.fullscreenElement is null, the code logs a message that the change is to leave full-screen mode. HTML <h1>fullscreenchange event example</h1> <
div id="fullscreen-
div"> <button id="toggle-fullscreen">Toggle Fullscreen Mode</button> </
div> JavaScript document.getElementById('fullscreen-
div').addEventListener('fullscreenchange', (event) => { // document.fullscreenElement will point to the element that // is in fullscreen mode if there is one. If not, the value // of the property is null. if (document.fullscreenElement) { cons...
...ement: ${document.fullscreenElement.id} entered fullscreen mode.`); } else { console.log('Leaving full-screen mode.'); } }); document.getElementById('toggle-fullscreen').addEventListener('click', (event) => { if (document.fullscreenElement) { // exitFullscreen is only available on the Document object. document.exitFullscreen(); } else { document.getElementById('fullscreen-
div').requestFullscreen(); } }); Specifications Specification Status Fullscreen API Living Standard ...
ElementCSSInlineStyle.style - Web APIs
ot be set by assigning a string directly to the style property (as in elt.style = "color: blue;"), since it is considered read-only, as the style attribute returns a CSSStyleDeclaration object which is also read-only. Instead, styles can be set by assigning values to the properties of style. For adding specific styles to an element without altering other style values, it is preferred to use the in
dividual properties of style (as in elt.style.color = '...') as using elt.style.cssText = '...' or elt.setAttribute('style', '...') sets the complete inline style for the element by overriding the existing inline styles. Note that the property names are in camel-case and not kebab-case while setting the style using elt.style.<property> (i.e., elt.style.fontSize, not elt.style.font-size). A style dec...
...e rules in the <head> section, or external style sheets. To get the values of all CSS properties for an element you should use Window.getComputedStyle() instead. ...
...l style sheets. To get the values of all CSS properties for an element you should use Window.getComputedStyle() instead. ...
EventTarget.addEventListener() - Web APIs
tions are similar, they have different this bindings. While anonymous (and all traditional JavaScript functions) create their own this bindings, arrow functions inherit the this binding of the containing function. That means that the variables and constants available to the containing function are also available to the event handler when using an arrow function. ...
...ings. While anonymous (and all traditional JavaScript functions) create their own this bindings, arrow functions inherit the this binding of the containing function. That means that the variables and constants available to the containing function are also available to the event handler when using an arrow function. ...
...uter"> outer, once & none-once <
div class="middle" target="_blank"> middle, capture & none-capture <a class="inner1" href="https://www.mozilla.org" target="_blank"> inner1, passive & preventDefault(which is not allowed) </a> <a class="inner2" href="https://developer.mozilla.org/" target="_blank"> inner2, none-passive & preventDefault(not open new page) </a> </
div> </
div> CSS .outer, .middle, .inner1, .inner2 { display: block; width: 520px; padding: 15px; margin: 15px; text-decoration: none; } .outer { border: 1px solid red; color: red; } .middle { border: 1px solid green; color: green; width: 460px; } .inner1, .inner2 { border: 1px solid purple; color: purple; width: 400px; } JavaScript const outer = document.query...
FileReader: abort event - Web APIs
The abort event is fired when a read has been aborted: for instance because the program called FileReader.abort(). ...
... The abort event is fired when a read has been aborted: for instance because the program called FileReader.abort(). ...
...bles No Cancelable No Interface ProgressEvent Event handler property FileReader.onabort Examples Live example HTML <
div class="example"> <
div class="file-select"> <label for="avatar">Choose a profile picture:</label> <input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg"> </
div> <img src="" class="preview" height="200" alt="Image preview..."> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS img.preview { margin: 1rem 0; } .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { disp...
FileReader: load event - Web APIs
The load event is fired when a file has been read successfully. ...
... The load event is fired when a file has been read successfully. ...
...bbles No Cancelable No Interface ProgressEvent Event handler property FileReader.onload Examples Live example HTML <
div class="example"> <
div class="file-select"> <label for="avatar">Choose a profile picture:</label> <input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg"> </
div> <img src="" class="preview" height="200" alt="Image preview..."> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS img.preview { margin: 1rem 0; } .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { disp...
FileReader: loadend event - Web APIs
The loadend event is fired when a file read has completed, successfully or not. ...
... The loadend event is fired when a file read has completed, successfully or not. ...
...es No Cancelable No Interface ProgressEvent Event handler property FileReader.onloadend Examples Live example HTML <
div class="example"> <
div class="file-select"> <label for="avatar">Choose a profile picture:</label> <input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg"> </
div> <img src="" class="preview" height="200" alt="Image preview..."> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS img.preview { margin: 1rem 0; } .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { disp...
FileReader: loadstart event - Web APIs
The loadstart event is fired when a file read operation has begun. ...
... The loadstart event is fired when a file read operation has begun. ...
... No Cancelable No Interface ProgressEvent Event handler property FileReader.onloadstart Examples Live example HTML <
div class="example"> <
div class="file-select"> <label for="avatar">Choose a profile picture:</label> <input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg"> </
div> <img src="" class="preview" height="200" alt="Image preview..."> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS img.preview { margin: 1rem 0; } .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { disp...
FileReader: progress event - Web APIs
The progress event is fired periodically as the FileReader reads data. ...
... The progress event is fired periodically as the FileReader reads data. ...
...s No Cancelable No Interface ProgressEvent Event handler property FileReader.onprogress Examples Live example HTML <
div class="example"> <
div class="file-select"> <label for="avatar">Choose a profile picture:</label> <input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg"> </
div> <img src="" class="preview" height="200" alt="Image preview..."> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS img.preview { margin: 1rem 0; } .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { disp...
Using the Gamepad API - Web APIs
nd cancelAnimationFrame() cross browser forks. var gamepadInfo = document.getElementById("gamepad-info"); var ball = document.getElementById("ball"); var start; var a = 0; var b = 0; Next we use the gamepadconnected event to check for a gamepad being connected. When one is connected, we grab the gamepad using Navigator.getGamepads()[0], print information about the gamepad into our gamepad info
div, and fire the gameLoop() function that starts the whole ball movement process up. window.addEventListener("gamepadconnected", function(e) { var gp = navigator.getGamepads()[e.gamepad.index]; gamepadInfo.innerHTML = "Gamepad connected at index " + gp.index + ": " + gp.id + ". It has " + gp.buttons.length + " buttons and " + gp.axes.length + " axes."; gameLoop(); }); Now we use the gamepad...
...ddisconnected events in order to display the state of all gamepads connected to the system. You can find a working demo and look at the full source code on Github. ...
...lers = {}; function connecthandler(e) { addgamepad(e.gamepad); } function addgamepad(gamepad) { controllers[gamepad.index] = gamepad; var d = document.createElement("
div"); d.setAttribute("id", "controller" + gamepad.index); var t = document.createElement("h1"); t.appendChild(document.createTextNode("gamepad: " + gamepad.id)); d.appendChild(t); var b = document.createElement("
div"); b.className = "buttons"; for (var i = 0; i < gamepad.buttons.length; i++) { var e = document.createElement("span"); e.className = "button"; //e.id = "b" + i; e.innerHTML = i; b.appendChild(e); } d.appendChild(b); var a = document.createElement("
div"); a.className = "axes"; for (var i = 0; i < gamepad.axes.length; i++) { var p = document.createElement("p...
HTMLDialogElement: cancel event - Web APIs
en the user presses the Esc key or clicks a "Close dialog" button which is part of the browser's UI. ...
...he Esc key or clicks a "Close dialog" button which is part of the browser's UI. ...
... a "Close dialog" button which is part of the browser's UI. ...
HTMLDialogElement: close event - Web APIs
event is fired on an HTMLDialogElement object when the dialog it represents has been closed. ...
... HTMLDialogElement object when the dialog it represents has been closed. ...
...bject when the dialog it represents has been closed. ...
HTMLMediaElement: loadstart event - Web APIs
The loadstart event is fired when the browser has started to load a resource. ...
... The loadstart event is fired when the browser has started to load a resource. ...
... Bubbles No Cancelable No Interface Event Event handler property onloadstart Examples Live example HTML <
div class="example"> <button type="button">Load video</button> <video controls width="250"></video> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { display: grid; grid-template-areas: "button log" "video log"; } button { grid-area: button; width: 10rem; margin: .5rem 0; } video { grid-area: video; } .event-log { grid-area: log; } .event-log>label { d...
HTMLMediaElement: progress event - Web APIs
The progress event is fired periodically as the browser loads a resource. ...
... The progress event is fired periodically as the browser loads a resource. ...
... Bubbles No Cancelable No Interface Event Event handler property onprogress Examples Live example HTML <
div class="example"> <button type="button">Load video</button> <video controls width="250"></video> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents"></textarea> </
div> </
div> CSS .event-log-contents { width: 18rem; height: 5rem; border: 1px solid black; margin: .2rem; padding: .2rem; } .example { display: grid; grid-template-areas: "button log" "video log"; } button { grid-area: button; width: 10rem; margin: .5rem 0; } video { grid-area: video; } .event-log { grid-area: log; } .event-log>label { d...
HTMLOrForeignElement.dataset - Web APIs
ly property of the HTMLOrForeignElement interface provides read/write access to all the custom data attributes (data-*) set on the element. This access is available both in HTML and within the DOM. It is a map of DOMStrings (DOMStringMap) with one entry for each custom data attribute. Note that the dataset property itself can be read, but not directly written. Instead, all writes must be to the in
dividual properties within the dataset, which in turn represent the data attributes. Note also that an HTML data-attribute and its corresponding DOM dataset.property do not share the same name, but they are always similar: In HTML, the name of a custom data attribute begins with data-. It must contain only letters, numbers, and the following characters: dash (-), dot (.), colon (:), underscore (_)...
...taset[keyname] The in operator can be used to check whether a given attribute exists. Setting values When an attribute is set, its value is always converted into a string. For example: null is converted into the string "null". To remove an attribute, you can use the delete operator. Syntax const dataAttrMap = element.dataset Value A DOMStringMap. ...
...s. Setting values When an attribute is set, its value is always converted into a string. For example: null is converted into the string "null". To remove an attribute, you can use the delete operator. Syntax const dataAttrMap = element.dataset Value A DOMStringMap. ...
The HTML DOM API - Web APIs
e about the actual structure of the DOM, see Introduction to the DOM. HTML DOM target audience The features exposed by the HTML DOM are among the most commonly-used APIs in the web developer's arsenal. All but the most simple web applications will use some features of the HTML DOM. HTML DOM API interfaces The majority of the interfaces that comprise the HTML DOM API map almost one-to-one to in
dividual HTML elements, or to a small group of elements with similar functionality. In addition, the HTML DOM API includes a few interfaces and types to support the HTML element interfaces. HTML element interfaces These interfaces represent specific HTML elements (or sets of related elements which have the same properties and methods associated with them). HTMLAnchorElement HTMLAreaElement HT...
...faces represent specific HTML elements (or sets of related elements which have the same properties and methods associated with them). ...
...t2D Path2D TextMetrics Media interfaces The media interfaces provide HTML access to the contents of the media elements: <audio> and <video>. AudioTrack AudioTrackList MediaError TextTrack TextTrackCue TextTrackCueList TextTrackList TimeRanges TrackEvent VideoTrack VideoTrackList Drag and drop interfaces These interfaces are used by the HTML_Drag_and_Drop_API to represent in
dividual draggable (or dragged) items, groups of dragged or draggable items, and to handle the drag and drop process. DataTransfer DataTransferItem DataTransferItemList DragEvent Page history interfaces The History API interfaces let you access information about the browser's history, as well as to shift the browser's current tab forward and backward through that history. BeforeUnloadE...
InputEvent.inputType - Web APIs
tax var aString = inputEvent.inputType; Value A DOMString containing the type of input that was made. There are many possible values, such as insertText, deleteContentBackward, insertFromPaste, and formatBold. For a complete list of the available input types, see the Attributes section of the Input Events Level 1 spec. ...
...alue A DOMString containing the type of input that was made. There are many possible values, such as insertText, deleteContentBackward, insertFromPaste, and formatBold. For a complete list of the available input types, see the Attributes section of the Input Events Level 1 spec. Examples This example logs the inputType for input events on an editable <
div>. ...
...for input events on an editable <
div>. HTML <p id="log">Input type: </p> <
div contenteditable="true" style="margin: 20px;padding: 20px;border:2px dashed red;"> <p>Some sample text. Try inserting line breaks, or deleting text in different ways, or pasting different content in.</p> <hr> <ul> <li>A sample</li> <li>bulleted</li> <li>list.</li> </ul> <p>Another paragraph.</p> </
div> JavaScript const log = document.getElementById('log'); const editable = document.querySelector('
div[contenteditable]'); editable.addEventListener('input', logInputType); function logInputType(event) { log.textContent = `Input type: ${event.inputType}`; } Result Try editing the text inside the <
div> and see what happens. Note: See also Masayuki Nakano's InputEvent test suite for a mor...
MediaKeyMessageEvent - Web APIs
The MediaKeyMessageEvent interface of the EncryptedMediaExtensions API contains the content and related data when the content decryption module generates a message for the session. ...
... Properties Inherits properties from its parent, Event. MediaKeyMessageEvent.message Read only Returns an ArrayBuffer with a message from the content decryption module. Messages vary by key system. MediaKeyMessageEvent.messageType Read only ...
...Creates a new instance of MediaKeyMessageEvent. Properties Inherits properties from its parent, Event. MediaKeyMessageEvent.message Read only Returns an ArrayBuffer with a message from the content decryption module. Messages vary by key system. MediaKeyMessageEvent.messageType Read only Indicates the type of message. May be one of license-request, license-renewal, license-release, or in
dividualization-request. Methods Inherits methods from its parent, Event. Examples // TBD Specifications Specification Status Comment Encrypted Media ExtensionsThe definition of 'MediaKeyMessageEvent' in that specification. Recommendation Initial definition. ...
MediaTrackSupportedConstraints.autoGainControl - Web APIs
t isn't supported, it's not included in the list, so this value will never be false. You can access the supported constraints dictionary by calling navigator.mediaDevices.getSupportedConstraints(). The autoGainControl constraint indicates whether or not the browser offers the ability to automatically control the gain (volume) on media tracks; this obviously is contingent on whether or not the in
dividual device supports automatic gain control as well; it's typically a feature provided by microphones. Syntax autoGainSupported = supportedConstraintsDictionary.autoGainControl; Value This property is present in the dictionary (and its value is always true) if the user agent supports the autoGainControl constraint. If the property isn't present, this property is missing from the supported con...
...s present in the dictionary (and its value is always true) if the user agent supports the autoGainControl constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. Example This example simply displays whether or not your browser supports the autoGainControl constraint. ...
...ctionary (and its value is always true) if the user agent supports the autoGainControl constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. Example This example simply displays whether or not your browser supports the autoGainControl constraint. ...
MediaTrackSupportedConstraints.noiseSuppression - Web APIs
isn't supported, it's not included in the list, so this value will never be false. You can access the supported constraints dictionary by calling navigator.mediaDevices.getSupportedConstraints(). The noiseSuppression constraint indicates whether or not the browser offers the ability to automatically control the gain (volume) on media tracks; this obviously is contingent on whether or not the in
dividual device supports automatic gain control as well. Syntax noiseSuppressionSupported = supportedConstraintsDictionary.noiseSuppression; Value This property is present in the dictionary (and its value is always true) if the user agent supports the noiseSuppression constraint (and therefore supports noise suppression on audio tracks). If the property isn't present, this property is missing fro...
... the user agent supports the noiseSuppression constraint (and therefore supports noise suppression on audio tracks). If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. Example This example simply displays whether or not your browser supports the noiseSuppression constraint. ...
...ports the noiseSuppression constraint (and therefore supports noise suppression on audio tracks). If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. Example This example simply displays whether or not your browser supports the noiseSuppression constraint. ...
Node.nextSibling - Web APIs
example, using Node.firstChild or Node.previousSibling may refer to a whitespace text node rather than the actual element the author intended to get. See Whitespace in the DOM and W3C DOM 3 FAQ: Why are some Text nodes empty? for more information. Element.nextElementSibling may be used to obtain the next element skipping any whitespace nodes, other between-element text, or comments. Example <
div id="
div-1">Here is
div-1</
div> <
div id="
div-2">Here is
div-2</
div> <script> var el = document.getElementById('
div-1').nextSibling, i = 1; console.group('Siblings of
div-1:'); while (el) { console.log(i, '. ', el.nodeName); el = el.nextSibling; i++; } console.groupEnd(); </script> /************************************************** The console displays the following: Sibling...
...#text 2.
DIV 3. #text 4. SCRIPT **************************************************/ In the above example, #text nodes are inserted in the DOM where whitespace occurs between tags (i.e. after the closing tag of an element and before the opening tag of the next). The possible inclusion of text nodes must be allowed for when traversing the DOM using nextSibling. ...
... id="
div-2">Here is
div-2</
div> <script> var el = document.getElementById('
div-1').nextSibling, i = 1; console.group('Siblings of
div-1:'); while (el) { console.log(i, '. ', el.nodeName); el = el.nextSibling; i++; } console.groupEnd(); </script> /************************************************** The console displays the following: Siblings of
div-1 1. #text 2.
DIV 3. #text 4. SCRIPT **************************************************/ In the above example, #text nodes are inserted in the DOM where whitespace occurs between tags (i.e. after the closing tag of an element and before the opening tag of the next). The possible inclusion of text nodes must be allowed for when traversing the DOM using nextSibling. See the resources in the Notes sec...
ParentNode.append() - Web APIs
trings, whereas Node.appendChild() can only append one node. Syntax // [Throws, Unscopable] ParentNode.append(...nodesOrDOMStrings) // returns undefined Parameters nodes A set of Node or DOMString objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...rs nodes A set of Node or DOMString objects to insert. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. Examples Appending an element let parent = document.createElement("
div") let p = document.createElement("p") parent.append(p) console.log(parent.childNodes) // NodeList [ <p> ] Appending text let parent = document.createElement("
div") parent.append("Some text") console.log(parent.textContent) // "Some text" Appending an element and text let parent = document.createElement("
div") let p = document.createElement("p") parent.append("Some text", p) console.log(parent.childNodes) // NodeList [ #text "Some text", <p> ] ParentNode.append() is unscopable The append() method is not scoped into the with statement. See Symbol.unsc...
...ome text" Appending an element and text let parent = document.createElement("
div") let p = document.createElement("p") parent.append("Some text", p) console.log(parent.childNodes) // NodeList [ #text "Some text", <p> ] ParentNode.append() is unscopable The append() method is not scoped into the with statement. See Symbol.unscopables for more information. ...
ParentNode.prepend() - Web APIs
pend One or more nodes to insert before the first child node currently in the ParentNode. Each node can be specified as either a Node object or as a string; strings are inserted as new Text nodes. Return value undefined. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...archyRequestError: Node cannot be inserted at the specified point in the hierarchy. ...
...("p"); var span = document.createElement("span"); parent.append(p); parent.prepend(span); console.log(parent.childNodes); // NodeList [ <span>, <p> ] Prepending text var parent = document.createElement("
div"); parent.append("Some text"); parent.prepend("Headline: "); console.log(parent.textContent); // "Headline: Some text" Appending an element and text var parent = document.createElement("
div"); var p = document.createElement("p"); parent.prepend("Some text", p); console.log(parent.childNodes); // NodeList [ #text "Some text", <p> ] ParentNode.prepend() is unscopable The prepend() method is not scoped into the with statement. See Symbol.unscopables for more information. var parent = document.createElement("
div"); with(parent) { prepend("foo"); } // ReferenceError: prepend is no...
ParentNode.replaceChildren() - Web APIs
any argument specified: myNode.replaceChildren(); Transferring nodes between parents replaceChildren() enables you to easily transfer nodes between parents, without having to resort to verbose looping code. For example, say we have a simple application allowing you to choose what food you want for your party. ...
...tion>Chocolate bars</option> <option>Ham Sandwiches</option> <option>Cheese Sandwiches</option> <option>Falafel sandwiches</option> <option>Ice cream</option> <option>Jelly</option> <option>Carrot sticks and houmous</option> <option>Margherita pizza</option> <option>Pepperoni pizza</option> <option>Vegan veggie pizza</option> </select> </
div> <
div class="buttons"> <button id="to-yes">Transfer to "Yes" --></button> <button id="to-no"><-- Transfer to "No"</button> </
div> <
div> <label for="yes">Yes please!</label> <select id="yes" multiple size="10"> </select> </
div> </main> It would make sense to use some simple CSS to lay out the two select lists in a line alongside one another, with the control ...
...ansfer to "Yes" --></button> <button id="to-no"><-- Transfer to "No"</button> </
div> <
div> <label for="yes">Yes please!</label> <select id="yes" multiple size="10"> </select> </
div> </main> It would make sense to use some simple CSS to lay out the two select lists in a line alongside one another, with the control buttons in between them: main { display: flex; }
div { margin-right: 20px; } label, button { display: block; } .buttons { display: flex; flex-flow: column; justify-content: center; } select { width: 200px; } What we want to do is transfer any selected options in the "no" list over to the "yes" list when the "yes" button is pressed, and transfer any selected options in the "yes" list over to the "no" list when the "no" button is pres...
Pinch zoom gestures - Web APIs
detect two pointing devices of any type, including fingers, mice, and pens. The pinch in (zoom out) gesture, which moves the two pointers toward each other, changes the target element's background color to lightblue. The pinch out (zoom in) gesture, which moves the two pointers away from each other, changes the target element's background color to pink. Define touch target The application uses <
div> to define the pointers' target areas. <style>
div { margin: 0em; padding: 2em; } #target { background: white; border: 1px solid black; } </style> Global state Supporting a two-pointer gesture requires preserving a pointer's event state during various event phases. This application uses two global variables to cache the event state. // Global vars to cache event state...
...ndler(ev) { log(ev.type, ev); // Remove this pointer from the cache and reset the target's // background and border remove_event(ev); ev.target.style.background = "white"; ev.target.style.border = "1px solid black"; // If the number of pointers down is less than two then reset diff tracker if (evCache.length < 2) { prevDiff = -1; } } Application UI The application uses a <
div> element for the touch area and provides buttons to enable logging and to clear the log. To prevent the browser's default touch behavior from overriding this application's pointer handling, the touch-action property is applied to the <body> element. <body onload="init();" style="touch-action:none"> <
div id="target">Touch and Hold with 2 pointers, then pinch in or out.<br/> The background c...
...touch behavior from overriding this application's pointer handling, the touch-action property is applied to the <body> element. <body onload="init();" style="touch-action:none"> <
div id="target">Touch and Hold with 2 pointers, then pinch in or out.<br/> The background color will change to pink if the pinch is opening (Zoom In) or changes to lightblue if the pinch is closing (Zoom out).</
div> <!-- UI for logging/debugging --> <button id="log" onclick="enableLog(event);">Start/Stop event logging</button> <button id="clearlog" onclick="clearLog(event);">Clear the log</button> <p></p> <output></output> </body> Miscellaneous functions These functions support the application but aren't directly involved in the event flow. Cache management This function helps manage the global ev...
RTCPeerConnection.onicegatheringstatechange - Web APIs
athering by looking at the value of the RTCPeerConnection.iceGatheringState property. Example This example updates status information presented to the user to let them know what's happening by examining the current value of the iceGatheringState property each time it changes and changing the contents of a status display based on the new information. ...
...ing at the value of the RTCPeerConnection.iceGatheringState property. Example This example updates status information presented to the user to let them know what's happening by examining the current value of the iceGatheringState property each time it changes and changing the contents of a status display based on the new information. ...
...he RTCPeerConnection.iceGatheringState property. Example This example updates status information presented to the user to let them know what's happening by examining the current value of the iceGatheringState property each time it changes and changing the contents of a status display based on the new information. ...
SVGFEConvolveMatrixElement - Web APIs
The SVGFEConvolveMatrixElement interface corresponds to the <feConvolveMatrix> element. ...
...It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. SVG_EDGEMODE_DUPLICATE 1 Corresponds to the duplicate value. SVG_EDG...
...orderX Read only An SVGAnimatedInteger corresponding to the order attribute of the given element. SVGFEConvolveMatrixElement.orderY Read only An SVGAnimatedInteger corresponding to the order attribute of the given element. SVGFEConvolveMatrixElement.kernelMatrix Read only An SVGAnimatedNumberList corresponding to the kernelMatrix attribute of the given element. SVGFEConvolveMatrixElement.
divisor Read only An SVGAnimatedNumber corresponding to the
divisor attribute of the given element. SVGFEConvolveMatrixElement.bias Read only An SVGAnimatedNumber corresponding to the bias attribute of the given element. SVGFEConvolveMatrixElement.targetX Read only An SVGAnimatedInteger corresponding to the targetX attribute of the given element. SVGFEConvolveMatrixElement.targetY Read only ...
SVGTextPositioningElement - Web APIs
The SVGTextPositioningElement interface is implemented by elements that support attributes that position in
dividual text glyphs. It is inherited by SVGTextElement, SVGTSpanElement, SVGTRefElement and SVGAltGlyphElement. ...
... The SVGTextPositioningElement interface is implemented by elements that support attributes that position in
dividual text glyphs. It is inherited by SVGTextElement, SVGTSpanElement, SVGTRefElement and SVGAltGlyphElement. ...
... SVGTextPositioningElement.x Read only Returns an SVGAnimatedLengthList reflecting the x attribute of the given element. SVGTextPositioningElement.y Read only Returns an SVGAnimatedLengthList reflecting the y attribute of the given eleme...
SourceBufferList - Web APIs
The SourceBufferList interface represents a simple container list for multiple SourceBuffer objects. The source buffer list containing the SourceBuffers appended to a particular MediaSource can be retrieved using the MediaSource.sourceBuffers property. The in
dividual source buffers can be accessed using array operator (i.e. []) or functions such as forEach() for example. ...
... The SourceBufferList interface represents a simple container list for multiple SourceBuffer objects. The source buffer list containing the SourceBuffers appended to a particular MediaSource can be retrieved using the MediaSource.sourceBuffers property. The in
dividual source buffers can be accessed using array operator (i.e. []) or functions such as forEach() for example. ...
... Event handlers SourceBufferList.onaddsourcebuffer The event handler for the addsourcebuffer event. SourceBufferList.onremovesourcebuffer The event handler for the removesourcebuffer event. Methods Inherits methods from ...
Storage API - Web APIs
The Storage API gives sites' code the ability to find out how much space they can use, how much they are already using, and even control whether or not they need to be alerted before the user agent disposes of site data in order to make room for other things. Note: This feature is available in Web Workers. ...
...ents. Origin 3's storage unit is completely full; it's reached its quota and can't store any more data without some existing material being removed. User agents are likely to use various techniques to determine the quota for various origins. One of the most likely methods--one which the specification specifically encourages, in fact--would be to consider the popularity and/or usage levels of in
dividual sites to determine what their quotas should be. It's also conceivable that the browser might offer a user interface to customize these quotas. Box modes The actual data storage within each site storage unit is called its box. Each site storage unit has exactly one box into which all of its data is placed, and has a box mode that describes the data retention policy for that box. There are ...
...origin's site storage unit's box mode is always "best-effort". Note: See Using the Permissions API for further details about obtaining and managing permissions. When clearing site storage units, an origin's box is treated as a single entity; if the user agent needs to clear it and the user approves, the entire data store is cleared rather than providing some means of clearing only data from in
dividual APIs. If a box is marked as "persistent", the contents won't be cleared by the user agent without either the data's origin itself or the user specifically doing so. This includes scenarios such as the user selecting a "Clear Caches" or "Clear Recent History" option. The user will be asked specifically for permission to remove persistent site storage units. Quotas and usage estimates The u...
TouchEvent - Web APIs
een or trackpad, for example. The event can describe one or more points of contact with the screen and includes support for detecting movement, addition and removal of contact points, and so forth. Touches are represented by the Touch object; each touch is described by a position, size and shape, amount of pressure, and target element. Lists of touches are represented by TouchList objects. ...
... Properties This interface inherits properties from its parent, UIEvent and Event. TouchEvent.altKey Read only A Boolean value indicating whether or not the alt key was down when the touch event was fired. TouchEvent.changedTouches Read only A TouchList of all the Tou...
... #0095DD; pointer-events: all;} Constructor TouchEvent() Creates a TouchEvent object. Properties This interface inherits properties from its parent, UIEvent and Event. TouchEvent.altKey Read only A Boolean value indicating whether or not the alt key was down when the touch event was fired. TouchEvent.changedTouches Read only A TouchList of all the Touch objects representing in
dividual points of contact whose states changed between the previous touch event and this one. TouchEvent.ctrlKey Read only A Boolean value indicating whether or not the control key was down when the touch event was fired. TouchEvent.metaKey Read only A Boolean value indicating whether or not the meta key was down when the touch event was fired. TouchEvent.shiftKey Read only A Boolean value ...
WebGL constants - Web APIs
FLOAT_MAT4x3 0x8B6A UNSIGNED_INT_VEC2 0x8DC6 UNSIGNED_INT_VEC3 0x8DC7 UNSIGNED_INT_VEC4 0x8DC8 UNSIGNED_NORMALIZED 0x8C17 SIGNED_NORMALIZED 0x8F9C Vertex attributes Constant name Value Description VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD VERTEX_ATTRIB_ARRAY_
DIVISOR 0x88FE Transform feedback Constant name Value Description TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 TRANSFORM_FEEDBACK_VARYINGS 0x8C83 TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 TRANSFOR...
... WEBGL_debug_renderer_info Constant name Value Description UNMASKED_VENDOR_WEBGL 0x9245 Passed to getParameter to get the vendor string of the graphics driver. UNMASKED_RENDERER_WEBGL 0x9246 Passed to getParameter to get the renderer string of the graphics d...
... WEBGL_debug_renderer_info Constant name Value Description UNMASKED_VENDOR_WEBGL 0x9245 Passed to getParameter to get the vendor string of the graphics driver. UNMASKED_RENDERER_WEBGL 0x9246 Passed to getParameter to get the renderer string of the graphics driver. EXT_texture_filter_anisotropic ...
A simple RTCDataChannel sample - Web APIs
uttons for establishing and closing the connection: <button id="connectButton" name="connectButton" class="buttonleft"> Connect </button> <button id="disconnectButton" name="disconnectButton" class="buttonright" disabled> Disconnect </button> Then there's a box which contains the text input box into which the user can type a message to transmit, with a button to send the entered text. ...
...on: <button id="connectButton" name="connectButton" class="buttonleft"> Connect </button> <button id="disconnectButton" name="disconnectButton" class="buttonright" disabled> Disconnect </button> Then there's a box which contains the text input box into which the user can type a message to transmit, with a button to send the entered text. This <
div> will be the first peer in the channel. ...
...the entered text. This <
div> will be the first peer in the channel. <
div class="messagebox"> <label for="message">Enter a message: <input type="text" name="message" id="message" placeholder="Message text" inputmode="latin" size=60 maxlength=120 disabled> </label> <button id="sendButton" name="sendButton" class="buttonright" disabled> Send </button> </
div> Finally, there's the little box into which we'll insert the messages. This <
div> block will be the second peer. <
div class="messagebox" id="receivebox"> <p>Messages received:</p> </
div> The JavaScript code While you can just look at the code itself on GitHub, below we'll review the parts of the code that do the heavy lifting. The WebRTC API makes heavy use of Promises. They make it very e...
Taking still photos with WebRTC - Web APIs
bRTC to access the camera on a computer or mobile phone with WebRTC support and take a photo with it. Try this sample then read on to learn how it works. You can also jump straight to the code on Github if you like. The HTML markup Our HTML interface has two main operational sections: the stream and capture panel and the presentation panel. ...
.... The HTML markup Our HTML interface has two main operational sections: the stream and capture panel and the presentation panel. Each of these is presented side-by-side in its own <
div> to facilitate styling and control. The first panel on the left contains two components: a <video> element, which will receive the stream from WebRTC, and a <button> the user clicks to capture a video frame. <
div class="camera"> <video id="video">Video stream not available.</video> <button id="startbutton">Take photo</button> </
div> This is straightforward, and we'll see how it ties together when we get into the JavaScript code. Next, we have a <canvas> element into which the captured frames are stored, potentially manipulated in some way, and then converted into an output image file. This can...
...red, potentially manipulated in some way, and then converted into an output image file. This canvas is kept hidden by styling the canvas with display:none, to avoid cluttering up the screen -- the user does not need to see this intermediate stage. We also have an <img> element into which we will draw the image -- this is the final display shown to the user. <canvas id="canvas"> </canvas> <
div class="output"> <img id="photo" alt="The screen capture will appear in this box."> </
div> That's all of the relevant HTML. The rest is just some page layout fluff and a bit of text offering a link back to this page. The JavaScript code Now let's take a look at the JavaScript code. We'll break it up into a few bite-sized pieces to make it easier to explain. Initialization We start by wr...
Rendering and the WebXR frame animation callback - Web APIs
he most of the time available between frames critical. If the user's device is using a 60 Hz display, your callback will be called up to 60 times per second, and your goal is to do what you can to ensure that it doesn't get called less often than that. You achieve this by doing as much as is practicable off the main thread and by keeping your frame rendering callback as efficient as possible. The
division of time into 60 Hz blocks with each block being used at least in part to render the scene is shown in the diagram below. This is important because as the computer becomes increasingly busy, it may not be able to accurately call your callback every frame and may have to skip frames. This is called dropping frames. This happens when the amount of time it takes to render a frame exceeds the ...
... through the frame loop. For that reason, the occasional dropped frame isn't usually particularly noticeable, but if it starts to happen a lot--especially if several frames are dropped in a very short span of time--it can become jarring or even leave your display unusable. Fortunately, you can easily compute how much time you're allowed to use between frames as 1/refreshRate seconds. That is, by
dividing 1 by the display's refresh rate. The resulting value is the amount of time available for each frame to be rendered in order to not drop the frame. For example, a 60 Hz display has 1/60th of a second to render a single frame, or 0.0166667 seconds. And if the device's refresh rate is 120 Hz, you only have 0.00883333 seconds to render each frame if you want to avoid dropping frames. Even if th...
...depth buffers are both erased by calling gl.clear(), passing in a bit mask in which both COLOR_BUFFER_BIT and DEPTH_BUFFER_BIT are set. Since WebXR uses a single framebuffer for every view, with viewports upon the view being used to separate each eye's viewpoint within the framebuffer, we only need to clear a single framebuffer rather than cleaning it for each eye (or other viewpoints, if any) in
dividually. Next, the time elapsed since the previous frame was rendered is calculated by subtracting from the current time as specified by the currentFrameTime parameter the saved time at which the last frame was rendered, lastFrameTime. The result is a DOMHighResTimeStamp value indicating the number of milliseconds that have elapsed since the last frame was rendered. We can use this value while dr...
Using the Web Animations API - Web APIs
r: '#000' }, { color: '#431236', offset: 0.3}, { transform: 'rotate(360deg) translate3D(-50%, -50%, 0)', color: '#000' } ]; Here we're using an array containing multiple objects. Each object represents a key from the original CSS. However, unlike CSS, the Web Animations API doesn't need to explicitly be told the percentages along the animation for each key to appear at. It will automatically
divide the animation into equal parts based on the number of keys you give it. This means that a Keyframe object with three keys will play the middle key 50% of the way through each loop of the animation unless told otherwise. When we want to explicitly set a key's offset from the other keys, we can specify an offset directly in the object, separated from the declaration with a comma. In the above e...
...urns an object containing all the details of the effect(s) active on Alice: aliceChange.currentTime = aliceChange.effect.getComputedTiming().duration / 2; effect lets us access the animation's keyframes and timing properties -- aliceChange.effect.getComputedTiming() points to Alice's timing object (which is of type ComputedEffectTiming) -- this contains her ComputedEffectTiming.duration. We can
divide her duration in half to get the midpoint for her animation's timeline, setting her to be normal height. Now we can reverse and play her animation in either direction to make her grow smaller or larger! And we can do the same thing when setting the cake and bottle durations: var drinking = document.getElementById('liquid').animate( [ { height: '100%' }, { height: '0' } ], { fill: 'forwa...
...game ends when you run out of cake to eat or empty the bottle. Which vignette players are presented with depends on how far along Alice was in her animation, whether she grew too big and can't get in the tiny door anymore or too small and cannot reach the key to open the door. ...
XPathResult.booleanValue - Web APIs
ote: This feature is available in Web Workers. Syntax var value = result.booleanValue; Return value The return value is the boolean value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not BOOLEAN_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the booleanValue property. ...
...s available in Web Workers. Syntax var value = result.booleanValue; Return value The return value is the boolean value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not BOOLEAN_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the booleanValue property. ...
... The return value is the boolean value of the XPathResult returned by Document.evaluate(). Exceptions TYPE_ERR In case XPathResult.resultType is not BOOLEAN_TYPE, an XPathException of type TYPE_ERR is thrown. Example The following example shows the use of the booleanValue property. HTML <
div>XPath example</
div> <p>Text is 'XPath example': <output></output></p> JavaScript var xpath = "//
div/text() = 'XPath example'"; var result = document.evaluate(xpath, document, null, XPathResult.BOOLEAN_TYPE, null); document.querySelector("output").textContent = result.booleanValue; Result Specifications Specification Status Comment Document Object Model (DOM) Level 3 XPath SpecificationThe definition of 'XPathResult.booleanValue' in that specification. Recommenda...
ARIA: button role - Accessibility
The button role should be used for clickable elements that trigger a response when activated by the user. Adding role="button" will make an element appear as a button control to a screen reader. This role can be used in combination with the aria-pressed attribute to create toggle buttons. ...
... The button role should be used for clickable elements that trigger a response when activated by the user. Adding role="button" will make an element appear as a button control to a screen reader. This role can be used in combination with the aria-pressed attribute to create toggle buttons. ...
...ue"); // Change aria-pressed to the opposite state element.setAttribute("aria-pressed", !pressed); // toggle the play state of the audio file if(pressed) { audio.pause(); } else { audio.play(); } } Result Accessibility concerns Buttons are interactive controls and thus focusable. If the button role is added to an element that is not focusable by itself (such as <span>, <
div> or <p>) then, the tabindex attribute has to be used to make the button focusable. Warning: Be careful when marking up links with the button role. Buttons are expected to be triggered using the Space or Enter key, while links are expected to be triggered using the Enter key. In other words, when links are used to behave like buttons, adding role="button" alone is not sufficient. It will also be ...
Web applications and ARIA FAQ - Accessibility
ARIA provides additional semantics to describe the role, state, and functionality of many familiar user interface controls, such as menus, sliders, trees, and dialogs. ...
...ipt user interface toolkits, including: Dojo/Dijit jQuery UI Fluid Infusion Google Closure Google Web Toolkit BBC Glow Yahoo! User Interface Library (YUI) For more information about JavaScript toolkit accessibility: Steve Faulkner's WAI-ARIA Implementation in JavaScript UI Libraries Can you show me an example of ARIA in action? Sure. Here's the markup for a progress bar widget: <
div id="percent-loaded" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" /> This progress bar is built using a <
div>, which is not very descriptive. Unfortunately, there isn't a more semantic tag available to developers in HTML 4, so we need to include ARIA roles and properties. These are specified by adding attributes to the element. In this example, the role="progressbar...
...ent is actually a JavaScript-powered progress bar widget. The aria-valuemin and aria-valuemax attributes specify the minimum and maximum values for the progress bar, and the aria-valuenow describes the current state of it. Along with placing them directly in the markup, ARIA attributes can be added to the element and updated dynamically using JavaScript code like this: // Find the progress bar <
div> in the DOM. var progressBar = document.getElementById("percent-loaded"); // Set its ARIA roles and states, so that assistive technologies know what kind of widget it is. progressBar.setAttribute("role", "progressbar"); progressBar.setAttribute("aria-valuemin", 0); progressBar.setAttribute("aria-valuemax", 100); // Create a function that can be called at any time to update the value of the prog...
Alerts - Accessibility
default 'alert' function). ...
...on to add the alert with the provided error message. If the search term is found, the aria-invalid attribute is reset to "false". In addition, any leftover alerts are removed. The addAlert function This function first removes any old alerts. The function is simple: It looks for an element with id "alert", and if found, removes that from the document object model. Next, the function creates a
div element to hold the alert text. It gets an ID of "alert". And it gets a role set of "alert". This is actually ARIA-inspired, even though it doesn't say "aria" in the attribute name. This is because that role is based on the XHTML Role Attribute Module that was simply ported to HTML for simplicity. The text is added to the
div element, and the
div element is added to the document. The moment thi...
...Most screen readers will pick this one up automatically and speak it. ...
ARIA - Accessibility
were later incorporated into HTML5, and developers should prefer using the correct semantic HTML element over using ARIA, if such an element exists. For instance, native elements have built-in keyboard accessibility, roles and states. However, if you choose to use ARIA, you are responsible for mimicking (the equivalent) browser behaviour in script. Here's the markup for a progress bar widget: <
div id="percent-loaded" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"> </
div> This progress bar is built using a <
div>, which has no meaning. Unfortunately, there isn't a more semantic tag available to developers in HTML 4, so we need to include ARIA roles and properties. These are specified by adding attributes to the element. In this example, the role="progressb...
...idget. The aria-valuemin and aria-valuemax attributes specify the minimum and maximum values for the progress bar, and the aria-valuenow describes the current state of it and therefore must be kept updated with JavaScript. Along with placing them directly in the markup, ARIA attributes can be added to the element and updated dynamically using JavaScript code like this: // Find the progress bar <
div> in the DOM. var progressBar = document.getElementById("percent-loaded"); // Set its ARIA roles and states, // so that assistive technologies know what kind of widget it is. progressBar.setAttribute("role", "progressbar"); progressBar.setAttribute("aria-valuemin", 0); progressBar.setAttribute("aria-valuemax", 100); // Create a function that can be called at any time to update // the value of th...
... notes and examples on real sites (updated as of July 2011). Improving form accessibility ARIA is not just for dynamic content! Learn how to improve accessibility of HTML forms using additional ARIA attributes. ARIA for Scripted Widgets Writing keyboard-navigable JavaScript widgets Built-in elements like <input>, <button> etc have built-in keyboard accessibility. If you 'fake' these with <
div>s and ARIA, you must ensure your widgets are keyboard accessible. Live regions Live regions provide suggestions to screen readers about how to handle changes to the contents of a page. Using ARIA Live Regions to announce content changes A quick summary of live regions, by the makers of JAWS screen reader software. Live regions are also supported by NVDA with Firefox, and VoiceOver with Safari...
Accessibility documentation index - Accessibility
related bugs ARIA, Bugzilla The state of ARIA technology has always depended on the community. If you notice an implementation issue, please take a little time and let the developers know. Here's where to file bugs: 13 Using ARIA: Roles, states, and properties ARIA, Accessibility, Overview, Reference ARIA defines semantics that can be applied to elements, with these
divided into roles (defining a type of user interface element) and states and properties that are supported by a role. Authors must assign an ARIA role and the appropriate states and properties to an element during its life-cycle, unless the element already has appropriate ARIA semantics (via use of an appropriate HTML element). Addition of ARIA semantics only exposes extra information to a browser's...
...lement is a numerical counter the amount of elapsed time from a starting point or the remaining time until an end point. 78 Web applications and ARIA FAQ ARIA, Accessibility, Guide WAI-ARIA is the Accessible Rich Internet Applications specification from the Web Accessibility Initiative at the W3C. ARIA provides a means to make web applications and widgets more accessible to a
diverse range of users, including those who use assistive technologies such as screen readers or magnifiers. 79 widgets Accessibility This page was auto-generated because a user created a sub-page to this page. 80 overview Accessibility, JavaScript, Landing, NeedsUpdate Here's a look at working examples and best practices in building accessible JavaScript wid...
...e it accessible with 3rd party assistive technologies, as well as for hackers wishing to be involved in Mozilla's MSAA support specifically. 93 Keyboard-navigable JavaScript widgets Accessibility, DOM, NeedsUpdate Web applications often use JavaScript to mimic desktop widgets such as menus, tree views, rich text fields, and tab panels. These widgets are typically composed of <
div> and <span> elements that do not, by nature, offer the same keyboard functionality that their desktop counterparts do. This document describes techniques to make JavaScript widgets accessible with the keyboard. 94 Mobile accessibility checklist Accessibility, Firefox OS, Guidelines, Mobile, checklist This document provides a concise checklist of accessibility requirements for...
Accessibility
abbreviated to A11y--as in "a" then 11 characters then "y") in Web development means enabling as many people as possible to use Web sites, even when those people's abilities are limited in some way. For many people, technology makes things easier. For people with disabilities, technology makes things possible. ...
...s possible. Accessibility means developing content to be as accessible as possible no matter an in
dividual's physical and cognitive abilities and no matter how they access the web. "The Web is fundamentally designed to work for all people, whatever their hardware, software, language, culture, location, or physical or mental ability. ...
...he Web Content Accessibility Guidelines This set of articles provides quick explanations to help you understand the steps that need to be taken to conform to the recommendations outlined in the W3C Web Content Accessibility Guidelines 2.0 (WCAG 2.0 or just WCAG, for the purposes of this writing). Keyboard-navigable JavaScript widgets Until now, web developers who want to make their styled <
div> and <span> based widgets accessible have lacked the proper techniques. Keyboard accessibility is part of the minimum accessibility requirements which a developer should be aware of. ARIA A collection of articles to learn how to use ARIA to make your HTML documents more accessible. Assistive technology (AT) development A collection of articles intended for AT developers Mobile accessibility ...
-moz-image-rect - CSS: Cascading Style Sheets
the list-style-image property to use parts of an image as the bullets in lists. However, this can be used for any CSS background. The syntax for the rectangle is similar to the rect() function generating a <<shape>()> CSS type. All four values are relative to the upper left corner of the image. Examples This example loads an image and uses it in four segments to draw the Firefox logo in four <
div> blocks. Clicking on their container causes the four segments to rotate around by swapping the background-image property values among the four <
div> blocks. CSS The CSS defines one container style, then the styles for the four boxes that comprise the complete image. The container looks like this: #container { width:267px; height:272px; top:100px; left:100px; position:absolute; fon...
...These four segments are all contained ...
...ge-rect(url(https://mdn.mozillademos.org/files/12053/firefox.png), 50%, 50%, 100%, 0%); width:133px; height:136px; position:absolute; } #box4 { background-image: -moz-image-rect(url(https://mdn.mozillademos.org/files/12053/firefox.png), 50%, 100%, 100%, 50%); width:133px; height:136px; position:absolute; } HTML The HTML is quite simple: <
div id="container" onclick="rotate()"> <
div id="box1" style="left:0px;top:0px;">Top left</
div> <
div id="box2" style="left:133px;top:0px;">Top right</
div> <
div id="box3" style="left:0px;top:136px;">Bottom left</
div> <
div id="box4" style="left:133px;top:136px;">Bottom right</
div> </
div> This places the four segments of our image in a two-by-two box grid. These four segments are all contained within a larger <
div> block whose primary ...
-webkit-overflow-scrolling - CSS: Cascading Style Sheets
ile after finishing the scroll gesture and removing your finger from the touchscreen. The speed and duration of the continued scrolling is proportional to how vigorous the scroll gesture was. Also creates a new stacking context. ...
...n. The speed and duration of the continued scrolling is proportional to how vigorous the scroll gesture was. Also creates a new stacking context. Formal definition Initial valueautoApplies toscrolling boxesInheritedyesComputed valueas specifiedAnimation typediscrete Formal syntax auto | touch Examples HTML <
div class="scroll-touch"> <p> This paragraph has momentum scrolling </p> </
div> <
div class="scroll-auto"> <p> This paragraph does not. ...
... vigorous the scroll gesture was. Also creates a new stacking context. Formal definition Initial valueautoApplies toscrolling boxesInheritedyesComputed valueas specifiedAnimation typediscrete Formal syntax auto | touch Examples HTML <
div class="scroll-touch"> <p> This paragraph has momentum scrolling </p> </
div> <
div class="scroll-auto"> <p> This paragraph does not. </p> </
div> CSS
div { width: 100%; overflow: auto; } p { width: 200%; background: #f5f9fa; border: 2px solid #eaf2f4; padding: 10px; } .scroll-touch { -webkit-overflow-scrolling: touch; /* Lets it scroll lazy */ } .scroll-auto { -webkit-overflow-scrolling: auto; /* Stops scrolling immediately */ } Results Specifications Not part of any standard. Apple has a description in the Safa...
:-moz-only-whitespace - CSS: Cascading Style Sheets
Note: In Selectors Level 4 the :empty selector was changed to act like :-moz-only-whitespace, but no browser currently supports this yet. The :-moz-only-whitespace CSS pseudo-class matches elements that only contains text nodes that only contain whitespace. ...
... Note: In Selectors Level 4 the :empty selector was changed to act like :-moz-only-whitespace, but no browser currently supports this yet. The :-moz-only-whitespace CSS pseudo-class matches elements that only contains text nodes that only contain whitespace. ...
...itespace, but no browser currently supports this yet. The :-moz-only-whitespace CSS pseudo-class matches elements that only contains text nodes that only contain whitespace. (This includes elements with empty text nodes and elements with no child nodes.) Syntax Syntax not found in DB! Examples HTML <
div> </
div> CSS :root { overflow: hidden; max-width: 100vw; max-height: 100vh; }
div { background-color: #ccc; box-sizing: border-box; height: 100vh; min-height: 16px; min-height: 1rem; }
div { border: 4px solid red; } :-moz-only-whitespace { border-color: lime; } Result Specifications Briefly defined as :blank in Selectors Level 4, but then the functionality was merged into :empty and :blank redefined to mean empty <input>. ...
::slotted() - CSS: Cascading Style Sheets
> ']' | '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'where <attr-matcher> = [ '~' | | | '^' | '$' | '*' ]? '='<attr-modifier> = i | s Examples Highlighting slotted elements The following snippets are taken from our slotted-pseudo-element demo (see it live also). ...
...ts are taken from our slotted-pseudo-element demo (see it live also). ...
...-- <person-details> -- is defined like so: customElements.define('person-details', class extends HTMLElement { constructor() { super(); let template = document.getElementById('person-template'); let templateContent = template.content; const shadowRoot = this.attachShadow({mode: 'open'}); let style = document.createElement('style'); style.textContent = '
div { padding: 10px; border: 1px solid gray; width: 200px; margin: 10px; }' + 'h2 { margin: 0 0 10px; }' + 'ul { margin: 0; }' + 'p { margin: 10px 0; }' + '::slotted(*) { color: gray; font-family: sans-serif; } '; shadowRoot.appendChild(style); shadowRoot.appendChild(templateConten...
:empty - CSS: Cascading Style Sheets
y CSS pseudo-class represents any element that has no children. Children can be either element nodes or text (including whitespace). Comments, processing instructions, and CSS content do not affect whether an element is considered empty. Note: In Selectors Level 4 the :empty pseudo-class was changed to act like :-moz-only-whitespace, but no browser currently supports this yet. ...
... element that has no children. Children can be either element nodes or text (including whitespace). Comments, processing instructions, and CSS content do not affect whether an element is considered empty. Note: In Selectors Level 4 the :empty pseudo-class was changed to act like :-moz-only-whitespace, but no browser currently supports this yet. /* Selects any <
div> that contains no content */
div:empty { background: lime; } Syntax :empty Examples HTML <
div class="box"><!-- I will be lime. --></
div> <
div class="box">I will be pink.</
div> <
div class="box"> <!-- I will be pink in older browsers because of the whitespace around this comment. --> </
div> <
div class="box"> <p><!-- I will be pink in all browsers because of the non-collapsible whitespace and elements around this comment. ...
... background: lime; } Syntax :empty Examples HTML <
div class="box"><!-- I will be lime. --></
div> <
div class="box">I will be pink.</
div> <
div class="box"> <!-- I will be pink in older browsers because of the whitespace around this comment. --> </
div> <
div class="box"> <p><!-- I will be pink in all browsers because of the non-collapsible whitespace and elements around this comment. --></p> </
div> CSS body { display: flex; justify-content: space-around; } .box { background: pink; height: 80px; width: 80px; } .box:empty { background: lime; } Result Accessibility concerns Assistive technology such as screen readers cannot parse interactive content that is empty. All interactive content must have an accessible name, which is created by providing a text value for the i...
:not() - CSS: Cascading Style Sheets
ecificity. :not(.foo) will match anything that isn't .foo, including <html> and <body>. This selector only applies to one element; you cannot use it to exclude all ancestors. For instance, body :not(table) a will still apply to links inside of a table, since <tr> will match with the :not() part of the selector. ...
... match anything that isn't .foo, including <html> and <body>. This selector only applies to one element; you cannot use it to exclude all ancestors. For instance, body :not(table) a will still apply to links inside of a table, since <tr> will match with the :not() part of the selector. ...
...ot() part of the selector. Examples HTML <p>I am a paragraph.</p> <p class="fancy">I am so very fancy!</p> <
div>I am NOT a paragraph.</
div> CSS .fancy { text-shadow: 2px 2px 3px gold; } /* <p> elements that are not in the class `.fancy` */ p:not(.fancy) { color: green; } /* Elements that are not <p> elements */ body :not(p) { text-decoration: underline; } /* Elements that are not <
div> and not <span> elements */ body :not(
div):not(span) { font-weight: bold; } /* Elements that are not `.crazy` or `.fancy` */ /* Note that this syntax is not well supported yet. */ body :not(.crazy, .fancy) { font-family: sans-serif; } Result Specifications Specification Status Comment Selectors Level 4The definition of ':not()' in that specification. Worki...
:target - CSS: Cascading Style Sheets
ique relies on the ability of anchor links to point to elements that are initially hidden on the page. Once targeted, the CSS changes their display so that they are shown. Note: A more complete pure-CSS lightbox based on the :target pseudo-class is available on GitHub (demo). ...
...is available on GitHub (demo). HTML <ul> <li><a href="#example1">Open example #1</a></li> <li><a href="#example2">Open example #2</a></li> </ul> <
div class="lightbox" id="example1"> <figure> <a href="#" class="close"></a> <figcaption>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec felis enim, placerat id eleifend eu, semper vel sem.</figcaption> </figure> </
div> <
div class="lightbox" id="example2"> <figure> <a href="#" class="close"></a> <figcaption>Cras risus odio, pharetra nec ultricies et, mollis ac augue. Nunc et diam quis sapien dignissim auctor. ...
...dipiscing elit. Donec felis enim, placerat id eleifend eu, semper vel sem.</figcaption> </figure> </
div> <
div class="lightbox" id="example2"> <figure> <a href="#" class="close"></a> <figcaption>Cras risus odio, pharetra nec ultricies et, mollis ac augue. Nunc et diam quis sapien dignissim auctor. ...
height - CSS: Cascading Style Sheets
The height CSS media feature can be used to apply styles based on the height of the viewport (or the page box, for paged media). Syntax The height feature is specified as a <length> value representing the viewport height. It is a range feature, meaning that you can also use the prefixed min-height and max-height variants to query minimum and maximum values, respectively. ...
... based on the height of the viewport (or the page box, for paged media). Syntax The height feature is specified as a <length> value representing the viewport height. It is a range feature, meaning that you can also use the prefixed min-height and max-height variants to query minimum and maximum values, respectively. ...
...r paged media). Syntax The height feature is specified as a <length> value representing the viewport height. It is a range feature, meaning that you can also use the prefixed min-height and max-height variants to query minimum and maximum values, respectively. Examples HTML <
div>Watch this element as you resize your viewport's height.</
div> CSS /* Exact height */ @media (height: 360px) {
div { color: red; } } /* Minimum height */ @media (min-height: 25rem) {
div { background: yellow; } } /* Maximum height */ @media (max-height: 40rem) {
div { border: 2px solid blue; } } Result Specifications Specification Status Comment Media Queries Level 4The definition of 'height' in that specification. Candidate Recommendation The va...
width - CSS: Cascading Style Sheets
The width CSS media feature can be used to test the width of the viewport (or the page box, for paged media). Syntax The width feature is specified as a <length> value representing the viewport width. It is a range feature, meaning that you can also use the prefixed min-width and max-width variants to query minimum and maximum values, respectively. ...
...be used to test the width of the viewport (or the page box, for paged media). Syntax The width feature is specified as a <length> value representing the viewport width. It is a range feature, meaning that you can also use the prefixed min-width and max-width variants to query minimum and maximum values, respectively. ...
...box, for paged media). Syntax The width feature is specified as a <length> value representing the viewport width. It is a range feature, meaning that you can also use the prefixed min-width and max-width variants to query minimum and maximum values, respectively. Examples HTML <
div>Watch this element as you resize your viewport's width.</
div> CSS /* Exact width */ @media (width: 360px) {
div { color: red; } } /* Minimum width */ @media (min-width: 35rem) {
div { background: yellow; } } /* Maximum width */ @media (max-width: 50rem) {
div { border: 2px solid blue; } } Result Specifications Specification Status Comment Media Queries Level 4The definition of 'width' in that specification. Candidate Recommendation The value c...
Using multiple backgrounds - CSS: Cascading Style Sheets
ltiple 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. Specifying multiple backgrounds is easy: .myclass { background: background1, background 2, ..., backgroundN; } You can do this with both the shorthand background property and the in
dividual properties thereof except for background-color. That is, the following background properties can be specified as a list, one per background: background, background-attachment, background-clip, background-image, background-origin, background-position, background-repeat, background-size. Example In this example, three backgrounds are stacked: the Firefox logo, an image of bubbles, and a line...
...eof except for background-color. That is, the following background properties can be specified as a list, one per background: background, background-attachment, background-clip, background-image, background-origin, background-position, background-repeat, background-size. ...
.... That is, the following background properties can be specified as a list, one per background: background, background-attachment, background-clip, background-image, background-origin, background-position, background-repeat, background-size. ...
Mastering margin collapsing - CSS: Cascading Style Sheets
Note that the margins of floating and absolutely positioned elements never collapse. Margin collapsing occurs in three basic cases: Adjacent siblings The margins of adjacent siblings are collapsed (except when the latter sibling needs to be cleared past floats). ...
...n and the smallest (most negative) negative margin. When all margins are negative, the size of the collapsed margin is the smallest (most negative) margin. This applies to both adjacent elements and nested elements. Examples HTML <p>The bottom margin of this paragraph is collapsed ...</p> <p>... ...
...>The bottom margin of this paragraph is collapsed ...</p> <p>... with the top margin of this paragraph, yielding a margin of <code>1.2rem</code> in between.</p> <
div>This parent element contains two paragraphs! <p>This paragraph has a <code>.4rem</code> margin between it and the text above.</p> <p>My bottom margin collapses with my parent, yielding a bottom margin of <code>2rem</code>.</p> </
div> <p>I am <code>2rem</code> below the element above.</p> CSS
div { margin: 2rem 0; background: lavender; } p { margin: .4rem 0 1.2rem 0; background: yellow; } Result Specifications Specification Status Comment CSS Level 2 (Revision 1)The definition of 'margin collapsing' in that specification. Recommendation Initial definition. ...
Introduction to formatting contexts - CSS: Cascading Style Sheets
becomes a mini-layout inside the main layout. A BFC contains everything inside it, float and clear only apply to items inside the same formatting context, and margins only collapse between elements in the same formatting context. BFC creation examples Let's have a look at a couple of these in order to see the effect creating a new BFC. In the example below, we have a floated element inside a <
div> with a border applied. The content of that <
div> has floated alongside the floated element. As the content of the float is taller than the content alongside it, the border of the <
div> now runs through the float. As explained in the guide to in-flow and out of flow elements, the float has been taken out of flow so the background and border of the
div only contain the content and not the float. ...
...Any child element will be contained inside it. The problem with using overflow to create a new BFC is that the overflow property is meant for telling the browser how you wish to deal with overflowing content. ...
...re developer, as it may not be obvious why you used overflow for this purpose. If you do this, it would be a good idea to comment the code to explain. Explicitly creating a BFC using display: flow-root Using display: flow-root (or display: flow-root list-item) on the containing block will create a new BFC without any other potentially problematic side-effects. With display: flow-root on the <
div>, everything inside that container participates in the block formatting context of that container, and floats will not poke out of the bottom of the element. The name of the flow-root keyword refers to the fact that you're creating something that serves, in essence, like a new root element (like <html> does), given how the new context is created and its flow layout functions. Inline formatting ...
OpenType font features guide - CSS: Cascading Style Sheets
ibutes defined to leverage font features, but unfortunately many are not fully implemented. They are all defined and shown here, but many will only work using the lower-level font-feature-settings property. It's possible to write CSS to work both ways but this can become cumbersome. The issue with simply using font-feature-settings for everything is that every time you want to change one of the in
dividual features, you have to redefine the entire string (similar to manipulating variable fonts with font-variation-settings). Discovering availability of features in fonts This is sometimes the trickiest thing to work out if you don't have any documentation that came with the fonts (many type designers and foundries will provide sample pages and CSS just for this very reason). But there are som...
...ites much easier to read and understand. Numerals within paragraphs of text set as 'oldstyle' sit more comfortably between lower-case letters, and likewise setting them as 'tabular numbers' will make them line up better when setting a list of costs in a table say. 'lining' figures on the other hand sit more uniformly on their own or in front of capitalized words. While none of these features in
dividually will render a site useless due to their absence, each of them in turn can make a site easier to use and more memorable for its attention to detail. OpenType features are like secret compartments in fonts. Unlock them and you'll find ways to make fonts look and behave differently in subtle and dramatic ways. Not all OpenType features are appropriate to use all of the time, but some featur...
...s for various glyphs, such as different styles of lower case 'a' or more or less elaborate swashes in a script typeface. This property can activate an entire set of alternates or just a specific one, depending on the values supplied.The example below is showing several different aspects of working with alternate characters. Fonts with alternate glyphs can make them available across the board or in
dividually in separate stylistic sets, or even in
dividual characters. In this example you can see two different typefaces, and the introduction of the @font-feature-values at-rule. This is used to define shortcuts or named options that can be defined per font family. This way you can create a named option that applies to only a single font, or one that is shared and can be applied more generally I...
CSS Grid Layout and Accessibility - CSS: Cascading Style Sheets
ve used the line-based placement properties to position box 1 on the second row of the grid. Visually it now appears as the fourth item in the list. However, if I tab from link to link the tab order still begins with box 1, as it comes first in the source. ...
...der-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 100px; } .box1 { grid-column: 1; grid-row: 2; } <
div class="wrapper"> <
div class="box box1"><a href="">One</a></
div> <
div class="box box2"><a href="">Two</a></
div> <
div class="box box3"><a href="">Three</a></
div> <
div class="box box4"><a href="">Four</a></
div> <
div class="box box5"><a href="">Five</a></
div> </
div> The specification says that in this scenario, if box 1 really makes sense logically in that position, we should go back t...
...y: contents. Given that interoperable support for display: contents is limited and we do not yet have subgrids, there is a definite temptation when developing a site using CSS Grid Layout to flatten out the markup, to remove semantic elements in order to make it simpler to create a layout. An example would be where some content was semantically marked up as a list but you decide to use a set of <
div> elements instead as then you can have the element to be a direct child of a container set to display: grid. Be aware of this temptation and find ways to develop your design without stripping out the markup. Starting out with a well-structured document is a very good way to avoid the problem, as you will be aware that you are removing semantic elements in order to make the layout work if you actu...
align-content - CSS: Cascading Style Sheets
evenly | stretch<overflow-position> = unsafe | safe<content-position> = center | start | end | flex-start | flex-end Examples CSS #container { height:200px; width: 240px; align-content: center; /* Can be changed in the live sample */ background-color: #8c8c8c; } .flex { display: flex; flex-wrap: wrap; } .grid { display: grid; grid-template-columns: repeat(auto-fill, 50px); }
div >
div { box-sizing: border-box; border: 2px solid #8c8c8c; width: 50px; display: flex; align-items: center; justify-content: center; } #item1 { background-color: #8cffa0; min-height: 30px; } #item2 { background-color: #a0c8ff; min-height: 50px; } #item3 { background-color: #ffa08c; min-height: 40px; } #item4 { background-color: #ffff8c; min-height: 60px; } #item5 ...
...px; } #item2 { background-color: #a0c8ff; min-height: 50px; } #item3 { background-color: #ffa08c; min-height: 40px; } #item4 { background-color: #ffff8c; min-height: 60px; } #item5 { background-color: #ff8cff; min-height: 70px; } #item6 { background-color: #8cffff; min-height: 50px; font-size: 30px; } select { font-size: 16px; } .row { margin-top: 10px; } HTML <
div id="container" class="flex"> <
div id="item1">1</
div> <
div id="item2">2</
div> <
div id="item3">3</
div> <
div id="item4">4</
div> <
div id="item5">5</
div> <
div id="item6">6</
div> </
div> <
div class="row"> <label for="display">display: </label> <select id="display"> <option value="flex">flex</option> <option value="grid">grid</option> </select> </
div> <
div class="row"> <labe...
...ption> <option value="unsafe center">unsafe center</option> <option value="safe right">safe right</option> <option value="unsafe right">unsafe right</option> <option value="safe end">safe end</option> <option value="unsafe end">unsafe end</option> <option value="safe flex-end">safe flex-end</option> <option value="unsafe flex-end">unsafe flex-end</option> </select> </
div> JavaScript var values = document.getElementById('values'); var display = document.getElementById('display'); var container = document.getElementById('container'); values.addEventListener('change', function (evt) { container.style.alignContent = evt.target.value; }); display.addEventListener('change', function (evt) { container.className = evt.target.value; }); Result Specificatio...
align-items - CSS: Cascading Style Sheets
rflow-position> = unsafe | safe<self-position> = center | start | end | self-start | self-end | flex-start | flex-end Examples CSS #container { height:200px; width: 240px; align-items: center; /* Can be changed in the live sample */ background-color: #8c8c8c; } .flex { display: flex; flex-wrap: wrap; } .grid { display: grid; grid-template-columns: repeat(auto-fill, 50px); }
div >
div { box-sizing: border-box; border: 2px solid #8c8c8c; width: 50px; display: flex; align-items: center; justify-content: center; } #item1 { background-color: #8cffa0; min-height: 30px; } #item2 { background-color: #a0c8ff; min-height: 50px; } #item3 { background-color: #ffa08c; min-height: 40px; } #item4 { background-color: #ffff8c; min-height: 60px; } #item5 ...
...0px; } #item2 { background-color: #a0c8ff; min-height: 50px; } #item3 { background-color: #ffa08c; min-height: 40px; } #item4 { background-color: #ffff8c; min-height: 60px; } #item5 { background-color: #ff8cff; min-height: 70px; } #item6 { background-color: #8cffff; min-height: 50px; font-size: 30px; } select { font-size: 16px; } .row { margin-top: 10px; } HTML <
div id="container" class="flex"> <
div id="item1">1</
div> <
div id="item2">2</
div> <
div id="item3">3</
div> <
div id="item4">4</
div> <
div id="item5">5</
div> <
div id="item6">6</
div> </
div> <
div class="row"> <label for="display">display: </label> <select id="display"> <option value="flex">flex</option> <option value="grid">grid</option> </select> </
div> <
div class="row"> <labe...
... <option value="unsafe right">unsafe right</option> <option value="safe end">safe end</option> <option value="unsafe end">unsafe end</option> <option value="safe self-end">safe self-end</option> <option value="unsafe self-end">unsafe self-end</option> <option value="safe flex-end">safe flex-end</option> <option value="unsafe flex-end">unsafe flex-end</option> </select> </
div> JavaScript var values = document.getElementById('values'); var display = document.getElementById('display'); var container = document.getElementById('container'); values.addEventListener('change', function (evt) { container.style.alignItems = evt.target.value; }); display.addEventListener('change', function (evt) { container.className = evt.target.value; }); Result Specifications...
background-image - CSS: Cascading Style Sheets
centage> = <length> | <percentage><angular-color-stop> = <color> && <color-stop-angle>?<angular-color-hint> = <angle-percentage>where <color-stop-length> = <length-percentage>{1,2}<color-stop-angle> = <angle-percentage>{1,2}<angle-percentage> = <angle> | <percentage> Examples Layering background images Note that the star image is partially transparent and is layered over the cat image. ...
...percentage> = <angle> | <percentage> Examples Layering background images Note that the star image is partially transparent and is layered over the cat image. HTML <
div> <p class="catsandstars"> This paragraph is full of cats<br />and stars. ...
...ransparent and is layered over the cat image. HTML <
div> <p class="catsandstars"> This paragraph is full of cats<br />and stars. ...
background-position-x - CSS: Cascading Style Sheets
wordAnimation typediscrete Formal syntax [ center | [ [ left | right | x-start | x-end ]? <length-percentage>? ]! ]#where <length-percentage> = <length> | <percentage> Examples Basic example The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately. ...
...imation typediscrete Formal syntax [ center | [ [ left | right | x-start | x-end ]? <length-percentage>? ]! ]#where <length-percentage> = <length> | <percentage> Examples Basic example The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately. ...
...ediscrete Formal syntax [ center | [ [ left | right | x-start | x-end ]? <length-percentage>? ]! ]#where <length-percentage> = <length> | <percentage> Examples Basic example The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately. ...
background-position-y - CSS: Cascading Style Sheets
wordAnimation typediscrete Formal syntax [ center | [ [ top | bottom | y-start | y-end ]? <length-percentage>? ]! ]#where <length-percentage> = <length> | <percentage> Examples Basic example The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately. ...
...imation typediscrete Formal syntax [ center | [ [ top | bottom | y-start | y-end ]? <length-percentage>? ]! ]#where <length-percentage> = <length> | <percentage> Examples Basic example The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately. ...
...ediscrete Formal syntax [ center | [ [ top | bottom | y-start | y-end ]? <length-percentage>? ]! ]#where <length-percentage> = <length> | <percentage> Examples Basic example The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately. ...
<basic-shape> - CSS: Cascading Style Sheets
e number and types of path data commands in the same order, interpolate each path data command as real numbers. In all other cases no interpolation occurs. Examples Animated polygon In this example, we use the @keyframes at-rule to animate a clip path between two polygons. Note that both polygons have the same number of vertices, which is necessary for this type of animation to work. ...
...er and types of path data commands in the same order, interpolate each path data command as real numbers. In all other cases no interpolation occurs. Examples Animated polygon In this example, we use the @keyframes at-rule to animate a clip path between two polygons. Note that both polygons have the same number of vertices, which is necessary for this type of animation to work. ...
...s of path data commands in the same order, interpolate each path data command as real numbers. In all other cases no interpolation occurs. Examples Animated polygon In this example, we use the @keyframes at-rule to animate a clip path between two polygons. Note that both polygons have the same number of vertices, which is necessary for this type of animation to work. ...
border-bottom-color - CSS: Cascading Style Sheets
border-bottom-color: initial; border-bottom-color: unset; The border-bottom-color property is specified as a single value. Values <color> The color of the bottom border. Formal definition Initial valuecurrentcolorApplies toall elements. ...
...ial; border-bottom-color: unset; The border-bottom-color property is specified as a single value. Values <color> The color of the bottom border. Formal definition Initial valuecurrentcolorApplies toall elements. ...
... border. Formal definition Initial valuecurrentcolorApplies toall elements. It also applies to ::first-letter.InheritednoComputed valuecomputed colorAnimation typea color Formal syntax <'border-top-color'> Examples A simple
div with a border HTML <
div class="mybox"> <p>This is a box with a border around it. Note which side of the box is <span class="redtext">red</span>.</p> </
div> CSS .mybox { border: solid 0.3em gold; border-bottom-color: red; width: auto; } .redtext { color: red; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-bottom-color' in that specification. Candidate Recommendation No significant changes, though the transparent keyword...
border-bottom-left-radius - CSS: Cascading Style Sheets
rst-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Live example Code . An arc of circle is used as the border
div { border-bottom-left-radius: 40px 40px; } . An arc of ellipse is used as the border
div { border-bottom-left-radius: 40px 20px; } . The box is a square: an arc of circle is used as the border
div { border-bottom-left-radius: 40%; } . The box is not a square: an arc of ellips...
...s: 40px 40px; } . An arc of ellipse is used as the border
div { border-bottom-left-radius: 40px 20px; } . The box is a square: an arc of circle is used as the border
div { border-bottom-left-radius: 40%; } . The box is not a square: an arc of ellipse is used as the border
div { border-bottom-left-radius: 40%; } . ...
...s: 40px 20px; } . The box is a square: an arc of circle is used as the border
div { border-bottom-left-radius: 40%; } . The box is not a square: an arc of ellipse is used as the border
div { border-bottom-left-radius: 40%; } . The background color is clipped at the border
div { border-bottom-left-radius:40%; border-style: black 3px double; background-color: rgb(250,20,70); background-clip: content-box; } Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-bottom-left-radius' in that specification. Candidate Recommendation Initial definition ...
border-bottom-right-radius - CSS: Cascading Style Sheets
rst-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Live example Code . An arc of circle is used as the border
div { border-bottom-right-radius: 40px 40px; } . An arc of ellipse is used as the border
div { border-bottom-right-radius: 40px 20px; } . The box is a square: an arc of circle is used as the border
div { border-bottom-right-radius: 40%; } . The box is not a square: an arc of ell...
... 40px 40px; } . An arc of ellipse is used as the border
div { border-bottom-right-radius: 40px 20px; } . The box is a square: an arc of circle is used as the border
div { border-bottom-right-radius: 40%; } . The box is not a square: an arc of ellipse is used as the border
div { border-bottom-right-radius: 40%; } . ...
... 40px 20px; } . The box is a square: an arc of circle is used as the border
div { border-bottom-right-radius: 40%; } . The box is not a square: an arc of ellipse is used as the border
div { border-bottom-right-radius: 40%; } . The background color is clipped at the border
div { border-bottom-right-radius:40%; border-style: black 3px double; background-color: rgb(250,20,70); background-clip: content-box; } Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-bottom-right-radius' in that specification. Candidate Recommendation Initial definition ...
border-end-end-radius - CSS: Cascading Style Sheets
l table elements is undefined for the moment.. ...
..... ...
...o ::first-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Border radius with vertical text HTML <
div> <p class="exampleText">Example</p> </
div> CSS Content
div { background-color: rebeccapurple; width: 120px; height: 120px; border-end-end-radius: 10px; } .exampleText { writing-mode: vertical-rl; padding: 10px; background-color: #fff; border-end-end-radius: 10px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-end-end-radius' in that...
border-end-start-radius - CSS: Cascading Style Sheets
l table elements is undefined for the moment.. ...
..... ...
...pplies to ::first-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Border radius with vertical text HTML <
div> <p class="exampleText">Example</p> </
div> CSS
div { background-color: rebeccapurple; width: 120px; height: 120px; border-end-start-radius: 10px; } .exampleText { writing-mode: vertical-rl; padding: 10px; background-color: #fff; border-end-start-radius: 10px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-end-start-radius' i...
border-left-color - CSS: Cascading Style Sheets
value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...alue>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples A simple
div with a border HTML <
div class="mybox"> <p>This is a box with a border around it. Note which side of the box is <span class="redtext">red</span>.</p> </
div> CSS .mybox { border: solid 0.3em gold; border-left-color: red; width: auto; } .redtext { color: red; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-left-color' in that specification. Candidate Recommendation No significant changes, though the transparent keyword, no...
border-right-color - CSS: Cascading Style Sheets
value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...alue>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples A simple
div with a border HTML <
div class="mybox"> <p>This is a box with a border around it. Note which side of the box is <span class="redtext">red</span>.</p> </
div> CSS .mybox { border: solid 0.3em gold; border-right-color: red; width: auto; } .redtext { color: red; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-right-color' in that specification. Candidate Recommendation No significant changes, though the transparent keyword, ...
border-right - CSS: Cascading Style Sheets
...
... Candidate Re...
... <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples Applying a right border to a
div HTML <
div> This box has a border on the right side. </
div> CSS
div { border-right: 4px dashed blue; background-color: gold; height: 100px; width: 100px; font-weight: bold; text-align: center; } Results Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-right' in that specification. Candidate Recommendation No direct changes, though the modi...
border-start-end-radius - CSS: Cascading Style Sheets
l table elements is undefined for the moment.. ...
..... ...
...pplies to ::first-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Border radius with vertical text HTML <
div> <p class="exampleText">Example</p> </
div> CSS
div { background-color: rebeccapurple; width: 120px; height: 120px; border-start-end-radius: 10px; } .exampleText { writing-mode: vertical-rl; padding: 10px; background-color: #fff; border-start-end-radius: 10px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-start-end-radius' i...
border-start-start-radius - CSS: Cascading Style Sheets
l table elements is undefined for the moment.. ...
..... ...
...pplies to ::first-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Border radius with vertical text HTML <
div> <p class="exampleText">Example</p> </
div> CSS
div { background-color: rebeccapurple; width: 120px; height: 120px; border-start-start-radius: 10px; } .exampleText { writing-mode: vertical-rl; padding: 10px; background-color: #fff; border-start-start-radius: 10px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-start-start-rad...
border-top-color - CSS: Cascading Style Sheets
value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
...alue>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples A simple
div with a border HTML <
div class="mybox"> <p>This is a box with a border around it. Note which side of the box is <span class="redtext">red</span>.</p> </
div> CSS .mybox { border: solid 0.3em gold; border-top-color: red; width: auto; } .redtext { color: red; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-top-color' in that specification. Candidate Recommendation No significant changes, though the transparent keyword, now includ...
border-top-right-radius - CSS: Cascading Style Sheets
The box is not a square: an arc of ellipse is used as the border ...
...solute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Live example Code An arc of circle is used as the border
div { border-top-right-radius: 40px 40px; } An arc of ellipse is used as the border
div { border-top-right-radius: 40px 20px; } The box is a square: an arc of circle is used as the border
div { border-top-right-radius: 40%; } . The box is not a square: an arc of ellipse is used as the border
div { border-top-right-radius: 40%; } The background color is clipped at the border ...
...{ border-top-right-radius: 40px 20px; } The box is a square: an arc of circle is used as the border
div { border-top-right-radius: 40%; } . The box is not a square: an arc of ellipse is used as the border
div { border-top-right-radius: 40%; } The background color is clipped at the border
div { border-top-right-radius:40%; border-style: black 3px double; background-color: rgb(250,20,70); background-clip: content-box; } Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-top-right-radius' in that specification. Candidate Recommendation Initial definition ...
box-flex - CSS: Cascading Style Sheets
-flex: 1). ...
... or -moz-inline-box or -webkit-box or -webkit-inline-boxInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <number> Examples Setting box-flex <!DOCTYPE html> <html> <head> <title>-moz-box-flex example</title> <style>
div.example { display: -moz-box; display: -webkit-box; border: 1px solid black; width: 100%; }
div.example > p:nth-child(1) { -moz-box-flex: 1; /* Mozilla */ -webkit-box-flex: 1; /* WebKit */ border: 1px solid black; }
div.example > p:nth-child(2) { -moz-box-flex: 0; /* Mozilla */ -webkit-box-flex: 0; /* WebKit */ border: 1px solid black; } </style> </head> <body> <
div class="example"> <p>I wi...
... ...
box-orient - CSS: Cascading Style Sheets
tial valueinline-axis (horizontal in XUL)Applies toelements with a CSS display value of box or inline-boxInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax horizontal | vertical | inline-axis | block-axis | inherit Examples Setting horizontal box orientation Here, he box-orient property will cause the two <p> sections in the example to display in the same line. ...
...uted valueas specifiedAnimation typediscrete Formal syntax horizontal | vertical | inline-axis | block-axis | inherit Examples Setting horizontal box orientation Here, he box-orient property will cause the two <p> sections in the example to display in the same line. ...
...s specifiedAnimation typediscrete Formal syntax horizontal | vertical | inline-axis | block-axis | inherit Examples Setting horizontal box orientation Here, he box-orient property will cause the two <p> sections in the example to display in the same line. ...
cross-fade() - CSS: Cascading Style Sheets
*/ cross-fade( url(white.png) 75%, url(black.png) 25%); /* 75% white, 25% black */ cross-fade( url(white.png) 100%, url(black.png) 0%); /* fully white */ cross-fade( url(green.png) 75%, url(red.png) 75%); /* both green and red at 75% */ If any percentages are omitted, all the specified percentages are summed together and subtracted from 100%. If the result is greater than 0%, the result is then
divided equally between all images with omitted percentages. In the simplest case, two images are faded between each other. To do that, only one of the images needs to have a percentage, the other one will be faded accordingly. For example, a value of 0% defined for the first image yields only the second image, while 100% yields only the first. A 25% value renders the first image at 25% and the seco...
...ed.png) 75%); /* both green and red at 75% */ If no percentages are declared, both the images will be 50% opaque, with a cross-fade rendering as an even merge of both images. The 50%/50% example seen above did not need to have the percentages listed, as when a percentage value is omitted, the included percentages are added together and subtracted from 100%. The result, if greater than 0, is then
divided equally between all images with omitted percentages. In the last example, the sum of both percentages is not 100%, and therefore both images include their respective opacities. If no percentages are declared and three images are included, each image will be 33.33% opaque. The two following are lines (almost) identical: cross-fade( url(red.png), url(yellow.png), url(blue.png)); /* all three...
...p> = <color> <color-stop-length>?<linear-color-hint> = <length-percentage><length-percentage> = <length> | <percentage><angular-color-stop> = <color> && <color-stop-angle>?<angular-color-hint> = <angle-percentage>where <color-stop-length> = <length-percentage>{1,2}<color-stop-angle> = <angle-percentage>{1,2}<angle-percentage> = <angle> | <percentage> Examples Older syntax for cross-fade HTML <
div class="crossfade"></
div> CSS .crossfade { width: 300px; height: 300px; background-image: -webkit-cross-fade( url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.org/files/8545/tr.png'), 75%); background-image: cross-fade( url('https://mdn.mozillademos.org/files/8543/br.png'), url('https://mdn.mozillademos.o...
<display-box> - CSS: Cascading Style Sheets
lay: contents | Hidde de Vries Display: Contents Is Not a CSS Reset | Adrian Roselli Examples In this first example, the paragraph with a class of secret is set to display: none; the box and any content is now not rendered. ...
...ple, the paragraph with a class of secret is set to display: none; the box and any content is now not rendered. display: none HTML <p>Visible text</p> <p class="secret">Invisible text</p> CSS p.secret { display: none; } Result display: contents In this example the outer <
div> has a 2-pixel red border and a width of 300px. ...
...<p class="secret">Invisible text</p> CSS p.secret { display: none; } Result display: contents In this example the outer <
div> has a 2-pixel red border and a width of 300px. However it also has display: contents specified therefore this <
div> will not be rendered, the border and width will no longer apply, and the child element will be displayed as if the parent had never existed. HTML <
div class="outer"> <
div>Inner
div.</
div> </
div> CSS .outer { border: 2px solid red; width: 300px; display: contents; } .outer >
div { border: 1px solid green; } Result Specifications Specification Status CSS Display Module Level 3The definition of 'display-box' in that specification. Candidate Recommendation ...
left - CSS: Cascading Style Sheets
mal definition Initial valueautoApplies topositioned elementsInheritednoPercentagesrefer to the width of the containing blockComputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length, percentage or calc(); Formal syntax <length> | <percentage> | auto Examples Positioning elements HTML <
div id="wrap"> <
div id="example_1"> <pre> position: absolute; left: 20px; top: 20px; </pre> <p>The only containing element for this
div is the main window, so it positions itself in relation to it.</p> </
div> <
div id="example_2"> <pre> position: relative; top: 0; right: 0; </pre> <p>Relative position in relation to its siblings.</p> ...
...="wrap"> <
div id="example_1"> <pre> position: absolute; left: 20px; top: 20px; </pre> <p>The only containing element for this
div is the main window, so it positions itself in relation to it.</p> </
div> <
div id="example_2"> <pre> position: relative; top: 0; right: 0; </pre> <p>Relative position in relation to its siblings.</p> </
div> <
div id="example_3"> <pre> float: right; position: relative; top: 20px; left: 20px; </pre> <p>Relative to its sibling
div above, but removed from flow of content.</p> <
div id="example_4"> <pre> position: absolute; bottom: 10px; right: 20px; </pre> <p>Absolute position inside of a parent with relative position</...
... id="example_3"> <pre> float: right; position: relative; top: 20px; left: 20px; </pre> <p>Relative to its sibling
div above, but removed from flow of content.</p> <
div id="example_4"> <pre> position: absolute; bottom: 10px; right: 20px; </pre> <p>Absolute position inside of a parent with relative position</p> </
div> <
div id="example_5"> <pre> position: absolute; right: 0; left: 0; top: 200px; </pre> <p>Absolute position with both left and right declared</p> </
div> </
div> </
div> CSS #wrap { width: 700px; margin: 0 auto; background: #5C5C5C; } pre { white-space: pre; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; }...
mask-type - CSS: Cascading Style Sheets
luminance values must be used when applying it. alpha Is a keyword indicating that the associated mask image is an alpha mask, i.e., that its alpha channel values must be used when applying it. ...
...e used when applying it. alpha Is a keyword indicating that the associated mask image is an alpha mask, i.e., that its alpha channel values must be used when applying it. ...
...> <defs> <mask id="m" maskContentUnits="objectBoundingBox" style="mask-type:alpha"> <rect x=".1" y=".1" width=".8" height=".8" fill="red" fill-opacity="0.7"/> </mask> </defs> </svg> CSS .redsquare { height: 100px; width: 100px; background-color: rgb(128, 128, 128); border: solid 1px black; mask: url("#m"); } Result Setting a luminance mask HTML <
div class="redsquare"></
div> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0"> <defs> <mask id="m" maskContentUnits="objectBoundingBox" style="mask-type:luminance"> <rect x=".1" y=".1" width=".8" height=".8" fill="red" fill-opacity="0.7"/> </mask> </defs> </svg> CSS .redsquare { height: 100p...
max-block-size - CSS: Cascading Style Sheets
mal syntax <'max-width'> Examples Setting max-block-size with horizontal and vertical text In this example, the same text (the opening sentences from Herman Melville's novel Moby-Dick) is presented in both the horizontal-tb and vertical-rl writing modes. Everything else about the two boxes is identical, including the values used for max-block-size. HTML The HTML simply establishes the two <
div> blocks that will be presented with their writing-mode set using the classes horizontal or vertical. Both boxes share the standard-box class, which simply establishes coloring, padding, and their respective values of max-block-size. <p>Writing mode <code>horizontal-tb</code> (the default):</p> <
div class="standard-box horizontal"> Call me Ishmael. Some years ago--never mind how long precisel...
...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. ...
..."standard-box horizontal"> 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. </
div> <p>Writing mode <code>vertical-rl</code>:</p> <
div class="standard-box vertical"> 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. </
div> CSS The CSS defines three classes. The fi...
overflow-inline - CSS: Cascading Style Sheets
and grid containersInheritednoComputed valueas specified, except with visible/clip computing to auto/hidden respectively if one of overflow-x or overflow-y is neither visible nor clipAnimation typediscrete Formal syntax visible | hidden | clip | scroll | auto Examples Setting inline overflow behavior HTML <ul> <li><code>overflow-inline:hidden</code> -- hides the text outside the box <
div id="
div1"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-inline:scroll</code> -- always adds a scrollbar <
div id="
div2"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-inline:visible</code> -- displays the text outside the box if needed <
div id="
div3"> ABCDEFGHIJKLMOPQRSTUVWXYZABCD...
...KLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-inline:scroll</code> -- always adds a scrollbar <
div id="
div2"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-inline:visible</code> -- displays the text outside the box if needed <
div id="
div3"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-inline:auto</code> -- on most browsers, equivalent to <code>scroll</code> <
div id="
div4"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> </ul> CSS #
div1, #
div2, #
div3, #
div4 { border: 1px solid black; width: 250px; margin-bottom: 12px; } #
div1 { overflow-inline: hidden;} #
div2 { overflow-inline: scroll;} #
div3 { overflow-i...
... Working Draft ...
radial-gradient() - CSS: Cascading Style Sheets
cle or an ellipse. Color-stop points are positioned on a virtual gradient ray that extends horizontally from the center towards the right. Percentage-based color-stop positions are relative to the intersection between the ending shape and this gradient ray, which represents 100%. Each shape is a single color determined by the color on the gradient ray it intersects. ...
... points are positioned on a virtual gradient ray that extends horizontally from the center towards the right. Percentage-based color-stop positions are relative to the intersection between the ending shape and this gradient ray, which represents 100%. Each shape is a single color determined by the color on the gradient ray it intersects. ...
... the ending shape and this gradient ray, which represents 100%. Each shape is a single color determined by the color on the gradient ray it intersects. Examples Simple gradient <
div class="radial-gradient"></
div> .radial-gradient { width: 240px; height: 120px; } .radial-gradient { background-image: radial-gradient(cyan 0%, transparent 20%, salmon 40%); } Non-centered gradient <
div class="radial-gradient"></
div> .radial-gradient { width: 240px; height: 120px; } .radial-gradient { background-image: radial-gradient(farthest-corner at 40px 40px, #f35 0%, #43e 100%); } More radial-gradient examples Please see Using CSS gradients for more examples. Specifications Specification Status Comment CSS Images Module Level 3The definitio...
resize - CSS: Cascading Style Sheets
ity of textareas In many browsers, <textarea> elements are resizable by default. You may override this behavior with the resize property. HTML <textarea>Type some text here.</textarea> CSS textarea { resize: none; /* Disables resizability */ } Result Using resize with arbitrary elements You can use the resize property to make any element resizable. ...
... resizable by default. You may override this behavior with the resize property. HTML <textarea>Type some text here.</textarea> CSS textarea { resize: none; /* Disables resizability */ } Result Using resize with arbitrary elements You can use the resize property to make any element resizable. In the example below, a resizable <
div> contains a resizable paragraph (<p> element). ...
...ability */ } Result Using resize with arbitrary elements You can use the resize property to make any element resizable. In the example below, a resizable <
div> contains a resizable paragraph (<p> element). HTML <
div class="resizable"> <p class="resizable"> This paragraph is resizable in all directions, because the CSS `resize` property is set to `both` on this element. </p> </
div> CSS .resizable { resize: both; overflow: scroll; border: 1px solid black; }
div { height: 300px; width: 300px; } p { height: 200px; width: 200px; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'resize' in that specification. Editor's Draft Adds the values block and inline. ...
scroll-snap-points-y - CSS: Cascading Style Sheets
n Initial valuenoneApplies toscroll containersInheritednoPercentagesrelative to same axis of the padding-box of the scroll containerComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typediscrete Formal syntax none | repeat( <length-percentage> )where <length-percentage> = <length> | <percentage> Examples Setting vertical scroll snap points HTML <
div id="container"> <
div>1</
div> <
div>2</
div> <
div>3</
div> </
div> CSS #container { height: 200px; width: 220px; overflow-x: hidden; overflow-y: auto; scroll-snap-points-y: repeat(200px); scroll-snap-type: mandatory; font-size: 0; } #container >
div { width: 200px; height: 200px; display: inline-block; line-height: 200px; text-align: center; font-size: 100px; } #con...
... ...
... ...
top - CSS: Cascading Style Sheets
Working Draft Adds behavior...
... Working Draft Adds behavior for sticky positioning. CSS Level 2 (Revision 1)The definition of 'top' in that specification. Recommendation Initia...
... Working Draft Adds behavior for sticky positioning. CSS Level 2 (Revision 1)The definition of 'top' in that specification. Recommendation Initial definition. ...
transform - CSS: Cascading Style Sheets
Specifications Specification Status Comment CSS Transforms Level 2The definition of 'transform' in that specification. ...
... Specifications Specification Status Comment CSS Transforms Level 2The definition of 'transform' in that specification. Editor's Draft Adds 3...
... Specifications Specification Status Comment CSS Transforms Level 2The definition of 'transform' in that specification. Editor's Draft Adds 3D transform...
vertical-align - CSS: Cascading Style Sheets
ements. ...
... percentage and length values, the absolute length, otherwise the keyword as specifiedAnimation typea length Formal syntax baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length> Examples Basic example HTML <
div>An <img src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a default alignment.</
div> <
div>An <img class="top" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a text-top alignment.</
div> <
div>An <img class="bottom" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a text-bottom alignment.</
div> <
div>An <img class="middle" src="https://udn.realityripple.com/sam...
..."link" width="32" height="32" /> image with a text-top alignment.</
div> <
div>An <img class="bottom" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a text-bottom alignment.</
div> <
div>An <img class="middle" src="https://udn.realityripple.com/samples/b4/e1f0faff5b.svg" alt="link" width="32" height="32" /> image with a middle alignment.</
div> CSS img.top { vertical-align: text-top; } img.bottom { vertical-align: text-bottom; } img.middle { vertical-align: middle; } Result Specifications Specification Status Comment CSS Level 2 (Revision 1)The definition of 'vertical-align' in that specification. Recommendation Adds the <length> value and allows it to be applied to elements with a display typ...
DOM onevent handlers - Developer guides
sing the attributes' values using JavaScript will get the value set in the HTML. Further changes to the HTML attribute value can be done via the setAttribute method; Making changes to the JavaScript property will have no effect. HTML Given this HTML document: <p>Demonstrating quirks of <code>on<em>event</em></code> HTML attributes on <a onclick="log('Click!')">these three words</a>. ...
...he attributes' values using JavaScript will get the value set in the HTML. Further changes to the HTML attribute value can be done via the setAttribute method; Making changes to the JavaScript property will have no effect. HTML Given this HTML document: <p>Demonstrating quirks of <code>on<em>event</em></code> HTML attributes on <a onclick="log('Click!')">these three words</a>. ...
... property will have no effect. HTML Given this HTML document: <p>Demonstrating quirks of <code>on<em>event</em></code> HTML attributes on <a onclick="log('Click!')">these three words</a>. </p> <
div></
div> JavaScript Then this JavaScript demonstrates that the value of the HTML attribute is unaffected by changes to the JavaScript object's property. ...
HTML5 Parser - Developer guides
put>, <keygen>, <link>, <meta>, <param>, <source> and <wbr>. ...
...e element whose end tags can be omitted in some cases, such as <p> in the example below, but it's simpler to always use end tags for those elements than to make sure that the end tags are only omitted when they aren't necessary.) For example, the following code writes a balanced sub-tree: <script> document.write("<
div>"); document.write("<p>Some content goes here.</p>"); document.write("</
div>"); </script> <!-- Non-script HTML goes here. ...
...ode writes a balanced sub-tree: <script> document.write("<
div>"); document.write("<p>Some content goes here.</p>"); document.write("</
div>"); </script> <!-- Non-script HTML goes here. --> In contrast, the following code contains two scripts with unbalanced sub-trees, which causes speculative parsing to fail and therefore the time to parse the document is longer. <script>document.write("<
div>");</script> <p>Some content goes here.</p> <script>document.write("</
div>");</script> For more information, see Optimizing your pages for speculative parsing. ...
Using HTML sections and outlines - Developer guides
tic sectioning elements are specifically designed to communicate structural meaning to browsers and other technologies interpreting the document on behalf of users, such as screen readers and voice assistants. Semantic sectioning elements clarify the larger-scale structures within a document. They are intended to enhance the limited semantics of earlier versions of HTML, which included only the <
div> tag as a generic mechanism for grouping related content. For example, <
div class="navigation"> does not suggest any meaning about its content to a browser; only a human reading the HTML source can
divine the meaning of a class like navigation. By contrast, the <nav> sectioning element more clearly describes to browsers and other devices the content contained: links or other navigational structur...
...'s content. New semantic elements were added to HTML5 to improve and clarify the sectioning of websites into meaningful areas of content. It is important for developers to use these semantic elements in line with their intended purposes. Many accessibility tools as well as reader views provided by some browsers rely on semantic sectioning elements. So don't simply swap out an existing tangle of <
div> elements for a bunch of <section> elements. Section Elements in HTML5 HTML Navigational Element (<nav>) defines a section that contains navigation links that appear often on a site. You can have primary and secondary menus, but you cannot nest a <nav> element inside another <nav> element. HTML Article Element (<article>) defines a piece of self-contained content. It does not refer to the ma...
.../h1> </header> <p> Do you want to help protect the web?.... </p> <aside> <blockquote> Amazing quote from article </blockquote> </aside> <footer> <p> Author info, publication date </p> </footer> </article> Nesting articles and sections Articles can be nested inside of sections and sections can be nested inside of articles. A book, for example, may be
divided up into sections with related articles. Each of these articles could contain sections of related information. <section> <h1>Getting Involved</h1> <article> <header> <h2>How to Become an MDN Contributor</h2> <p>Do you want to help protect the web?....</p> </header> <section> <h3>Steps to Editing an Article</h3> </section> <footer> <p>Author info...
Applying color to HTML elements using CSS - HTML: Hypertext Markup Language
it--is to simply specify colors in the CSS that's used when rendering elements. While we won't use every single property mentioned previously, we'll look at a couple of examples. The concept is the same anywhere you use color. Let's take a look at an example, starting by looking at the results we're trying to achieve: HTML The HTML responsible for creating the above example is shown here: <
div class="wrapper"> <
div class="box boxLeft"> <p> This is the first box. </p> </
div> <
div class="box boxRight"> <p> This is the second box. </p> </
div> </
div> This is pretty simple, using a <
div> as a wrapper around the contents, which consists of two more <
div>s, each styled differently with a single paragraph (<p>) in each box. The magic happens, as usual, in ...
.... The magic happens, as usual, in the CSS, where we'll apply colors define the layout for the HTML above. CSS We'll look at the CSS to create the above results a piece at a time, so we can review the interesting parts one by one. .wrapper { width: 620px; height: 110px; margin: 0; padding: 10px; border: 6px solid mediumturquoise; } The .wrapper class is used to assign styles to the <
div> that encloses all of our other content. This establishes the size of the container using width and height as well as its margin and padding. Of more interest to our discussion here is the use of the border property to establish a border around the outside edge of the element. This border is a solid line, 6 pixels wide, in the color mediumturquoise. Our two colored boxes share a number of prope...
...up and picking the final color, the color picker's value is displayed. On macOS, you indicate that you've finalized selection of the color by closing the color picker window. HTML The HTML here creates a box that contains a color picker control (with a label created using the <label> element) and an empty paragraph element (<p>) into which we'll output some text from our JavaScript code. <
div id="box"> <label for="colorPicker">Border color:</label> <input type="color" value="#8888ff" id="colorPicker"> <p id="output"></p> </
div> CSS The CSS simply establishes a size for the box and some basic styling for appearances. The border is also established with a 2-pixel width and a border color that won't last, courtesy of the JavaScript below... #box { width: 500px; height: 200px...
HTML attribute reference - HTML: Hypertext Markup Language
is specified, it overrides the target attribute of the button's form owner. headers <td>, <th> IDs of the <th> elements which applies to this element. height <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> Specifies the height of elements listed here. For all other elements, use the CSS height property. Note: In some instances, such as <
div>, this is a legacy attribute, in which case the CSS height property should be used instead. hidden Global attribute Prevents rendering of given element, while keeping child elements, e.g. script elements, active. high <meter> Indicates the lower bound of the upper range. href <a>, <area>, <base>, <link> The URL of a linked resource. h...
... <input>, <object> value <button>, <data>, <input>, <li>, <meter>, <option>, <progress>, <param> Defines a default value which will be displayed in the element on page load. width <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> For the elements listed here, this establishes the element's width. Note: For all other instances, such as <
div>, this is a legacy attribute, in which case the CSS width property should be used instead. wrap <textarea> Indicates whether the text should be wrapped. Content versus IDL attributes In HTML, most attributes have two faces: the content attribute and the IDL (Interface Definition Language) attribute. The content attribute is the attribute as you set it from the con...
...ML5 defines restrictions on the allowed values of boolean attributes: If the attribute is present, its value must either be the empty string (equivalently, the attribute may have an unassigned value), or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace. The following examples are valid ways to mark up a boolean attribute: <
div itemscope> This is valid HTML but invalid XML. </
div> <
div itemscope=itemscope> This is also valid HTML but invalid XML. </
div> <
div itemscope=""> This is valid HTML and also valid XML. </
div> <
div itemscope="itemscope"> This is also valid HTML and XML, but perhaps a bit verbose. </
div> To be clear, the values "true" and "false" are not allowed on boolean attributes. To represent a false value, ...
<input type="email"> - HTML: Hypertext Markup Language
rnational domain names and the validation of e-mail addresses in HTML. See W3C bug 15489 for details. Pattern validation If you need the entered e-mail address to be restricted further than just "any string that looks like an e-mail address," you can use the pattern attribute to specify a regular expression the value must match for it to be valid. If the multiple attribute is specified, each in
dividual item in the comma-delineated list of values must match the regular expression. For example, let's say you're building a page for employees of Best Startup Ever, Inc. which will let them contact their IT department for help. In our simplified form, the user needs to enter their e-mail address and a message describing the problem they need help with. We want to ensure that not only does the u...
...ess be an internal corporate e-mail address. Since inputs of type email validate against both the standard e-mail address validation and the specified pattern, you can implement this easily. ...
... line-height: 22px; } label::after { content: ":"; } <form> <
div class="emailBox"> <label for="emailAddress">Your e-mail address</label><br> <input id="emailAddress" type="email" size="64" maxLength="64" required placeholder="username@beststartupever.com" pattern=".+@beststartupever.com" title="Please provide only a Best Startup Ever corporate e-mail address"> </
div> <
div class="messageBox"> <label for="message">Request</label><br> <textarea id="message" cols="80" rows="8" required placeholder="My shoes are too tight, and I have forgotten how to dance."></textarea> </
div> <input type="submit" value="Send Request"> </form> Our <form> contains one <input> of type email for the user's e-mail address, a <textarea> to enter their messa...
<input>: The Input (Form Input) element - HTML: Hypertext Markup Language
step numeric types Incremental values that are valid. type all Type of form control value all Current value of the form control. Submitted with the form as part of a name/value pair. width image Same as width attribute for <img> A few additional non-standard attributes are listed following the descriptions of the standard attributes. In
dividual attributes accept Valid for the file input type only, the accept attribute defines which file types are selectable in a file upload control. See the file input type. alt Valid for the image button only, the alt attribute provides alternative text for the image, displaying the value of the attribute if the image src is missing or otherwise fails to load. See the image input type. ...
... color: blue; } Only the subset of CSS properties that apply to the ::first-line pseudo-element can be used in a rule using ::placeholder in its selector. appearance The appearance property enables the displaying of (almost) any element as a platform-native style based on the operating system's theme as well as the removal of any platform-native styling with the none value. You could make a <
div> look like a radio button with
div {appearance: radio;} or a radio look like a checkbox with [type="checkbox] {appearance: checkbox;}, but don't. Setting appearance: none removes platform native borders, but not functionality. caret-color A property specific to text entry-related elements is the CSS caret-color property, which lets you set the color used to draw the text input caret: HTML <l...
...sers to click on or touch. By pairing a <label> with an <input>, clicking on either one will focus the <input>. If you use plain text to "label" your input, this won't happen. Having the prompt part of the activation area for the input is helpful for people with motor control conditions. As web developers, it's important that we never assume that people will know all the things that we know. The
diversity of people using the web--and by extension your web site--practically guarantees that some of your site's visitors will have some variation in thought processes and/or circumstances that leads them to interpret your forms very differently from you without clear and properly-presented labels. Placeholders are not accessible The placeholder attribute lets you specify a text that appears with...
<kbd>: The Keyboard Input element - HTML: Hypertext Markup Language
though the user's preferences may potentially override your CSS. ...
... Note: You don't need to do all this wrapping; you can choose to simplify it by leaving out the external <kbd> element. In other words, simplifying this to just <kbd>Ctrl</kbd>+<kbd>N</kbd> would be perfectly valid. ...
...th <kbd> and <samp>, indicating an input which is selected from a screen widget. Result Specifications Specification Status Comment HTML Living StandardThe definition of '<kbd>' in that specification. Living Standard HTML5The definition of '<kbd>' in that specification. Recommendation Expanded to include any user input, like voice input and in
dividual keystrokes. HTML 4.01 SpecificationThe definition of '<kbd>' in that specification. Recommendation ...
<menu> - HTML: Hypertext Markup Language
mand or option the user can utilize), or (if there are no <li> elements), flow content describing the available commands and options. This element was deprecated in HTML4, but reintroduced in HTML5.1 and the HTML living standard. This document describes the current Firefox implementation. Type 'list' is likely to change to 'toolbar' according to HTML5.1. ...
...or (if there are no <li> elements), flow content describing the available commands and options. This element was deprecated in HTML4, but reintroduced in HTML5.1 and the HTML living standard. This document describes the current Firefox implementation. Type 'list' is likely to change to 'toolbar' according to HTML5.1. ...
...nds and options. This element was deprecated in HTML4, but reintroduced in HTML5.1 and the HTML living standard. This document describes the current Firefox implementation. Type 'list' is likely to change to 'toolbar' according to HTML5.1. Examples Context menu HTML <!-- A <
div> element with a context menu --> <
div contextmenu="popup-menu"> Right-click to see the adjusted context menu </
div> <menu type="context" id="popup-menu"> <menuitem>Action</menuitem> <menuitem>Another action</menuitem> <hr/> <menuitem>Separated action</menuitem> </menu> CSS
div { width: 300px; height: 80px; background-color: lightgreen; } Result Menu button Menu buttons haven't been implemented in any known browsers yet. The type attribute on the <menu> element is now obsolete. <men...
<tr>: The Table Row element - HTML: Hypertext Markup Language
ed attributes The following attributes may still be implemented in browsers but are no longer part of the HTML specification and may be missing or may not work as expected. They should be avoided. alignObsolete since HTML5 A DOMString which specifies how the cell's context should be aligned horizontally within the cells in the row; this is shorthand for using align on every cell in the row in
dividually. Possible values are: left Align the content of each cell at its left edge. center Center the contents of each cell between their left and right edges. right Align the content of each cell at its right edge. justify Widen whitespaces within the text of each cell so that the text fills the full width of each cell (full justification). char Align each cell in the row on...
...me string you would specify for the char property, such as text-align: ".". charoffObsolete since HTML5 A DOMString indicating the number of characters on the tail end of the column's data should be displayed after the alignment character specified by the char attribute. For example, when displaying money values for currencies that use hundredths of a unit (such as the dollar, which is
divided into 100 cents), you would typically specify a value of 2, so that in tandem with char being set to ".", the values in a column would be cleanly aligned on the decimal points, with the number of cents properly displayed to the right of the decimal point. This attribute is obsolete, and was never widely supported anyway. valignObsolete since HTML5 A DOMString specifying the vert...
... table { border: 1px solid black; font: 16px "Open Sans", Helvetica, Arial, sans-serif; } thead > tr { background-color: rgb(228, 240, 245); } th, td { border: 1px solid black; padding:4px 6px; } While we add a font property to the <table> element here to set a more visually-appealing typeface (or an an abominable sans-serif typeface, depending on your personal ...
itemscope - HTML: Hypertext Markup Language
e an itemscope attribute specified. An itemscope element that does not have an associated itemtype must have an associated itemref. Note: Find more about itemtype attributes at http://schema.org/Thing Simple example HTML The following example specifies the itemscope attribute. The example specifies the itemtype as "http://schema.org/Movie", and specifies three related itemprop attributes. <
div itemscope itemtype="http://schema.org/Movie"> <h1 itemprop="name">Avatar</h1> <span>Director: <span itemprop="director">James Cameron</span> (born August 16, 1954)</span> <span itemprop="genre">Science fiction</span> <a href="https://youtu.be/0AY1XIkX7bY" itemprop="trailer">Trailer</a> </
div> Structured data The following table shows the structured data from the preceding example. ...
...tems found on pages across the Web. Example There are four itemscope attributes in the following example. Each itemscope attribute sets the scope of its corresponding itemtype attribute. The itemtypes, Recipe, AggregateRating, and NutritionInformation in the following example are part of the schema.org structured data for a recipe, as specified by the first itemtype, http://schema.org/Recipe. ...
...p="servingSize">1 medium slice</span><br> Calories per serving: <span itemprop="calories">250 cal</span><br> Fat per serving: <span itemprop="fatContent">12 g</span><br> </span> <p> Ingredients:<br> <span itemprop="recipeIngredient">Thinly-sliced apples: 6 cups<br></span> <span itemprop="recipeIngredient">White sugar: 3/4 cup<br></span> ... </p> Directions: <br> <
div itemprop="recipeInstructions"> 1. Cut and peel apples<br> 2. Mix sugar and cinnamon. Use additional sugar for tart apples. <br> ... </
div> </
div> Results HTML The following is an example rendering of the preceding code example. Structured data itemscope itemtype Recipe itemprop name Grandma's Holiday Apple Pie itemprop image https:...
Microdata - HTML: Hypertext Markup Language
itemtype associated with it. itemtype is a valid URL of a vocabulary (such as schema.org) that describes the item and its properties context. itemtype - Specifies the URL of the vocabulary that will be used to define itemprop's (item properties) in the data structure. Itemscope is used to set the scope of where in the data structure the vocabulary set by itemtype will be active. ...
...structure. Itemscope is used to set the scope of where in the data structure the vocabulary set by itemtype will be active. ...
... <span itemprop="name">Angry Birds</span> - REQUIRES <span itemprop="operatingSystem">ANDROID</span><br> <link itemprop="applicationCategory" href="http://schema.org/GameApplication"/> <
div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> RATING: <span itemprop="ratingValue">4.6</span> ( <span itemprop="ratingCount">8864</span> ratings ) </
div> <
div itemprop="offers" itemscope itemtype="http://schema.org/Offer"> Price: $<span itemprop="price">1.00</span> <meta itemprop="priceCurrency" content="USD" /> </
div> </
div> Structured data itemscope itemtype SoftwareApplication (http://schema.org/SoftwareApplication) itemprop name Angry Birds itemprop operatingSystem ANDROID ...
CSP: style-src - HTTP
't load: <link href="https://not-example.com/styles/main.css" rel="stylesheet" type="text/css" /> <style> #inline-style { background: red; } </style> <style> @import url("https://not-example.com/styles/print.css") print; </style> as well as styles loaded using the Link header: Link: <https://not-example.com/styles/stylesheet.css>;rel=stylesheet Inline style attributes are also blocked: <
div style="display:none">Foo</
div> As well as styles that are applied in JavaScript by setting the style attribute directly, or by setting cssText: document.querySelector('
div').setAttribute('style', 'display:none;'); document.querySelector('
div').style.cssText = 'display:none;'; However, styles properties that are set directly on the element's style property will not be blocked, allowing users to...
... Unsafe inline styles Note: Disallowing inline styles and inline scripts is one of the biggest security wins CSP provides. ...
...re a few mechanisms that will allow them. To allow inline styles, 'unsafe-inline', a nonce-source or a hash-source that matches the inline block can be specified. Content-Security-Policy: style-src 'unsafe-inline'; The above Content Security Policy will allow inline styles like the <style> element, and the style attribute on any element: <style> #inline-style { background: red; } </style> <
div style="display:none">Foo</
div> You can use a nonce-source to only allow specific inline style blocks: Content-Security-Policy: style-src 'nonce-2726c7f26c' You will have to set the same nonce on the <style> element: <style nonce="2726c7f26c"> #inline-style { background: red; } </style> Alternatively, you can create hashes from your inline styles. CSP supports sha256, sha384 and sha512. Con...
Introduction - JavaScript
he Internet. JavaScript Guide (this guide) provides an overview about the JavaScript language and its objects. JavaScript Reference provides detailed reference material for JavaScript. If you are new to JavaScript, start with the articles in the learning area and the JavaScript Guide. Once you have a firm grasp of the fundamentals, you can use the JavaScript Reference to get more details on in
dividual objects and statements. What is JavaScript? JavaScript is a cross-platform, object-oriented scripting language used to make webpages interactive (e.g., having complex animations, clickable buttons, popup menus, etc.). There are also more advanced server side versions of JavaScript such as Node.js, which allow you to add more functionality to a website than simply downloading files (such a...
... In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for in
dividual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods. JavaScript is a very free-form language compared to Java. You do not have to declare all variables, classes, and methods. You do not have to be concerned with whether methods are public, private, or protected, and you do not ha...
...ider audience because of their easier syntax, specialized built-in functionality, and minimal requirements for object creation. JavaScript compared to Java JavaScript Java Object-oriented. No distinction between types of objects. Inheritance is through the prototype mechanism, and properties and methods can be added to any object dynamically. Class-based. Objects are
divided into classes and instances with all inheritance through the class hierarchy. Classes and instances cannot have properties or methods added dynamically. Variable data types are not declared (dynamic typing, loosely typed). Variable data types must be declared (static typing, strongly typed). Cannot automatically write to hard disk. Can automatically write to hard disk. ...
Promise - JavaScript
ng like XHR or an HTML5 API. setTimeout( function() { resolve("Success!") // Yay! Everything went well! }, 250) }) myFirstPromise.then((successMessage) => { // successMessage is whatever we passed in the resolve(...) function above. // It doesn't have to be a string, but if it is only a succeed message, it probably will be. console.log("Yay! " + successMessage) }); Example with
diverse situations This example shows
diverse techniques for using Promise capabilities, and
diverse situations that can occur. To understand this, start by scrolling to the bottom of the code block, and examine the promise chain. Upon provision of an initial promise, a chain of promises can follow. The chain is composed of .then() calls, and typically (but not necessarily) has a single .catch() at ...
...The testPromise() method is called each time the <button> is clicked. It creates a promise that will be fulfilled, using window.setTimeout(), to the promise count (number starting from 1) every 1-3 seconds, at random. The Promise() constructor is used to create the promise. The fulfillment of the promise is simply logged, vi...
...The testPromise() method is called each time the <button> is clicked. It creates a promise that will be fulfilled, using window.setTimeout(), to the promise count (number starting from 1) every 1-3 seconds, at random. The Promise() constructor is used to create the promise. The fulfillment of the promise is simply logged, via a fulfill cal...
MathML element reference - MathML
lement) A <maction> (Binded actions to sub-expressions) <maligngroup> (Alignment group) <malignmark> (Alignment points) E <menclose> (Enclosed contents) <merror> (Enclosed syntax error messages) F <mfenced> (Parentheses) <mfrac> (Fraction) G <mglyph> (Displaying non-standard symbols) I <mi> (Identifier) L <mlabeledtr> (Labeled row in a table or a matrix) <mlong
div> (Long
division notation) M <mmultiscripts> (Prescripts and tensor indices) N <mn> (Number) O <mo> (Operator) <mover> (Overscript) P <mpadded> (Space around content) <mphantom> (Invisible content with reserved space) R <mroot> (Radical with specified index) <mrow> (Grouped sub-expressions) S <ms> (String literal) <mscarries> (Annotations such as carries) <mscarr...
...Number) O <mo> (Operator) <mover> (Overscript) P <mpadded> (Space around content) <mphantom> (Invisible content with reserved space) R <mroot> (Radical with specified index) <mrow> (Grouped sub-expressions) S <ms> (String literal) <mscarries> (Annotations such as carries) <mscarry> (Single carry, child element of <mscarries>) <msgroup> (Grouped rows of <mstack> and <mlong
div> elements) <msline> (Horizontal lines inside <mstack> elements) <mspace> (Space) <msqrt> (Square root without an index) <msrow> (Rows in <mstack> elements) <mstack> (Stacked alignment) <mstyle> (Style change) <msub> (Subscript) <msup> (Superscript) <msubsup> (Subscript-superscript pair) T <mtable> (Table or matrix) <mtd> (Cell in a table or a matrix) <mtext> (Text) <mtr> (Row in ...
... <mn> <mo> <ms> <mspace> <mtext> General layout <menclose> <merror> <mfenced> <mfrac> <mpadded> <mphantom> <mroot> <mrow> <msqrt> <mstyle> Script and limit elements <mmultiscripts> <mover> <mprescripts> <msub> <msubsup> <msup> <munder> <munderover> <none> Tabular math <maligngroup> <malignmark> <mlabeledtr> <mtable> <mtd> <mtr> Elementary math <mlong
div> <mscarries> <mscarry> <msgroup> <msline> <msrow> <mstack> Uncategorized elements <maction> Semantic annotations <annotation> <annotation-xml> <semantics> ...
Media - Progressive web apps (PWAs)
edia type. To specify rules that are specific to a type of media, use @media followed by the media type, followed by curly braces that enclose the rules. Example A document on a website has a navigation area that contains the primary site menu. In the markup language, the navigation area's parent element has the id nav-area. (In HTML5, this can be marked up with the <nav> element instead of <
div> with an id attribute.) When printing the document, the navigation area has no purpose. This CSS (below) removes the navigation area when printing the document: @media print { #nav-area {display: none;} } Some common media types are: screen Color device display print Printed paged media projection Projected display all All media (the defau...
...r Indicating a link wait Indicating that the program cannot accept input progress Indicating that the program is working, but can still accept input default The default (usually an arrow) An outline property creates an outline that is often used to indicate keyboard focus. Its values are similar to the border property, except that you cannot specify in
dividual sides. Some other features of user interfaces are implemented using attributes, in the normal way. For example, an element that is disabled or read-only has the disabled attribute or the readonly attribute. Selectors can specify these attributes like any other attributes, by using square brackets: [disabled] or [readonly]. Example These rules specify styles for a button that changes dyna...
...uldn not work in other browsers. See issue on css3-page. Make a new HTML document, doc4.html. Copy and paste the content from here: <!DOCTYPE html> <html> <head> <title>Print sample</title> <link rel="stylesheet" href="style4.css"> </head> <body> <h1>Section A</h1> <p>This is the first section...</p> <h1>Section B</h1> <p>This is the second section...</p> <
div id="print-head"> Heading for paged media </
div> <
div id="print-foot"> Page: </
div> </body> </html> Make a new stylesheet, style4.css. Copy and paste the content from here: /*** Print sample ***/ /* defaults for screen */ #print-head, #print-foot { display: none; } /* print only */ @media print { h1 { page-break-before: always; padding-top: 2em; } h1:fi...
x - SVG: Scalable Vector Graphics
property for <svg>. text For <text>, if it contain a single value, x defines the x coordinate on where the content text position must be placed. The content text position is usualy a point on the baseline of the first line of text. The exact content text position is influenced by some properties like text-anchor, or direction. If there are multiple values, x defines the x coordinate of each in
dividual glyph from the text. If there are less values than glyphes, the remaining glyphes are placed in the continuity of the last positioned glyph. If there are more values than glyphes, extra values are ignored. Value List of (<length> | <percentage>) Default value 0 Animatable Yes Example html,body,svg { height:100% } <svg viewBox="0 0 200 100" xmln...
...ted and shouldn't be used. For <tref>, if it contain a single value, x defines the x coordinate on where the content text position must be placed. The content text position is usualy a point on the baseline of the first line of text. The exact content text position is influenced by some properties like text-anchor, or direction. If there are multiple values, x defines the x coordinate of each in
dividual glyph from the text. If there are less values than glyphes, the remaining glyphes are placed in the continuity of the last positioned glyph. If there are more values than glyphes, extra values are ignored. Value List of (<length> | <percentage>) Default value 0 Animatable Yes tspan For <tspan>, if it contain a single value, x defines the x coordin...
...table Yes tspan For <tspan>, if it contain a single value, x defines the x coordinate on where the content text position must be placed. The content text position is usualy a point on the baseline of the first line of text. The exact content text position is influenced by some properties like text-anchor, or direction. If there are multiple values, x defines the x coordinate of each in
dividual glyph from the text. If there are less values than glyphes, the remaining glyphes are placed in the continuity of the last positioned glyph. If there are more values than glyphes, extra values are ignored. Value List of (<length> | <percentage>) Default value none Animatable Yes Example html,body,svg { height:100% } <svg viewBox="0 0 200 100" x...
y - SVG: Scalable Vector Graphics
property for <svg>. text For <text>, if it contain a single value, y defines the y coordinate on where the content text position must be placed. The content text position is usualy a point on the baseline of the first line of text. The exact content text position is influenced by some properties like text-anchor, or direction. If there are multiple values, y defines the y coordinate of each in
dividual glyph from the text. If there are less values than glyphes, the remaining glyphes are placed in the continuity of the last positioned glyph. If there are more values than glyphes, extra values are ignored. Value List of (<length> | <percentage>) Default value 0 Animatable Yes Example html,body,svg { height:100% } <svg viewBox="0 0 200 100" xmln...
...ted and shouldn't be used. For <tref>, if it contain a single value, y defines the y coordinate on where the content text position must be placed. The content text position is usualy a point on the baseline of the first line of text. The exact content text position is influenced by some properties like text-anchor, or direction. If there are multiple values, y defines the y coordinate of each in
dividual glyph from the text. If there are less values than glyphes, the remaining glyphes are placed in the continuity of the last positioned glyph. If there are more values than glyphes, extra values are ignored. Value List of (<length> | <percentage>) Default value 0 Animatable Yes tspan For <tspan>, if it contain a single value, y defines the y coordin...
...table Yes tspan For <tspan>, if it contain a single value, y defines the y coordinate on where the content text position must be placed. The content text position is usualy a point on the baseline of the first line of text. The exact content text position is influenced by some properties like text-anchor, or direction. If there are multiple values, y defines the y coordinate of each in
dividual glyph from the text. If there are less values than glyphes, the remaining glyphes are placed in the continuity of the last positioned glyph. If there are more values than glyphes, extra values are ignored. Value List of (<length> | <percentage>) Default value none Animatable Yes Example html,body,svg { height:100% } <svg viewBox="0 0 200 100" x...
<foreignObject> - SVG: Scalable Vector Graphics
The <foreignObject> SVG element includes elements from a different XML namespace. In the context of a browser, it is most likely (X)HTML. ...
... Value type: <length>|<percentage> ; Default value: auto; ...
... Value type: <length>|<percentage> ; Default value: auto; Animatable: yes width The width of the foreignObject. ...
Tutorials
. This module provides a gentle beginning to your path towards CSS mastery with the basics of how it works, what the syntax looks like, and how you can start using it to add styling to HTML. CSS building blocks This module carries on where CSS first steps left off -- now you've gained familiarity with the language and its syntax, and got some basic experience with using it, its time to
dive a bit deeper. This module looks at the cascade and inheritance, all the selector types we have available, units, sizing, styling backgrounds and borders, debugging, and lots more. The aim here is to provide you with a toolkit for writing competent CSS and help you understand all the essential theory, before moving on to more specific disciplines like text styling and CSS layout. Styling tex...
...ommon questions and answers for beginners. Intermediate level CSS layout At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so can now
dive deep into CSS layout, looking at different display settings, traditional layout methods involving float and positioning, and new fangled layout tools like flexbox. CSS reference Complete reference to CSS, with details on support by Firefox and other browsers. Fluid Grids Design layouts that fluidly resize with the browser window, while still using a typographic grid. CSS Challenges F...
...kly and properly, and for JavaScript programmers who want to deepen their skills and/or look up specific topics. Essential JavaScript Design Patterns An introduction to essential JavaScript design patterns. Advanced level JavaScript Guide A comprehensive, regularly updated guide to JavaScript for all levels of learning from beginner to advanced. You Don't Know JS A series of books
diving deep into the core mechanisms of the JavaScript language. JavaScript Garden Documentation of the most quirky parts of JavaScript. Exploring ES6 Reliable and in-depth information on ECMAScript 2015. JavaScript Patterns A JavaScript pattern and antipattern collection that covers function patterns, jQuery patterns, jQuery plugin patterns, design patterns, general patterns, literals an...
Introduction to using XPath in JavaScript - XPath
ment. This adapter works like the DOM Level 3 method lookupNamespaceURI on nodes in resolving the namespaceURI from a given prefix using the current information available in the node's hierarchy at the time lookupNamespaceURI is called. Also correctly resolves the implicit xml prefix. Specifying the Return Type The returned variable xpathResult from document.evaluate can either be composed of in
dividual nodes (simple types), or a collection of nodes (node-set types). Simple Types When the desired result type in resultType is specified as either: NUMBER_TYPE - a double STRING_TYPE - a string BOOLEAN_TYPE - a boolean We obtain the returned value of the expression by accessing the following properties respectively of the XPathResult object. numberValue stringValue booleanValue ...
... Note however, that if the document is mutated (the document tree is modified) between iterations that will invalidate the iteration and the invalidIteratorState property of XPathResult is set to true, and a NS_ERROR_DOM_INVALI...
...rst Nodes Iterators When the specified result type in the resultType parameter is either: UNORDERED_NODE_ITERATOR_TYPE ORDERED_NODE_ITERATOR_TYPE The XPathResult object returned is a node-set of matched nodes which will behave as an iterator, allowing us to access the in
dividual nodes contained by using the iterateNext() method of the XPathResult. Once we have iterated over all of the in
dividual matched nodes, iterateNext() will return null. Note however, that if the document is mutated (the document tree is modified) between iterations that will invalidate the iteration and the invalidIteratorState property of XPathResult is set to true, and a NS_ERROR_DOM_INVALID_STATE_ERR exception is thrown. Iterator Example var iterator = document.evaluate('//phoneNumber', documentNode, null...
passwords - Archive of obsolete content
n "action" attribute, this property should match the url property. usernameField The value of the "name" attribute for the form's username field. passwordField The value of the "name" attribute for the form's password field. ...
..., this property should match the url property. usernameField The value of the "name" attribute for the form's username field. passwordField The value of the "name" attribute for the form's password field. ...
content/mod - Archive of obsolete content
Experimental Provides functions to modify a page content. Globals Constructors Functions attachTo(modification, window) Function applies given modification to a given window. For example, the following code applies a style to a content window, adding a border to all
divs in page: var attachTo = require("sdk/content/mod").attachTo; var Style = require("sdk/stylesheet/style").Style; var style = Style({ source: "
div { border: 4px solid gray }" }); // assuming window points to the content page we want to modify attachTo(style, window); Parameters modification : object The modification we want to apply to the target. window : nsIDOMWindow The window to be modified. detachFrom(modification, window) Function removes attached modification from a given window. If window is not sp...
...t The modification we want to apply to the target. window : nsIDOMWindow The window to be modified. detachFrom(modification, window) Function removes attached modification from a given window. If window is not specified, modification is removed from all the windows it's being attached to. For example, the following code applies and removes a style to a content window, adding a border to all
divs in page: var { attachTo, detachFrom } = require("sdk/content/mod"); var Style = require("sdk/stylesheet/style").Style; var style = Style({ source: "
div { border: 4px solid gray }" }); // assuming window points to the content page we want to modify attachTo(style, window); // ... detachFrom(style, window); Parameters modification : object The modification we want to remove from the target...
places/bookmarks - Archive of obsolete content
k group lives under. index The index of the bookmark group within its group. updated A Unix timestamp indicating when the bookmark was last updated on the platform. PlacesEmitter The PlacesEmitter is not exported from the module, but returned from the save and search functions. The PlacesEmitter inherits from event/target, and emits data, error, and end. data events are emitted for every in
dividual operation (such as: each item saved, or each item found by a search query), whereas end events are emitted as the aggregate of an operation, passing an array of objects into the handler. Events data The data event is emitted when a bookmark item that was passed into the save method has been saved to the platform. This includes implicit saves that are dependencies of the explicit items sav...
... let { search } = require("sdk/places/bookmarks"); search({ query: "firefox" }).on("data", function (item) { // each bookmark item that matches the query will // be called in this function }); Arguments Bookmark|Group|Separator : For the save function, this is the saved, latest snapshot of the bookmark item. For search, this is a snapshot of a bookmark retur...
Miscellaneous - Archive of obsolete content
le method to restart the application. Example for Firefox: Services.startup.quit(Services.startup.eForceQuit|Services.startup.eRestart); Mouse and keyboard Detecting mouse wheel events When scrolling the mouse wheel on an element, the DOMMouseScroll event fires. event.detail contains the number of lines to scroll. This event is Mozilla-only; other browsers may support window.onmousewheel. <
div id="scrollArea" style="overflow: scroll; height: 6em; width: 10em;"> This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. ...
...: scroll; height: 6em; width: 10em;"> This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. This is the scrolling area. ...
Creating custom Firefox extensions with the Mozilla build system - Archive of obsolete content
e with all the chrome files listed in jar.mn as well as a complete directory structure mirroring that of the JAR file. The directory structure, however, is empty. Why? I don't know. Don't worry about this, the files in the JAR are the ones that are actually used. Keeping it Complex If you're developing a really complex extension with lots of XPCOM components, you'll probably want to
divide your code up into smaller modules. Kinda, Sorta Complex Extensions For a moderately complex extension, it's probably enough just to sub
divide the code into a single level of modules. Let's assume that you have a base/ module that defines a bunch of basic XPCOM components and an advanced/ module that defines some chrome as well as other components that use the basic components. Yo...
...The difference between having separate modules and having a single module with separate submodules is that the submodules all share the same file for registering components (the famous myExtension.cpp file), and when compiled they create a single dynamic library. The decision to split a module into submodules is all about code organization; it doesn't really affect ...
Enhanced Extension Installation - Archive of obsolete content
s file in the profile location, the file paths are now absolute. <profile>/extensions.rdf -visible items This file contains non-startup and compatibility metadata for extensions that are visible to the user, whether they are enabled or disabled. If an extension is installed at two different Install Locations, the one with the higher importance is what is shown in this file. This replaces the in
dividual Extensions.rdf files at the old locations. <profile>/extensions-startup.manifest -all items This file contains a tab delimited set of lines, one per item. This is a list of all installed items, disabled or not, keyed first by Install Location name, then by GUID. The following information is stored for each entry: the persistent descriptor of the path where the item lives. the last m...
...alled flag and sets the toBeInstalled flag to trigger the item's files to be replaced from the staged XPI. When an item's files are extracted, a special extraction routine known as a safeInstallOperation is performed. This function moves the existing item's folder to {GUID}-trash file-by-file, while maintaining a list of the files that are moved. If at any point during this move the move of an in
dividual file fails, the process rolls back and the install is aborted. The extraction operation then proceeds into the now-clean {GUID} folder. If this operation fails, the entire operation is rolled back. At the end of the process once everything has succeeded the {GUID}-trash folder is removed. Uninstallation If an item is uninstalled via the UI (and has a toBeUninstalled flag set, its data is r...
Appendix: What you should know about open-source software licenses - Archive of obsolete content
author is granting users the use of the work in the strong, authorial sense, and when I write "use" in the rest of this document it is generally in that sense. These conditions will vary from one license to the next, but the Open Source Definition stipulates the following minimum conditions: The integrity of the author's source code must be preserved; No discrimination may be made against in
dividuals or organizations; No discrimination may be made based on field of endeavor; No additional licensing can be required when redistributing; License must not be specific to a product; License must not interfere with other software. The "No discrimination may be made against in
dividuals or organizations" rule means that you cannot prohibit it from any particular country. The "No discrimina...
... to an existing project, you need to familiarize yourself with that project's procedure for submitting modified code. Let's consider the case where you've discovered a bug in some OSS code. You don't just want to patch the instance of the program you're running, you want to publish the patch to benefit other people. And you don't want each person using that code to be forced to apply the patch in
dividually--that would be a lot of duplicated effort. Instead, you want to roll the patch into the source code being maintained by the OSS project team. But the team may not permit just anyone to contribute additional code whenever they want--if they did, then viruses and back-doors could wind up being distributed in the official version. So OSS gives you the freedom to duplicate, distribute, and m...
Chapter 3: Introduction to XUL—How to build a more intuitive UI - Archive of obsolete content
ton" results in a special button that combines features of both a normal toolbar button and one with type="menu", so that clicking the button itself does issue a command event. This is the type of button used for the Back and Forward buttons. Input Controls XUL includes a number of input control elements that are very similar to HTML's form-related elements. Labels Use the label element for in
dividual text labels, such as descriptive text. The value of the value attribute is the text that will be displayed. The control attribute takes as its value an id reference to another XUL element with that id; clicking that label or giving it focus can be used to pass the focus to the referenced XUL element. This can also be used to display longer chunks of text. If you want to insert long strings ...
...e elements in it are layered over each other, working from the bottom up. Listing 21 shows an example of a thermometer-style progress bar, with its output shown in Figure 17. <stack> <progressmeter mode="normal" value="50"/> <hbox align="center"> <label value="In progress..."/> </hbox> </stack> Listing 21: Overlapping with stack Figure 17: Progress Bar tab Use the tab element to
divide multiple pages, as used in the Properties dialog; use the tabbox element to group related elements. This is demonstrated in Listing 22, with its output shown in Figure 18. <tabbox> <tabs> <tab label="tab1"/> <tab label="tab2" selected="true"/> </tabs> <tabpanels> <tabpanel> <checkbox label="check1"/> </tabpanel> <tabpanel orient="vertical"> <checkbox labe...
JavaScript Object Management - Archive of obsolete content
r instance, then SgtPepper would be a good namespace name. /** * <Namespace> namespace. */ if (typeof <Namespace> == "undefined") { var <Namespace> = {}; }; Note: The naming standard that we normally follow is that the first part of the namespace corresponds to the development group (or company), and the second to the specific project. However, most extensions are small projects by in
dividuals, so these examples follow a more practical approach of having just one namespace with the project name. Notice how the <Namespace> namespace is declared using var. We need the namespace to be a global object that it can be used everywhere in the window chrome. You can include functions in any namespace, since namespaces are just regular JS objects. That should come in handy when you hav...
...cated. For instance, you could replace a method in any object in the Firefox chrome, so that it behaves differently than how it normally does. This should be a last resort option, but it is very useful at times. You usually need only one JS file to control a XUL window, since the code required is normally not that much. If you have complex behavior that requires too much code, look for ways to
divide it into multiple objects and files. You can include as many scripts in a XUL window as you need. To initialize your chrome objects, it's usually better to run the initialization code from the "load" event handler for the window. The load event is fired after the DOM on the window has loaded completely, but before it's displayed to the user. This allows you to manipulate and possibly change el...
Mozilla Documentation Roadmap - Archive of obsolete content
place to ask questions and have them answered by experienced developers. It also includes discussions on add-on monetization, job postings and a long list of add-on ideas waiting to be developed. The Mozilla Source Sometimes you need more than just a tutorial. There are various tricks that you can't learn anywhere, but you know that Firefox implements them in some way. In these cases you should
dive into Mozilla's source code and try to locate the code you need. One way to do this is to look into your Firefox installation directory, maybe unpack a few JARs and see what's inside. But this is very awkward and limited. It would be much better to be able to search and navigate through the huge code base with some ease. Luckily, Mozilla provides exactly that in the Mozilla Cross-Reference. The ...
...he people that have the answers. You'll need an IRC client in order to do this, and the Chatzilla extension works well for this purpose. Problems using IRC include: finding help when you have a big timezone difference with the United States, and no records of previously asked questions and their answers. Another somewhat obscure communication channel is the Mozilla Newsgroups. They are also very
diverse and active, and there's a good chance you'll get your queries answered. Thunderbird also comes in handy for reading and posting to the newsgroups. Another advantage is that discussions are archived and searchable through Google Groups. Other And finally, a couple resources you should also keep in mind: Other extensions. There are thousands of extensions out there, and you may strike luck...
The Box Model - Archive of obsolete content
lity. Most of the examples shown in the rest of this section were generated using the XUL Box Alignment Example. We recommend you play around with it for a while to get an idea of how the basic parts of the box model work. In order to use this page, you'll need to install the Remote XUL Manager extension and add developer.mozilla.org to the whitelist. Boxes A XUL box is very similar to an HTML
div. It's an invisible rectangular container with no styling at all (
divs may have some default styling, though). Their behavior is similar. However, one of the fundamental differences between XUL and HTML has been the fact that XUL boxes can be oriented vertically or horizontally (this behavior is being introduced into HTML standards). There are 3 basic box elements in XUL: hbox, vbox and box. An h...
... orientation of boxes (and most XUL elements) can be controlled using the orient attribute or the -moz-box-orient CSS property. With these you can make an hbox have vertical orientation and viceversa, although that isn't very useful. The CSS property may be useful on some occasions, but using the orient attribute is not recommended because it mixes content and presentation. Flexibility An HTML
div is as big as its contents unless you override its dimensions using CSS. This is similarly the case for XUL, except there are two flexibility directions to consider. An hbox is as big as its contents horizontally, but it will occupy all the available space vertically. You can make an hbox flexible horizontally with the CSS property -moz-box-flex or the flex attribute. The same applies to a vbox, b...
Tabbed browser - Archive of obsolete content
See tabbrowser for getBrowserForTab(). Note that the code above does not work inside of the Electrolysis (e10s) enabled tabs. Opening a URL in the correct window/tab There are methods available in chrome://browser/content/utilityOverlay.js that make it easy to open URL in tabs such as openUILin...
...See tabbrowser for getBrowserForTab(). Note that the code above does not work inside of the Electrolysis (e10s) enabled tabs. Opening a URL in the correct window/tab There are methods available in chrome://browser/content/utilityOverlay.js that make it easy to open URL in tabs such as openUILinkIn and openUILin...
Creating reusable content with CSS and XBL - Archive of obsolete content
mation about XBL bindings, see the XBL page in this wiki. Action: An XBL demonstration Make a new HTML document, doc6.html. Copy and paste the content from here: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> <HEAD> <TITLE>Mozilla CSS Getting Started - XBL demonstration</TITLE> <LINK rel="stylesheet" type="text/css" href="style6.css"> </HEAD> <BODY> <H1>XBL demonstration</H1> <
DIV id="square">Click Me</
DIV> </BODY> </HTML> Make a new CSS file, style6.css. This stylesheet contains the document style. Copy and paste the content from here: /*** XBL demonstration ***/ #square { -moz-binding: url("square.xbl#square"); } Make a new text file, square.xbl. This file contains the XBL binding. Copy and paste the content from here: <?xml version="1.0"?> <!DOCTYPE binding...
...ntains the XBL binding. ...
MCD, Mission Control Desktop, AKA AutoConfig - Archive of obsolete content
authentication. Objective The objective is to provide users with a mailer agent, a web browser, and a news reader which are automatically configured (preferences) at startup to the current user connected on the computer. Choosing Mozilla products allow us to use the same apps while running either Windows or Linux systems (I suspect MAC OSX would be fine too). Instead of configuring end user in
dividual preferences files (~/.mozilla/default/randomdir/prefs.js) we now use a centralized default set of preferences. This centralized preference file can lock preferences (lockPref) or initialize them (defaultPref) based on environment variables (USER, HOME...) and/or LDAP queries (fetch email address, Common Name , language, homepage etc...) from the enterprise directory. Central Configuration F...
...DEFAULT="wallet spellcheck xmlextras pref webservices universalcharset auth" are now present in the default configure script. See bug 295329 for details. Add the AutoConfig Option for Old Thunderbird 1.0.x By default, AutoConfig did not make part of the binaries distribution of Thunderbird (1.0.x). It was apparently supposed to increase the load of the binary for a feature not used by lots of in
dividuals. However for enterprise deployment, it is vital! So we needed to recompile Thunderbird with AutoConfig support, it's just a matter of adding --enable-extensions=pref in mozconfig file. On my Fedora Core 3 system, I took the Thunderbird source package thunderbird-1.0.2-1.3.3.src.rpm installed it (rpm -i) then modified /usr/src/redhat/SOURCES/thunderbird-mozconfig by adding: ac_add_options ...
Visualizing an audio spectrum - Archive of obsolete content
ays them in a canvas. NOTE: You can use the AudioNode called AnalyserNode to perform real-time FFT analysis on an audio stream, rather than the code shown below. ...
...called AnalyserNode to perform real-time FFT analysis on an audio stream, rather than the code shown below. ...
Getting Started - Archive of obsolete content
on as the one you use to browse the web, but if you mess it up, it is possible that you will be unable to access your browser without uninstalling and reinstalling Mozilla. For this reason we suggest that you install a second copy into a second directory (Make sure that you use a different profile as stated in the release notes) Extract the chrome The chrome is stored in \mozilla\chrome and the in
dividual modules are stored in Jar files. Jar files are zip files with a different extension. You can open them up in your zip program the same way you open up zip files. Mozilla currently comes with two skins, Classic and Modern. Looking in the directory you'll also notice that there are classic.jar and modern.jar files. For this tutorial we are going to use the Classic skin as a base. Extract class...
...mportant directory is \global. The default Widgets are defined here, and anything that is modified will change throughout Mozilla. If you want to modify how checkboxes, radio buttons, and scrollbars appear, this is the place. The next directory is the \communicator directory. This is a catchall directory which holds all of the images and styles for portions of Mozilla that don't merit their own in
dividual directory. You'll be able to change the bookmark manager and the profile migration window here. The three remaining directories are pretty self-explanatory. They contain the images/styles for the browser, email client, or html editor. CSS Files The CSS files in these directories tell the browser how to display the buttons and other controls, where to put the images, what border and padding i...
Block and Line Layout Cheat Sheet - Archive of obsolete content
ent. Objects This section presents some of the classes involved in block and line reflow, along with important members of each object that control reflow processing. nsFrame The base class for all frames. mFlags Flags set on the frame to indicate its state. These flags can be grouped into two categories: flags which affect all frames ("public" flags), and flags that are reserved for an in
dividual frame's private use ("private" flags). NS_FRAME_IN_REFLOW This bit is set when the frame is being actively being reflowed. By default it is set in WillReflow(), and unset in DidReflow(). Many frames' Reflow() method verifies that the bit is set with an assertion. NS_FRAME_FIRST_REFLOW This flag is set on a newly created frame, and later cleared by the frame's Reflow() method when the fr...
...mFrame The PerFrameData of the inline frame that "owns" the span, or null if this is the root span. mFrame is initialized to the containing inline frame's PerFrameData when a new PerSpanData is pushed in nsLineLayout::BeginSpan. Original Document Information Author(s): Chris Waterson Last Updated Date: December 4, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Content states and the style system - Archive of obsolete content
the node is by just checking whether it matches with the caveat that all the state-dependent pseudo-classes corresponding to the states that changed must be treated as matching (whether they actually do and whether they're negated or not). This is needed to catch both selectors that now match and selectors that no longer match. ...
...catch both selectors that now match and selectors that no longer match. For example, say we have the selectors: a:hover a:not(:hover)
div:hover and the hover state on some node changes. We then try matching the node against these selectors, with the assumption that both :hover and :not(:hover) match the node. So the effect will be that of matching a node against the selectors: a a
div The code that implements this is in the SelectorMatches method, which is passed the list of states that changed in the aStateMask parameter. ...
Modularization techniques - Archive of obsolete content
e mechanism for determining whether interfaces A and B are implemented by the same object.For simple objects, maintaining these behaviors is easy. Aggregation, as we will see later, can complicate things. On the other hand, objects are allowed a certain degree of flexibility in their implementations of AddRef() and Release(). They can maintain a single reference count for the entire object, or in
dividual reference counts for each interface. A static object would chose to ignore reference counts altogether. However, a poor implementation of these functions can have negative results, such as memory leaks or inadvertent access of freed objects. Factories Factories are special classes dedicated to creating instances of classes. A Foo class will typically have a FooFactory associated with it. T...
...ill be developed as needed. ...
BundleLibrary - Archive of obsolete content
ebapp (NOTE: Should work with Google Gears with some help) Rsizr Image Editor rsizr.webapp SeeqPod: seeqpod.webapp Playable music search engine. ...
...TE: Should work with Google Gears with some help) Rsizr Image Editor rsizr.webapp SeeqPod: seeqpod.webapp Playable music search engine. ...
Frequently Asked Questions - Archive of obsolete content
ase first search in the SVG component of our bug database to check that the issue hasn't already been reported. If you can't find a matching bug please file a new SVG bug report, preferably attaching a (very small!) SVG file that demonstrates the bug. If you have any problems with the bug database feel free to contact contact us. Can I use a plugin for SVG instead of Mozilla's native support? In
dividuals can choose to use a plugin to view SVG in Mozilla on their own computers, but there is no way for SVG content authors to make Mozilla use a plugin when people view the SVG files on their website. The native SVG support must be turned off before Mozilla will look to see if there's an SVG plugin installed. This is done by toggling a hidden user configuration preference (pref). To access the p...
...ou'd prefer to contact us by email you can send an email to our newsgroup mozilla.dev.tech.svg which is archived here. Alternatively you can email any of us directly of course (see the preceeding question for our email addresses). Original Document Information Author(s): Jonathan Watt Last Updated Date: November 6, 2006 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Tamarin Build System Documentation - Archive of obsolete content
The phase state is idle or active Click on the phase (e.g. Compile, Smoke, or Test to show the build slaves from the most recent phase run or Click on an ...
...ed into the phase table at the top and the waterfall table below The phase table shows all phases at the top of the page, each slave is shown as a box with a red,green, or yellow color: red means failed, green passed, and yellow has warnings. The phase state is idle or active Click on the phase (e.g. ...
A XUL Bestiary - Archive of obsolete content
ting files; chrome means the XUL content and structure, plus the CSS skin, plus whatever localization and platform-specific files are part of that XUL interface. By contrast, the skin is just the CSS and referenced graphics for a XUL file, the localization strings are just a DTD, and the content is just the XUL. The Chrome URL This concept of a chrome as an integrated, dynamic thing in some way
divorced from the "appcore" is realized in the use of the chrome URL to point to chunks of XUL and their related files. The chrome URL, which appears in place of the HTTP URL in pointers like the following global skin processing instruction: <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> Specifies a chrome to be loaded by the Gecko rendering engine. In the example above, the chrom...
...ies. Skinning is most often brought up in the context of dynamic changes to the overall look of an application. Though this is not yet in the browser, very soon it will be possible to change the look of a whole application dynamically, but only to the extent that the skin is actually defined in the main global.css, or global skin. When you create styles in <style> tags, as style attributes for in
dividual elements, or in custom CSS files, you break the ability of Gecko to skin the application to which your XUL belongs. Widgets Widgets are the pieces that you assemble to make an interface. Menus, toolbars, buttons, and scrollbars are widgets, and so are such general purpose pieces as boxes and springs. These widgets can be created and placed within a XUL file as simple elements: <menu>, <too...
treecell.editable - Archive of obsolete content
When the user double-clicks an editable cell, a text field appears in which the user can edit the contents of the cell. The tree and treecol must also be marked as editable in order for this to work. ...
...When the user double-clicks an editable cell, a text field appears in which the user can edit the contents of the cell. The tree and treecol must also be marked as editable in order for this to work. ...
MenuButtons - Archive of obsolete content
arbutton type="menu" image="cookies.png"> <menupopup> <menuitem label="Block Cookies" type="checkbox"/> <menuitem label="Clear Cookies"/> </menupopup> </toolbarbutton> The 'menu-button' button The 'menu-button' type of button is used when you want to attach a menu to a button but want to have a default action carried out when the button is pressed by itself. This is accomplished by
dividing the button into two parts, one with the label and image to carry out the default command and the second to show the menu. To create a button of this type, set the type attribute of the button to 'menu-button'. <toolbarbutton type="menu-button" label="Save" oncommand="alert('Save');"> <menupopup> <menuitem label="Save This Document"/> <menuitem label="Save All" oncommand="alert('...
...the button does not get called as well. The effect is a button that performs one command with a menu for other commands. As with this example, the 'menu-button' type of button is usually used when the menu provides more specific options pertaining to the operation. We might want to extend this example to insert a list of the unsaved documents to the Save button menu so that each could be saved in
dividually. You might want to set the first item in the example above as the default button, so it indicates to the user that the command is carried out when the main button is pressed. This can be done by setting the default attribute on the item to true. <menuitem label="Save This Document" default="true"/> See Indicating_the_Default_Item for more information about the default attribute. As wi...
Skinning XUL Files by Hand - Archive of obsolete content
s you have at least basic understanding of XUL and the Application Object Model that XUL describes. Following the instructions here, you are going to create a skin for a XUL file and apply it by specifying classes for all of the interested elements. The skin will reside in a single CSS file, appropriately named drxul.css. As you will see, CSS provides a lot of flexibility for defining styles to in
dividual elements, to classes of elements, to pseudo-classes, and to anonymous classes. By the way, in contrast to the term skin, "chrome" refers to the skin and the content and whatever localization and platform-specific files are necessary for a particular part of the application or window. The skin is just the style or appearance of an interface, where the chrome is the style, content, and struct...
... types of style definitions: Class ID element.class { attribute: value; } element#id { attribute: value; } menu.baseline { border: 0px; font-size: 9pt; } menu#edit { color: red; } Other Style Subgroups Contextualsubgroups -- elements appearing within other elements, such as italicized text anywhere within a <p> element or a <
div> -- can be grouped in CSS, but this is an extremely inefficient way to style XUL, and is frowned upon in the Mozilla development community (again, refer to the skinning guidelines in Writing Skinnable XUL and CSS for more info); CSS2 also provides some new ways to group elements for styling, which we summarize briefly here, because they appear in Mozilla with some frequency, but reserve for anoth...
Styling a Tree - Archive of obsolete content
properties="makeItBlue"> CSS Selectors for the Tree The style sheet can take this property and use it to change the appearance of the row for unread messages or labels. You can think of the properties as functioning much like style classes, although they require a somewhat more complex syntax to use in a style sheet. This is because you can specify the style for a number of parts of the cell in
dividually. You can style not only the cell and its text, but the twisty and indentation. The following is the syntax that needs to be used: treechildren::-moz-tree-row(makeItBlue) { background-color: blue; } This style which has a complex selector is used to style the background color of rows that have the 'makeItBlue' property. This special syntax is needed because the cells themselves are not...
...ies for the RDF-built Trees For RDF-built trees, you can use the same syntax. However, you will often set the properties based on values in the datasource. Setting Properties for the Custom View For trees with a custom view script, you can set properties by supplying the functions getRowProperties(), getColumnProperties() and getCellProperties() in the view. These return information about an in
dividual row, column and cell. Arguments to these functions indicate which row and/or column. Prior to Gecko 22 the last argument to each of these functions is a properties list which the view is expected to fill with a list of properties. The function getColumnProperties() also supplies the corresponding treecol element for the column. getRowProperties : function(row,prop){} getColumnProperties : ...
Tabboxes - Archive of obsolete content
n click each tab to see a different set of options. It is useful in cases when you have more options than will fit in one screen. XUL provides a method to create such dialogs. It involves five new elements, which are described briefly here and in more detail below. tabbox The outer box that contains the tabs along the top and the tab pages themselves. tabs The inner box that contains the in
dividual tabs. In other words, this is the row of tabs. tab A specific tab. Clicking on the tab brings the tab page to the front. tabpanels The container for the pages. tabpanel The body of a single page. You would place the content for a page within this element. The first tabpanel corresponds to the first tab, the second tabpanel corresponds to the second tab and so on. The tabbox is the ou...
...ns a tabpanels element which will appear below the tabs due to the vertical orientation on the whole tabbox. There is really nothing special about the tab elements that make them different than boxes. Like boxes, tabs can contain any element. The difference is that the tabs render slightly differently and only one tab panel's contents are visible at once, much like a deck. The contents of the in
dividual tab pages should go inside each tabpanel element. They do not go in the tab elements, as that is where the contents of the tabs along the top go. Each tabpanel element becomes a page on the tabbed display. The first panel corresponds to the first tab, the second panel corresponds to the second tab, and so on. There is a one-to-one relationship between the tab and tabpanel elements. When de...
The Box Model - Archive of obsolete content
Elements inside of a box will orient themselves horizontally or vertically. By combining a series of boxes, spacers and elements with flex and pack attributes, you can control the layout of a window. Although a box is the fundamental part of XUL element layout, it follows a few very simple rules. ...
...tically. The inner boxes orient their elements horizontally. As you see in the image below, the label and text input are placed side by side. The spacer and two buttons are also placed horizontally in their box. Notice how the spacer causes the buttons to appear on the right side, because it is flexible. Example so far: Source View In the next section, we will look at specifying the sizes of in
dividual elements and how to constrain their sizes. << PreviousNext >> ...
The Implementation of the Application Object Model - Archive of obsolete content
o render the widgetry, then drawing code has to be written for each and every widget. Look at the difference between the two tree widgets that exist in NGLayout today as an example. The tree widget that is extending the table code has no drawing code, and even by the time it has matched and far outstripped the capabilities of the old gfx-based tree widget, it will still CONTAIN NO DRAWING CODE. In
dividual widgets, even complex widgets like the trees and toolbars need little to no drawing code (above and beyond what NGLayout already has) in order to work. Native widgets vs. NGLayout's form element widgets. This is really another issue of code bloat. It is a given that NGLayout will ship with its own non-native form element widgets. This has to be done in order to get features like transparenc...
...r the persistent attribute, thus allowing the XUL writer to specify a default for the whole window, but to still selectively override it for certain subtrees. Note that even if the persistent attribute is set to false, that changes can still be made to a window's content tree. They simply won't be remembered across sessions. Preventing the Persistence of Attributes: The DISCARDABLE attribute In
dividual attributes can be specified as non-persistent (i.e.,discardable) through the use of the discardable attribute. For example, the open attribute used to indicate whether a node is expanded or collapsed in a tree view is something that is sometimes persistent (in the case of bookmarks) and sometimes not (in the case of mail folders). In both cases, the overall tree structure needs to be persist...
Gecko Compatibility Handbook - Archive of obsolete content
s that have optional ending tags. CSS ID's should be case-sensitive Gecko implements the case sensitivity of Class ID's correctly and will display this example correctly. However Internet Explorer treats all CSS ID's as case-insensitive and will not display this example correctly. <style type="text/css"> #id1 { text-decoration: line-through; } #ID1 { text-decoration: underline; } </style> <
div id="id1"> should be line-through </
div> <
div id="ID1"> should be underline </
div> -(EXAMPLE REMOVED)- Note that the W3C's HTML Validator will flag HTML ID attributes as duplicates if they only differ due to case. There appears to be some inconsistency between the actual HTML 4.01 Recommendation and the SGML declaration for HTML on whether ID attributes are case sensitive or not. This is unf...
...earning about the standards. Due to the common nature of this error, Netscape 6.2 began treating CSS ID attributes as case-insensitive in Quirks mode only. If you are invoking Standards mode, you should still code your CSS to be consistent with respect to case. CSS Class names should be case-sensitive <style type="text/css"> .class1 { font-size: 1em; } .CLASS1 { font-size: 2em; } </style> <
div> <
div class="class1"> should be font-size: 1em; </
div> <
div class="CLASS1"> should be font-size: 2em; </
div> -(EXAMPLE REMOVED)- Gecko implements the case sensitivity of Class names correctly and will display this example correctly while Internet Explorer treats all CSS Classnames's as case-insensitive and will not display this example correctly. Due to the common nature of this error by w...
Mozilla release FAQ - Archive of obsolete content
e distributed and modified freely. No guarantee of factuality in this FAQ is made, and it is maintained by Pat Gunn, who is not affiliated with Netscape. Various other people have contributed to this FAQ. General Questions about the Mozilla Project What is Mozilla? Mozilla is a project to continue Netscape Communicator as an open project. The project is maintained by employees of Netscape (now a
division of AOL), Red Hat, some other companies, as well as contributors from the community. On what is Mozilla based? The Mozilla project started near the end of life of the 4.x line of Netscape Communicator. Originally, the plan was just to re-stabilize the code and release 5.0, but it was decided within the community that the more ambitious changes that were planned for later integration were clos...
...s no connection between the Mozilla project and the spam. You might want to visit The Open Directory Project's spam pages to help you track down the origin. For the second case, go to The Mozilla Community section to unsubscribe Original Document Information Author(s): Pat Gunn Last Updated Date: May 28, 2005 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Introduction to Public-Key Cryptography - Archive of obsolete content
lities. Certificates and Authentication Managing Certificates Certificates and Authentication A Certificate Identifies Someone or Something Authentication Confirms an Identity How Certificates Are Used Contents of a Certificate How CA Certificates Are Used to Establish Trust A Certificate Identifies Someone or Something A certificate is an electronic document used to identify an in
dividual, a server, a company, or some other entity and to associate that identity with a public key. Like a driver's license, a passport, or other commonly used personal IDs, a certificate provides generally recognized proof of a person's identity. Public-key cryptography uses certificates to address the problem of impersonation. To get a driver's license, you typically apply to a government agency...
...ssumptions are true only if unauthorized personnel have not gained access to the user's machine or password, the password for the client software's private key database has been set, and the software is set up to request the password at reasonable frequent intervals. Neither password-based authentication nor certificate-based authentication address security issues related to physical access to in
dividual machines or passwords. Public-key cryptography can only verify that a private key used to sign some data corresponds to the public key in a certificate. It is the user's responsibility to protect a machine's physical security and to keep the private-key password secret. These are the steps shown in Figure 5: The client software, such as Communicator, maintains a database of the private k...
TCP/IP Security - Archive of obsolete content
tion-specific. For example, all network communications between two hosts or networks can be protected at this layer without modifying any applications on the clients or the servers. In some environments, network layer controls such as Internet Protocol Security (IPsec) provide a much better solution than transport or application layer controls because of the difficulties in adding controls to in
dividual applications. Network layer controls also provide a way for network administrators to enforce certain security policies. Another advantage of network layer controls is that since IP information (e.g., IP addresses) is added at this layer, the controls can protect both the data within the packets and the IP information for each packet. However, network layer controls provide less control a...
...rom all applications, as well as protecting IP information. Nevertheless, in many cases, controls at another layer are better suited to providing protection than network layer controls. For example, if only one or two applications need protection, a network layer control may be excessive. Transport layer protocols such as SSL are most commonly used to provide security for communications with in
dividual HTTP-based applications, although they are also used to provide protection for communication sessions of other types of applications such as SMTP, Point of Presence (POP), Internet Message Access Protocol (IMAP), and File Transfer Protocol (FTP). Because all major Web browsers include support for TLS, users who wish to use Web-based applications that are protected by TLS normally do not nee...
-moz-border-bottom-colors - Archive of obsolete content
, <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
... <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
-moz-border-left-colors - Archive of obsolete content
, <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
... <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
-moz-border-right-colors - Archive of obsolete content
, <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
... <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
-moz-border-top-colors - Archive of obsolete content
, <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
... <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
Back to the Server: Server-Side JavaScript On The Rise - Archive of obsolete content
ks the form to make sure it is complete, returning a boolean. The both context it operates within is a very powerful concept as we are able to use this code to check values entered in the form on both the client and server side. No custom validation libraries for each environment makes for rapid development with less risk for error. Towards the bottom of the code are two
div tags with ids form-comments and out-logger. The form-comments
div is used to render the form and the out-logger will be used as a log display as each comment is added. The completed user interface is shown in Figure 1. Figure 1 - The user interface Server-Side DOM Processing Another powerful concept of Jaxer is the ability to access the DOM server-side with Java...
...="server"> window.onserverload = function() { document.getElementById( "out-logger" ).innerHTML = Jaxer.File.read( "dump.txt" ); } </script> The code in listing 7 is executed server-side and takes advantage of the onserverload event which ensures that we have a complete DOM before trying to access it. This code is simple in that it updates the innerHTML of the logging
div with the contents of a text file. The contents of this file are obtained through the file I/O capabilities exposed by Jaxer which is what we'll examine next. File I/O Jaxer ships with a comprehensive filesystem I/O capability that is very useful. There are numerous methods in this namespace which allow for a simple, yet powerful approach to file management. The example a...
Writing JavaScript for XHTML - Archive of obsolete content
when document.write() worked. Now you can't do this as easily as before. Use DOM methods to create all of your elements, attributes and other nodes. This is XML proof, as long as you keep the namespace problem in focus (e.g., there is a document.createElementNS method). Of course, you can still use strings like in document.write(), but it takes a little more effort. ...
...as before. Use DOM methods to create all of your elements, attributes and other nodes. This is XML proof, as long as you keep the namespace problem in focus (e.g., there is a document.createElementNS method). Of course, you can still use strings like in document.write(), but it takes a little more effort. For example: var string = '<
div xmlns="http://www.w3.org/999/xhtml"><h1>Hello World!</h1></
div>'; var parser = new DOMParser(); var documentFragment = parser.parseFromString(string, "text/xml"); body.appendChild(documentFragment); // assuming 'body' is the body element But be aware that if your string is not well-formed XML (e.g., you have an & where it should not be), then this method will crash, leaving you with a parser error. Problem: I want to remain forward compatible! Given the ...
XForms Custom Controls - Archive of obsolete content
ific pieces of our implementation of output is kept in the xforms-xhtml.xml#xformswidget-output binding. If you would like to do this kind of heroic work then please contact the Mozilla XForms developers before you start. Hopefully we can help you avoid a lot of frustration and despair :). Overview The Mozilla XForms controls are largely implemented using XBL and the bindings are applied to the in
dividual xforms control tags via CSS. So you can always refer to our source code to get some great examples of how XForms controls can be written. This will also allow you to be up to date with our current approaches (often the result of hard-learned lessons) and that will hopefully help you to more easily write your own controls. To get started, you really only need to know the language where you'd ...
...<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"> <head> <title>Custom Image Control Sample</title> <bindings id="xformsBindings" xmlns="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml"> <binding id="output-image" extends="chrome://xforms/content/xforms.xml#xformswidget-base"> <content> <html:
div> <html:img anonid="content"/> </html:
div> </content> <implementation implements="nsIXFormsUIWidget"> <method name="refresh"> <body> <!-- set the src attribute on the html:img to be the simpleContent of the instance node bound to this control --> var img = document.getAnonymousElementByAttribute(this, "anonid", "...
Choosing Standards Compliance Over Proprietary Practices - Archive of obsolete content
and supports the relevant international standards. Accessibility No organization can afford to overlook or ignore accessibility standards. Within the web environment, the accessibility standards are closely tied to HTML, XML, XHTML, and other W3C standards. By integrating and supporting the accessibility guidelines, an organization can offer their product lines or services to a larger and more
diverse user base. Interchangeability If a user experiences consistent behavior across a range of products, they can predict how a particular action or function will work or respond. As a product provider, the goal should be the element of least surprise. By instilling a set of global goals and standards into an organizational infrastructure, an organization is ensuring its end users the ability to...
...or function will work or respond. As a product provider, the goal should be the element of least surprise. By instilling a set of global goals and standards into an organizational infrastructure, an organization is ensuring its end users the ability to interact, function, view, and process information consistently as they transition from one device to the next. A significant drawback in allowing
divergence across applications is that information must be replicated, altered, or massaged to be processed across the
divergent applications. This also creates issues in regard to authoring tools for these various applications. For example, let us say we have multiple application offerings that can be used to browse the web. Each of these applications has followed their own development and support s...
Windows Media in Netscape - Archive of obsolete content
but this is legacy software nowadays } if (player) { // Windows Media Player control exists and it is version 7 or 9 // Can use WMP 7 or 9 API -- call versionInfo property, only in 7 and 9 var versionString = player.versionInfo; alert(versionString); } Only GeckoActiveXObject allows for the use of the Windows Media Player classID as an argument. Since classIDs are affiliated with in
dividual ActiveX controls in a unique manner, this allows for unique instantiation of controls. Netscape 7.1 works with both Windows Media Player 6.4 and with Windows Media Players 7 and 9, but they have unique classIDs: Windows Media Player 6.4 has this classID:22D6F312-B0F6-11D0-94AB-0080C74C7E95 Windows Media Players 7 and 9 have this classID: 6BF52A52-394A-11d3-B153-00C04F79FAA6 ...
... elements. No Netscape browser prior to Netscape 7.1 has supported this non-standard way of writing scripts that handle information sent by a plugin or control. A good illustration of the use of this non-standard script element syntax is in creating closed captioning of media content. Automatic closed captioning does not work in Netscape 7.1 as it does in IE. In IE, a named HTML element such as a
DIV may be given to the Windows Media Player control and it will be automatically updated with caption data. This does not work in Gecko because it requires IE DOM functionality that has not been implemented. Fortunately, Windows Media Player also fires a ScriptCommand() event for closed captioning, which means content may update the caption manually with a small piece of JavaScript. For example, in ...
Anatomy of a video game - Game development
pret the input as a success, failure, pause, menu interaction, etc.; finally, they calculate an updated scene resulting from that input. The game loop is advanced by the user's input and sleeps until they provide it. This is more of a turn-based approach that doesn't demand a constant update every frame, only when the player reacts. Other games demand control over each of the smallest possible in
dividual timeslices. The same principles as above apply with a slight twist: each frame of animation progresses the cycle and any change in user input is caught at the first available turn. This once-per-frame model is implemented in something called a main loop. If your game loops based on time then this will be its authority that your simulations will adhere to. But it might not need per-frame con...
...in ); // Your main loop contents // tFrame, from "function main ( tFrame )", is now a DOMHighResTimeStamp provided by rAF. } main(); // Start the cycle })(); Several other optimizations are possible and it really depends on what your game attempts to accomplish. Your game genre will obviously make a difference but it could even be more subtle than that. You could draw every pixel in
dividually on a canvas or you could layer DOM elements (including multiple WebGL canvases with transparent backgrounds if you want) into a complex hierarchy. Each of these paths will lead to different opportunities and constraints. It is decision... time You will need to make hard decisions about your main loop: how to simulate the accurate progress of time. If you demand per-frame control then you...
Gecko FAQ - Gecko Redirect 1
ecko enables a pioneering new class of dynamic content that is more interactive and offers greater presentation control to Web developers, using open and recommended Internet standards instead of proprietary APIs. You are encouraged to join this team by getting involved. How does Mozilla use Gecko? Gecko lies at the heart of Mozilla and Firefox browsers, as well as others, powering all of the in
dividual components. Gecko technologies will also power the display of the mozilla.com portal site, speedily delivering more exciting content and services. Gecko's architecture will serve Mozilla well into the future, enabling faster time to market, more innovation, less costly development, easier distribution and updating, and better cross platform support. How can other companies and organizations...
...or Win32, X, and Mac User preferences library Mozilla Plug-in API (NPAPI) to support the Navigator plug-in interface Open Java Interface (OJI), with Sun Java 1.2 JVM RDF back end Font library Security library (NSS) Original Document Information Author(s): Angus Other Contributors: Ekrock, Vidur, Hidday, Drunclear Copyright Information: Portions of this content are (C) 1998-2006 by in
dividual mozilla.org contributors; content available under a Creative Commons license ...
Grid Areas - MDN Web Docs Glossary: Definitions of Web-related terms
area. In the example below I have a grid container with two grid items. I have named these with the grid-area property and then laid them out on the grid using grid-template-areas. This creates two grid areas, one covering four grid cells, the other two. ...
...ius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #ffd8a8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: 100px 100px; grid-template-areas: "a a b" "a a b"; } .item1 { grid-area: a; } .item2 { grid-area: b; } <
div class="wrapper"> <
div class="item1">Item</
div> <
div class="item2">Item</
div> </
div> Learn More Property reference grid-template-columns grid-template-rows grid-auto-rows grid-auto-columns grid-template-areas grid-area Further reading CSS Grid Layout Guide: Basic concepts of grid layout CSS Grid Layout Guide: Grid template areas Definition of Grid Areas in the CSS Grid L...
Gutters - MDN Web Docs Glossary: Definitions of Web-related terms
tracks. These can be created in CSS Grid Layout using the grid-column-gap, grid-row-gap, or grid-gap properties. In the example below we have a three-column and two-row track grid, with 20-pixel gaps between column tracks and 20px-gaps between row tracks. ...
...r-box;} .wrapper { border: 2px solid #f76707; border-radius: 5px; background-color: #fff4e6; } .wrapper >
div { border: 2px solid #ffa94d; border-radius: 5px; background-color: #fff8f8; padding: 1em; color: #d9480f; } .wrapper { display: grid; grid-template-columns: repeat(3,1.2fr); grid-auto-rows: 45%; grid-column-gap: 20px; grid-row-gap: 20px; } <
div class="wrapper"> <
div>One</
div> <
div>Two</
div> <
div>Three</
div> <
div>Four</
div> <
div>Five</
div> </
div> In terms of grid sizing, gaps act as if they were a regular grid track however nothing can be placed into the gap. The gap acts as if the grid line at that location has gained extra size, so any grid item placed after that line begins at the end of the gap. The grid-gap prop...
NaN - MDN Web Docs Glossary: Definitions of Web-related terms
NaN (Not a Number) is a numeric data type that means an undefined value or value that cannot be represented, especially results of floating-point calculations. For example, NaNs can represent infinity, result of
division by zero, missing value, or the square root of a negative (which is imaginary, whereas a floating-point number is real). Practically speaking, if I
divide two variables in a JavaScript program, the result may be NaN, which is predefined in JavaScript as "undefined". Hence this
division may break the program. ...
...is real). Practically speaking, if I
divide two variables in a JavaScript program, the result may be NaN, which is predefined in JavaScript as "undefined". Hence this
division may break the program. Now, if this computation was a small part of a much larger algorithm, it would be really painful to figure out where the error actually occurs. Fortunately, since the result will be NaN and I know my
divisor may turn out to be 0, I can set up testing conditions that prevent any such computations in the first place or notify me of where they happen. Learn more General knowledge NaN on Wikipedia Technical information NaN in JavaScript ...
Semantics - MDN Web Docs Glossary: Definitions of Web-related terms
that takes a string parameter, and returns an <li> element with that string as its textContent. Would you need to look at the code to understand what the function did if it was called build('Peach'), or createLiWithContent('Peach')? Semantics in CSS In CSS, consider styling a list with li elements representing different types of fruits. ...
...), is the sole responsibility of CSS. ...
CSS and JavaScript accessibility best practices - Learn web development
outline): You can be creative with link styles, as long as you keep giving users feedback when they interact with the links. Something should definitely happen when states change, and you shouldn't get rid of the pointer cursor or the outline -- both are very important accessibility aids for those using keyboard controls. Form elements Elements to allow users to input data into websites: <
div> <label for="name">Enter your name</label> <input type="text" id="name" name="name"> </
div> You can see some good example CSS in our form-css.html example (see it live also). Most of the CSS you'll write for forms will be for sizing the elements, lining up labels and inputs, and getting them looking neat and tidy. You shouldn't however deviate too much from the expected visual feedback for...
...t users can find out exactly what's wrong with their form submissions and get to the input elements in question by going back up to the start of the page. As a final note, we have used some WAI-ARIA attributes in our demo to help solve accessibility problems caused by areas of content constantly updating without a page reload (screen readers won't pick this up or alert users to it by default): <
div class="errors" role="alert" aria-relevant="all"> <ul> </ul> </
div> We will explain these attributes in our next article, which covers WAI-ARIA in much more detail. Note: Some of you will probably be thinking about that fact that HTML5 forms have built-in validation mechanisms like the required, min/minlength, and max/maxlength attributes (see the <input> element reference for more informat...
Type, class, and ID selectors - Learn web development
appended using a dot, with no white space in between. This approach reduces the scope of a rule as the rule will only apply to that particular element & class combination; so you would need to add another selector if you decided the rule should apply to other elements too. Target an element if it has more than one class applied You can apply multiple classes to an element and target them in
dividually, or only select the element when all of the classes in the selector are present. This can be helpful when building up components that can be combined in different ways on your site. In the example below we have a <
div> that contains a note. The grey border is applied when the box has a class of notebox. If it also has a class of warning or danger, we change the border-color. We can tell ...
... ID Selectors An ID selector begins with a # rather than a full stop character, but is basically used in the same way as a class selector. ...
Normal Flow - Learn web development
ow is designed to make a readable document, by starting in this way you are working with the document rather than fighting against it as you make changes to the layout. Before digging deeper into different layout methods, it is worth revisiting some of the things you will have studied in previous modules with regard to normal document flow. How are elements laid out by default? First of all, in
dividual element boxes are laid out by taking the elements' content, then adding any padding, border and margin around them -- it's that box model thing again, which we've looked at earlier. By default, a block level element's content is 100% of the width of its parent element, and as tall as its content. Inline elements are as tall as their content, and as wide as their content. You can't set width...
...s tall as their content, and as wide as their content. You can't set width or height on inline elements -- they just sit inside the content of block level elements. If you want to control the size of an inline element in this manner, you need to set it to behave like a block level element with display: block; (or even,display: inline-block; which mixes characteristics from both.) That explains in
dividual elements, but what about how elements interact with one another? The normal layout flow (mentioned in the layout introduction article) is the system by which elements are placed inside the browser's viewport. By default, block-level elements are laid out in the block flow direction, based on the parent's writing mode (initial: horizontal-tb) -- each one will appear on a new line below the la...
Responsive design - Learn web development
Previous Overview: CSS layout Next In the early days of web design, pages were built to target a particular screen size. If the user had a larger or smaller screen than the designer expected, results ranged from unwanted scrollbars to overly long line lengths, and poor use of space. As more
diverse screen sizes became available, the concept of responsive web design (RWD) appeared, a set of practices that allows web pages to alter their layout and appearance to suit different screen widths, resolutions, etc. It is an idea that changed the way we design for a multi-device web, and in this article, we'll help you understand the main techniques you need to know to master it. Prerequisites: HTML basics (study Introduction to HTML), and an idea of how CSS works (study ...
...by giving each element a percentage width, and ensuring that across the layout the totals were not more than 100%. In his original piece on fluid grids, Marcotte detailed a formula for taking a layout designed using pixels and converting it into percentages. target / context = result For example, if our target column size is 60 pixels, and the context (or container) it is in is 960 pixels, we
divide 60 by 960 to get a value we can use in our CSS, after moving the decimal point two places to the right. .col { width: 6.25%; /* 60 / 960 = 0.0625 */ } This approach will be found in many places across the web today, and it is documented here in the layout section of our Legacy layout methods article. It is likely that you will come across websites using this approach in your work, so it ...
CSS layout - Learn web development
At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so we can now
dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about. Looking to become a front-end web developer? We have put together a course that includes all the essential information you need to work towards your goal. Get started Prerequisites Before starting this module, you should already: Have basic familiarity with HTML, as discusse...
... sitting on top of one another, or always remaining in the same place inside the browser viewport. This article explains the different position values, and how to use them. Multiple-column layout The multiple-column layout specification gives you a method of laying content out in columns, as you might see in a newspaper. This article explains how to use this feature. Responsive design As more
diverse screen sizes have appeared on web-enabled devices, the concept of responsive web design (RWD) has appeared: a set of practices that allows web pages to alter their layout and appearance to suit different screen widths, resolutions, etc. It is an idea that changed the way we design for a multi-device web, and in this article we'll help you understand the main techniques you need to know to mas...
Learn to style HTML using CSS - Learn web development
eatures. This module provides a gentle beginning to your path towards CSS mastery with the basics of how it works, what the syntax looks like, and how you can start using it to add styling to HTML. CSS building blocks This module carries on where CSS first steps left off -- now you've gained familiarity with the language and its syntax, and got some basic experience with using it, its time to
dive a bit deeper. This module looks at the cascade and inheritance, all the selector types we have available, units, sizing, styling backgrounds and borders, debugging, and lots more. The aim here is to provide you with a toolkit for writing competent CSS and help you understand all the essential theory, before moving on to more specific disciplines like text styling and CSS layout. Styling tex...
...t applying custom fonts to your page, and styling lists and links. CSS layout At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so we can now
dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about. Solving common CSS problems Use CSS to solve common problems provides links to sections of content explaining how to use CSS to solve very common problems when creating a web page. From the beginning, y...
How can we design for all types of users? - Learn web development
go away when we switch to the Web. The reader's eyes act like a shuttle going from line to line. To make it easier on people's eyes, limit line width to around 60 or 70 characters. To achieve this, you can specify a size for your text's container. Let's consider this HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Font size experiment</title> </head> <body> <
div class="container"> <h1>This is our main heading <span class="subheading">This is our subheading</span> </h1> <p>[lengthly text that spans many lines]</p> </
div> </body> </html> We have a
div with class container. We can style the
div either to set its width (using the width property) or its maximum width so that it never gets too large (using the max-width property). If you...
... Images Images can be either decorative or informative, but there's no guarantee that your users can see them. For example, Visually impaired users rely on a screen reader, which can only handle text. ...
Example 3 - Learn web development
This is the third example that explain how to build custom form widgets. ...
...>Banana</option> <option>Strawberry</option> <option>Apple</option> </select> <
div class="select" tabindex="0"> <span class="value">Cherry</span> <ul class="optList hidden"> <li class="option">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> </form> CSS Content .widget select, .no-widget .select { position : absolute; left : -5000em; height : 0; overflow : hidden; } /* --------------- */ /* Required Styles */ /* --------------- */ .select { position: relative; display : inline-block; } .select.active, .select:focus { box-shadow: 0 0 3px 1px #227755; outline: none; } .select .optList { position: absolute...
Example 4 - Learn web development
This is the fourth example that explain how to build custom form widgets. ...
...tion> <option>Banana</option> <option>Strawberry</option> <option>Apple</option> </select> <
div class="select"> <span class="value">Cherry</span> <ul class="optList hidden"> <li class="option">Cherry</li> <li class="option">Lemon</li> <li class="option">Banana</li> <li class="option">Strawberry</li> <li class="option">Apple</li> </ul> </
div> </form> CSS Content .widget select, .no-widget .select { position : absolute; left : -5000em; height : 0; overflow : hidden; } /* --------------- */ /* Required Styles */ /* --------------- */ .select { position: relative; display : inline-block; } .select.active, .select:focus { box-shadow: 0 0 3px 1px #227755; outline: none; } .select .optList { position: absolute...
Example 5 - Learn web development
This is the last example that explain how to build custom form widgets. ...
..." role="listbox"> <span class="value">Cherry</span> <ul class="optList hidden" role="presentation"> <li class="option" role="option" aria-selected="true">Cherry</li> <li class="option" role="option">Lemon</li> <li class="option" role="option">Banana</li> <li class="option" role="option">Strawberry</li> <li class="option" role="option">Apple</li> </ul> </
div> </form> CSS Content .widget select, .no-widget .select { position : absolute; left : -5000em; height : 0; overflow : hidden; } /* --------------- */ /* Required Styles */ /* --------------- */ .select { position: relative; display : inline-block; } .select.active, .select:focus { box-shadow: 0 0 3px 1px #227755; outline: none; } .select .optList { position: absolute...
CSS basics - Learn web development
el="stylesheet"> Save index.html and load it in your browser. You should see something like this: If your paragraph text is red, congratulations! Your CSS is working. Anatomy of a CSS ruleset Let's dissect the CSS code for red paragraph text to understand how it works : The whole structure is called a ruleset. (The term ruleset is often referred to as just rule.) Note the names of the in
dividual parts: Selector This is the HTML element name at the start of the ruleset. It defines the element(s) to be styled (in this example, <p> elements). To style a different element, change the selector. Declaration This is a single rule like color: red;. It specifies which of the element's properties you want to style. Properties These are ways in which you can style an HTML element. (In ...
...al declarations for the <body> element. Let's go through these line-by-line: width: 600px; This forces the body to always be 600 pixels wide. margin: 0 auto; When you set two values on a property like margin or padding, the first value affects the element's top and bottom side (setting it to 0 in this case); the second value affects the left and right side. (Here, auto is a special value that
divides the available horizontal space evenly between left and right). You can also use one, three, or four values, as documented in Margin Syntax. background-color: #FF9500; This sets the element's background color. This project uses a reddish orange for the body background color, as opposed to dark blue for the <html> element. (Feel free to experiment.) padding: 0 20px 20px 20px; This sets four v...
JavaScript basics - Learn web development
aster these fundamentals, you have a head start on coding in other languages too! Important: In this article, try entering the example code lines into your JavaScript console to see what happens. For more details on JavaScript consoles, see Discover browser developer tools. Variables Variables are containers that store values. You start by declaring a variable with the var (less recommended,
dive deeper for the explanation) or the let keyword, followed by the name you give to the variable: let myVariable; Note: A semicolon at the end of a line indicates where a statement ends. It is only required when you need to separate statements on a single line. However, some people believe it's good practice to have semicolons at the end of each statement. There are other rules for when you shou...
...bol which produces a result based on two values (or variables). In the following table you can see some of the simplest operators, along with some examples to try in the JavaScript console. Operator Explanation Symbol(s) Example Addition Add two numbers together or combine two strings. + 6 + 9; 'Hello ' + 'world!'; Subtraction, Multiplication,
Division These do what you'd expect them to do in basic math. -, *, / 9 - 3; 8 * 2; // multiply in JS is an asterisk 9 / 3; Assignment As you've seen already: this assigns a value to a variable. = let myVariable = 'Bob'; Equality This performs a test to see if two values are equal. It returns a true/false (Boolean) result. === let myVariable = 3; ...
Mozilla splash page - Learn web development
bed the small version of the Firefox logo in the header. Adding a video to the main article content Just inside the <article> element (right below the opening tag), embed the YouTube video found at https://www.youtube.com/watch?v=ojcNcvb1olg, using the appropriate YouTube tools to generate the code. The video should be 400px wide. Adding responsive images to the further info links Inside the <
div> with the class of further-info you will find four <a> elements -- each one linking to an interesting Mozilla-related page. To complete this section you'll need to insert an <img> element inside each one containing appropriate src, alt, srcset and sizes attributes. In each case (except one -- which one is inherently responsive?) we want the browser to serve the 120px wide version when the viewpo...
...ersion otherwise. Make sure you match the correct images with the correct links! Note: To properly test the srcset/sizes examples, you'll need to upload your site to a server (using Github pages is an easy and free solution), then from there you can test whether they are working properly using browser developer tools such as the Firefox Network Monitor. An art directed red panda Inside the <
div> with the class of red-panda, we want to insert a <picture> element that serves the small portrait panda image if the viewport is 600px wide or less, and the large landscape image otherwise. Example The following screenshots show what the splash page should look like after being correctly marked up, on a wide and narrow screen display. Assessment or further help If you would like your wor...
JavaScript object basics - Learn web development
me to create it. This is in contrast to objects instantiated from classes, which we'll look at later on. It is very common to create an object using an object literal when you want to transfer a series of structured, related data items in some manner, for example sending a request to the server to be put into a database. Sending a single object is much more efficient than sending several items in
dividually, and it is easier to work with than an array, when you want to identify in
dividual items by name. Dot notation Above, you accessed the object's properties and methods using dot notation. The object name (person) acts as the namespace -- it must be entered first to access anything encapsulated inside the object. Next you write a dot, then the item you want to access -- this can be the nam...
...examples. So when you used string methods like: myString.split(','); You were using a method available on an instance of the String class. Every time you create a string in your code, that string is automatically created as an instance of String, and therefore has several common methods and properties available on it. When you accessed the document object model using lines like this: const my
Div = document.createElement('
div'); const myVideo = document.querySelector('video'); You were using methods available on an instance of the Document class. For each webpage loaded, an instance of Document is created, called document, which represents the entire page's structure, content, and other features such as its URL. Again, this means that it has several common methods and properties availabl...
Client-Server Overview - Learn web development
nother page (e.g. myproduct2.html) and so on. This can start to get really inefficient -- what happens when you get to thousands of product pages? You would repeat a lot of code across each page (the basic page template, structure, etc.), and if you wanted to change anything about the page structure -- like add a new "related products" section for example -- then you'd have to change every page in
dividually. Note: Static sites are excellent when you have a small number of pages and you want to send the same content to every user. However they can have a significant cost to maintain as the number of pages becomes larger. Let's recap on how this works, by looking again at the static site architecture diagram we looked at in the last article. When a user wants to navigate to a page, the ...
...tes handle requests for static files (CSS, JavaScript, static images, etc.) in exactly the same way. Dynamic sites A dynamic site is one that can generate and return content based on the specific request URL and data (rather than always returning the same hard-coded file for a particular URL). Using the example of a product site, the server would store product "data" in a database rather than in
dividual HTML files. When receiving an HTTP GET Request for a product, the server determines the product ID, fetches the data from the database, and then constructs the HTML page for the response by inserting the data into an HTML template. This has major advantages over a static site: Using a database allows the product information to be stored efficiently in an easily extensible, modifiable, and s...
Website security - Learn web development
like send the user's site authorization cookie to the attacker. When the attacker has the cookie, they can log into a site as though they were the user and do anything the user can, such as access their credit card details, see contact details, or change passwords. Note: XSS vulnerabilities have been historically more common than any other type of security threat. The XSS vulnerabilities are
divided into reflected and persistent, based on how the site returns the injected scripts to a browser. A reflected XSS vulnerability occurs when user content that is passed to the server is returned immediately and unmodified for display in the browser. Any scripts in the original user content will be run when the new page is loaded. For example, consider a site search function where the search...
...so actually unwittingly click a completely different button. As a defense, your site can prevent itself from being embedded in an iframe in another site by setting the appropriate HTTP headers. Denial of Service (DoS). DoS is usually achieved by flooding a target site with fake requests so that access to a site is disrupted for legitimate users. The requests may simply be numerous, or they may in
dividually consume large amounts of resource (e.g., slow reads or uploading of large files). DoS defenses usually work by identifying and blocking "bad" traffic while allowing legitimate messages through. These defenses are typically located before or in the web server (they are not part of the web application itself). Directory Traversal (File and disclosure). In this attack, a malicious user attem...
TypeScript support in Svelte - Learn web development
wing contents: export enum Filter { ALL = 'all', ACTIVE = 'active', COMPLETED = 'completed', } Now we will use this from the FilterButton component. ...
... Todos.svelte We will also use the Filter enum in the Todos.svelte component. First add the lang='ts' attribute to it, as before. Next, import the Filter enum -- add the following import statement below your existing ones: import { Filter } from '../types/filter.enum' ...
Getting started with Vue - Learn web development
Previous Overview: Client-side JavaScript frameworks Next Now let's introduce Vue, the third of our frameworks. In this article we'll look at a little bit of Vue background, learn how to install it and create a new project, study the high-level structure of the whole project and an in
dividual component, see how to run the project locally, and get it prepared to start building our example. Prerequisites: Familiarity with the core HTML, CSS, and JavaScript languages, knowledge of the terminal/command line. Vue components are written as a combination of JavaScript objects that manage the app's data and an HTML-based template syntax that maps to the underlying DOM structure. For installation, and to use some of the more advanced features of Vue (like Single File C...
...ent but are not using it. We also need to remove the lines from inside the <script> element that import and register the component: Delete these lines now: import HelloWorld from './components/HelloWorld.vue' components: { HelloWorld } Your rendered app should no longer show an error, just a blank page, as we currently have no visible content inside <template>. Let's add a new <h1> inside <
div id="app">. Since we're going to be creating a todo list app below, let's set our header text to "To-Do List". Add it like so: <template> <
div id="app"> <h1>To-Do List</h1> </
div> </template> App.vue will now show our heading, as you'd expect. Summary Let's leave this here for now. We've learnt about some of the ideas behind Vue, created some scaffolding for our example app to live ins...
Rendering a list of Vue components - Learn web development
default { props: { label: {required: true, type: String}, done: {default: false, type: Boolean}, id: {required: true, type: String} }, data() { return { isDone : this.done, } }, } Now, over in your App.vue component, pass item.id as a prop to the ToDoItem component. ...
...e : this.done, } }, } Now, over in your App.vue component, pass item.id as a prop to the ToDoItem component. Your App.vue template should now look like this: <template> <
div id="app"> <h1>My To-Do List</h1> <ul> <li v-for="item in ToDoItems" :key="item.id"> <to-do-item :label="item.label" :done="item.done" :id="item.id"></to-do-item> </li> </ul> </
div> </template> When you look at your rendered site, it should look the same, but our refactor now means that our id is being taken from the data inside App.vue and passed into ToDoItem as a prop, just like everything else, so things are now more logical and consistent. Summary And that brings us to the end of another article. We now have sample data in place, and a loop that takes each bit of da...
Understanding client-side JavaScript frameworks - Learn web development
a bit about how React works in the process. 2. Beginning our React todo list Let's say that we've been tasked with creating a proof-of-concept in React - an app that allows users to add, edit, and delete tasks they want to work on, and also mark tasks as complete without deleting them. This article will walk you through putting the basic App component structure and styling in place, ready for in
dividual component definition and interactivity, which we'll add later. 3. Componentizing our React app At this point, our app is a monolith. Before we can make it do things, we need to break it apart into manageable, descriptive components. React doesn't have any hard rules for what is and isn't a component - that's up to you! In this article, we will show you a sensible way to break our app up in...
...ished version of the sample Vue app code in our todo-vue repository. For a running live version, see https://mdn.github.io/todo-vue/dist/. 1. Getting started with Vue Now let's introduce Vue, the third of our frameworks. In this article, we'll look at a little bit of Vue background, learn how to install it and create a new project, study the high-level structure of the whole project and an in
dividual component, see how to run the project locally, and get it prepared to start building our example. 2. Creating our first Vue component Now it's time to
dive deeper into Vue, and create our own custom component -- we'll start by creating a component to represent each item in the todo list. Along the way, we'll learn about a few important concepts such as calling components inside other compo...
Handling common JavaScript problems - Learn web development
level tends to consist of downloading the library's files (JavaScript, possibly some CSS or other dependencies too) and attaching them to your page (e.g. via a <script> element), although there are normally many other usage options for such libraries, like installing them as Bower components, or including them as dependencies via the Webpack module bundler. You will have to read the libraries' in
dividual install pages for more information. Note: You will also come across JavaScript frameworks in your travels around the Web, like Ember and Angular. Whereas libraries are often usable for solving in
dividual problems and dropping into existing sites, frameworks tend to be more along the lines of complete solutions for developing complex web applications. Polyfills Polyfills also consist of ...
...}); Now if you load it in a browser that doesn't support Fetch (Safari and IE are obvious candidates), you should still see the flower image appear -- cool! Note: You can find our finished version at fetch-polyfill-finished.html (see also the source code). Note: Again, there are many different ways to make use of the different polyfills you will encounter -- consult each polyfill's in
dividual documentation. One thing you might be thinking is "why should we always load the polyfill code, even if we don't need it?" This is a good point -- as your sites get more complex and you start to use more libraries, polyfills, etc., you can start to load a lot of extra code, which can start to affect performance, especially on less-powerful devices. It makes sense to only load files as need...
Command line crash course - Learn web development
Before you go any further, open your terminal program! Navigation on the command line When you visit the command line you ...
...s part of the installation. Although we'll look at a number of different tools in the next article onwards, we'll cut our teeth on Prettier. Prettier is an opinionated code formatter that has "few options". Fewer options tends to mean simpler. Given how tooling can sometimes get out of hand in terms of complexity, "few options" can be very appealing. Where to install our CLI tools? Before we
dive into installing Prettier, there's a question to answer -- "where should we install to?" With npm we have the choice of installing tools globally -- so we can access them anywhere -- or locally to the current project directory. There's pros and cons each way -- and this list of pros and cons for globally installing is far from exhaustive: Pros of installing globally Cons of install...
Mozilla accessibility architecture
MNode is associated with the current window's document object. There must be a document for the current widget (nsWindow/nsIWidget) for the pres shell to create a doc accessible for it. One benefit of this approach is that accessibility.dll/libaccessibility.so does not need get loaded until the accessibility service gets used, and for most users it is never loaded. All other accessibles for the in
dividual objects are created on demand as well. The assistive technology can choose to get the entire tree by using a depth- or breadth- first search, it can choose to get accessibles only based on events like focus, or it can get the accessible at a given point on the screen. No matter how the assistive technology client requests the data, the accessible for a given node is only created once. We use...
...ady been visited. Role of nsAccessNode If you work mostly in the ATK sections of our accessibility module, you may wonder what the purpose of nsAccessNode is -- there are no ATK interfaces that use it. In fact, it exists because of our ISimpleDOMNode extension to MSAA, which we implement on nsAccessNodeWrap. ISimpleDOMNode is used by the assistive technology to get access to information about in
dividual DOM nodes which may or may not be "accessible". Because an nsAccessNode can point to any DOM node, even DOM nodes that are not "accessible", it may or may not also be an nsAccessible. In other words, the lowest common denominator for objects we must cache is nsAccessNode. nsAccessNode::Init() When nsAccessibilityService::GetAccessible() gets a newly created accessible, it calls nsIAccessNode...
A bird's-eye view of the Mozilla framework
overview of the architecture of the extensible, object-based Mozilla application framework. It examines what happens when the user performs a simple user interface (UI) action such as clicking a link in the Contents Panel of the Help Viewer window shown below. The article focuses on the architecture of the overall framework supporting the Mozilla application suite, not the architecture of the in
dividual applications themselves. Prerequisites This article assumes you have access to Mozilla sources and are familiar with the directory structure of the source tree. The code samples in the article are based on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20051104 SeaMonkey/1.1a from a new source tree checked out 11/04/05. The build ID is 2005110409. TheHelp Viewer files re...
...el elements stored in a DOM tree. As a client, getLink() begins by obtaining the XULElement in the DOM tree representing theContents Panel. var tocTree = document.getElementById("help-toc-panel"); The document object is a XULDocument, and tocTree is theContents Panel XULElement. Using the database attribute of the XULElement, getLink() obtains an nsIRDFCompositeDataSource, which presents the in
dividual datasources of the XULElement as a single RDF graph. var tocDS = tocTree.database; NsIRDFCompositeDataSource inherits from nsIRDFDataSource. Help.js declares an nsIRDFService as a compile time constant at the beginning of the file. const RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); The Components object is made available...
Building SpiderMonkey with UBSan
ion of LLVM & Clang. 2. Save the following bash script, fixing LLVM_ROOT to point to your installation. #! /bin/sh if [ -z $1 ] ; then echo "usage: $0 <dirname>" elif [ -d $1 ] ; then echo "directory $1 already exists" else autoconf2.13 autoconf213 mkdir $1 cd $1 LLVM_ROOT="$HOME/llvm" SANFLAG="-fsanitize=undefined -fno-sanitize=alignment,float-cast-overflow,float-
divide-by-zero,vptr -Dxmalloc=myxmalloc" \ CC="$LLVM_ROOT/build/Release+Asserts/bin/clang" \ CXX="$LLVM_ROOT/build/Release+Asserts/bin/clang++" \ CFLAGS="$SANFLAG" \ CXXFLAGS="$SANFLAG" \ MOZ_LLVM_HACKS=1 \ ../configure --enable-debug --disable-optimize make -j 8 fi 3. Use the script to compile SpiderMonkey. This enables all the cheap undefined behavior checks othe...
...bug --disable-optimize make -j 8 fi 3. Use the script to compile SpiderMonkey. This enables all the cheap undefined behavior checks other than: alignment, which hits known bugs in SpiderMonkey, and is more implementation-defined (slow on x86 / crash on ARM) than undefined behavior float-cast-overflow, which hits known bugs in SpiderMonkey, and isn't exploited by today's compilers float-
divide-by-zero, which Jesse doesn't think is actually undefined behavior (aside from the question of whether CPU overflow flags are set) vptr, a check that requires RTTI, which is disabled by default in SpiderMonkey 4. When you hit a bug and want a stack trace, run under gdb with a breakpoint at the end of __ubsan::Diag::~Diag(). The stack trace should show a function such as __ubsan_handle_load_...
mach
building the tree: $ ./mach build If you get error messages, make sure that you have all of the build requisites for your system. If it works, you can look at compiler warnings: $ ./mach warnings-list Try running the program: $ ./mach run Try running your program in a debugger: $ ./mach run --debug Try running some tests: $ ./mach xpcshell-test services/common/tests/unit/ Or run an in
dividual test: $ ./mach mochitest browser/base/content/test/general/browser_pinnedTabs.js You run mach from the source directory, so you should be able to use your shell's tab completion to tab-complete paths to tests. Mach figures out how to execute the tests for you! Check out the linting and analysis tools: $ ./mach lint $ ./mach static-analysis mach and mozconfigs It's possible to use mach ...
...ppened was an invoked command returned a non-0 exit code - possibly expectedly so in Mozilla! Generally, mach is known to work pretty well without issues for most people and works terribly for others with even the "basics" being quite unsatisfactory. How do I report bugs? Bugs against the mach core can be filed in Bugzilla in the Firefox Build System::Mach Core. Most mach bugs are bugs in in
dividual commands, not bugs in the core mach code. Bugs for in
dividual commands should be filed against the component that command is related to. For example, bugs in the build command should be filed against Firefox Build System :: General. Bugs against testing commands should be filed somewhere in the Testing product. How is building with mach different from building with client.mk, from using ma...
Multiple Firefox profiles
his: Right-click the icon and choose "Properties". When the properties dialog box pops up, you should see a "Target" text field that you can edit, and it should show the current file path. After the closing quote, add -ProfileManager. Click Ok. Now whenever you double click that icon, the profile manager should appear, allowing you to choose which profile you'd like to use. If you want in
dividual icons to launch specific profiles, you will need to edit the "Target" of each icon. To do this: Right-click the icon and choose "Properties". When the properties dialog box pops up, you should see a "Target" text field that you can edit, and it should show the current file path. To permanently set a specific profile, add -p PROFILE_NAME to the target path, but outside of the quotes, rep...
... can have the profile dialog show up every time or set the launcher to launch a specific profile. If you want to have the profile manager to pop up each time you start Firefox, so you can choose a profile, you will need to set the command line for your new launcher. Set the "command" text field to target the executable file, likely "/usr/bin/firefox", and add the -p parameter. If you want in
dividual icons to launch specific profiles, you will need to set the command line for your new launcher. To do this: Set the "command" text field to target the executable file, likely "/usr/bin/firefox", and add the -p PROFILE_NAME parameter, replacing "PROFILE_NAME" with the specific profile. Repeat as necessary, for each additional profile you want to set. If you would also like to allow multi...
Communicating with frame scripts
an XPCOM component), you can access the window of the brow...
...n listener(message) { console.log(message.name); console.log(message.sync); console.log(message.data); console.log(message.target); console.log(message.objects); } So combining this message listener with the message above will give console output somewhat like this, when the user clicks a <
div>: "my-addon@me.org:my-e10s-extension-message" false Object { details: "they clicked", tag: "
div" } <xul:browser anonid="initialBrowser" ... > { target: <
div#searchContainer> } If your code requires access to a window (for example to run window.openDialog), and your message listener is run from somewhere without access to a window (e.g. an XPCOM component), you can access the window of the browser that sent the message with message.target.ownerDocument.defaultView. Synchronous messaging ...
CSS -moz-bool-pref() @supports function
The -moz-bool-pref() @supports condition is available to Gecko chrome and UA stylesheets to check if a boolean preference is enabled. ...
...o check if a boolean preference is enabled. Syntax -moz-bool-pref( <string> ) Parameters <string> The preference name Returns Evaluates to true if the preference is enabled, false otherwise. Example Warning: This will only work when loaded from a Gecko chrome stylesheet. ...
MozBeforePaint
or 60. This is intentional, because modern operating systems and hardware won't let the browser display more frames than that anyway. Limiting the frame rate avoids wasting work, thereby saving CPU usage and power and improving overall system performance. Example This example performs a simple animation, moving a box a short distance after a short period of time. ...
...the browser display more frames than that anyway. Limiting the frame rate avoids wasting work, thereby saving CPU usage and power and improving overall system performance. Example This example performs a simple animation, moving a box a short distance after a short period of time. ...
Download
ile the download is in progress, using the MIME type provided by the server. currentBytes Read only number Number of bytes currently transferred. This value starts at zero, and may be updated regardless of the value of hasProgress. Note: You shouldn't rely on this property being equal to totalBytes to determine whether the download is completed. You should use the in
dividual state properties instead, since this value may not be updated after the last piece of data is transferred. error Read only DownloadError When the download fails, this is set to a DownloadError instance indicating the cause of the failure. If the download has been completed successfully or has been canceled, this property is null. This property is reset to null when a fail...
...her properties change. Warning: This property cannot be used if the download is part of a DownloadList. progress Read only number Progress percent, from 0 to 100. Intermediate values are reported only if hasProgress is true. Note: You shouldn't rely on this property being equal to 100 to determine whether the download is completed. You should use the in
dividual state properties (for example, the succeeded property) instead. saver Read only DownloadSaver Saver object associated with this download. source Read only DownloadSource Source of this download. startTime Read only Date Indicates the start time of the download. When the download starts, this property is set to a valid Date object. The defau...
Application Translation with Mercurial
eak. File comparison program For the translation, it is recommend to use file comparison program to compare the English file (containing the new texts) with the file of your locale (which is still missing the new strings). This example uses WinMerge: Download and install it. A comparison of alternatives (e.g. for Linux and Mac OS) is available on Wikipedia. File and text editor For editing in
dividual files a text editor can be a better choice than a file comparion program, e.g. because the file is new and everything has to be translated, the file is too customized to compare it to the English one, or special functionality is required (e.g. bookmarking untranslated lines). Use a text editor you are comfortable with. This example uses Notepad++. Progress tracking tool To track which stri...
...en translated and later also to see which new strings have already been tested in the product as being a good translation for the functionality behind the translated strings and that the translated texts fit into the available, the translation progress should be tracked. This can be done in a text editor or word processor or any other tool in which you can attach different kind of states to the in
dividual texts to translate. The Firefox extension Scrapbook is used in this guide. Install it into your default Firefox profile (you will have more than one profile when following this guide). Getting the current Texts in English and your Locale Obtaining the English texts with the source code Get the source code by downloading the following file: Firefox Desktop or Firefox for Android: Downlo...
Localization content best practices
es best practices for developers to create localizable code, and describes how to avoid some localizability (l12y) common mistakes. Note: If you're a localizer and you want to contribute to the localization of Mozilla products, you might want to read our Localization quick start guide for information on localizing Mozilla code. Note on localizers Mozilla localizers are volunteers with very
diverse technical skills: some of them rely exclusively on translation tools, others prefer to work directly with text editors and don't have problems working with VCS systems. It's important to consider this when adding strings, and especially localization comments for strings that contain references, or obscure technical details. Localization files Choose good key IDs The IDs (names) chosen for...
...tring to match the new meaning. If your changes are relevant only for English -- for example, to correct a typographical error or to make letter case consistent -- then there is generally no need to update the entity name. Changing the string ID will invalidate the existing translation, the new string will be reported as missing in all tools, and localizers will have to retranslate it. Given the
diversity of tools used by localization teams, this is the only reliable method to ensure that localizers update existing localizations. If you change the entity or property name of a string, you must also update all instances where that entity or property name is used in the source code, including localization comments. If you change the entity or property name of a string, and the string has an a...
Extras
top-opacity:1;"/> <stop offset="100%" style="stop-color:rgb(0,0,255); stop-opacity:.9;"/> </radialGradient> </defs> <g> <animateMotion path="M0,0 L3,0 L2,5 L5,5 L0,4 L5,2 z" begin="0s" dur="0.5s" repeatCount="indefinite"/> <circle fill="url(#radGrad2)" r="5px" cx="5px" cy="5px"/> </g> </svg> </mtext> </msup> <mrow> <mo>d</mo> <mi>?</mi> </mrow> </math> <
div style="width: 300px; margin-left: auto; margin-right: auto;"> <svg width="300px" height="250px"> <defs> <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0%" style="stop-color:rgb(0,0,255);stop-opacity:1"/> <stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/> </linearGradient> <linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%"> <stop offset="0%...
..."60" height="60" requiredExtensions="http://www.w3.org/1998/Math/MathML"> <math display="block"> <mrow> <munderover> <mo>?</mo> <mrow> <mi>n</mi> <mo>=</mo> <mn>0</mn> </mrow> <mrow> <mo>+</mo> <mi>?</mi> </mrow> </munderover> <mfrac> <msup> <mi>?</mi> <mi>n</mi> </msup> <mrow> <mi>n</mi> <mo>!</mo> </mrow> </mfrac> </mrow> </math> </foreignObject> <text>exp(?)</text> </switch> </g> </g> </svg> </
div> Inline JavaScript HTML Content <math display="block"> <mfrac> <mtext id="num">Mouse</mtext> <mtext id="denum">Over</mtext> </mfrac> </math> JavaScript Content function whoIsThereAlert(evt) { alert("Who is there?"); } function attachListener(id) { document.getElementById(id).addEventListener("mouseover", whoIsThereAlert); } function init() { attachListener("num"); attachList...
Mozilla MathML Status
Implemented. mlabeledtr Not Implemented. See bug 689641. mtd Implemented. * - groupalign. Not implemented. See bug 122253. maligngroup Not implemented. See bug 122253. malignmark Not implemented. See bug 122253. Elementary Math Element [- attribute] Notes mstack Not implemented. See bug 534967. mlong
div Not implemented. See bug 534967. msgroup Not implemented. See bug 534967. msrow Not implemented. See bug 534967. mscarries Not implemented. See bug 534967. mscarry Not implemented. See bug 534967. msline Not implemented. See bug 534967. Other elements Element [- attribute] Notes mglyph Not implemented. Se...
... Other elements Element [- attribute] Notes mglyph Not implemented. See bug 297465. maction Implemented. maction - tooltip Not implemented. See bug 544001. semantics Implemented. Original Document Information Author(s): Frederic Wang Other Contributors: Copyright Information: Portions of this content are (C) 2010 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
MathML Demo: <mfrac> - fractions
( t , y ) = ( 1 , d y d t ) || ( 1 , d y d t ) || with some real math in it. ...
... d y d t ) || ( 1 , d y d t ) || with some real math in it. ...
Mozilla Development Strategies
itch some code over to nsCOMPtrs. Look for XXX or TODO in the code, verify the code still needs fixing, and fix it. Smaller patches get reviewed faster If you find that you spend a lot of time waiting for reviews, keep in mind that patch size is not linear to time to review. A twenty line patch doesn't take twice as long to review as a ten line patch, it usually takes much more time. If you can
divide and conquer what you are working on into smaller chunks, you will find you'll get faster reviews. Of course, not everything can be
divided up. And, shorter fixes aren't necessarily better than longer ones. Having parallel trees should allow you to work on other items while you are awaiting reviews. Get advice before working on a patch or feature, instead of after If you are blocked, or stum...
... ...
NSS 3.45 release notes
Only relevant for clients that might have copied the unit tes...
...Only relevant for clients that might have copied the unit test code verbatim Bug 1550022 - Ensure nssutil3 gets built on Android Bug 1528174 - ChaCha20Poly1305 should...
NSS API Guidelines
db library manipulates the certificate database (add, create, delete certificates and CRLs). It also provides general certificate-handling routines (create a certificate, verify, add/check certificate extensions). Low Cert lib/certdb cdbhdl.h, certdb.h, cert.h, certt.h certhi Provides high-level certificate-related functions, that do not access the certificate database, nor in
dividual certificate data directly. Currently, OCSP checking settings are exported through certhi. High Cert lib/certhigh ocsp.h, ocspt.h crmf Provides functions, and data types, to handle Certificate Management Message Format (CMMF) and Certificate Request Message Format (CRMF, see RFC 2511) data. CMMF no longer exists as a proposed standard; CMMF functions have been incorporat...
... header file. For example, for the structure SECMyOpaqueData you would add: typedef struct SECMyOpaqueDataStr SECMyOpaqueData; and add the actual structure definition to the private header file. In this same example: struct SECMyOpaqueDataStr { unsigned long myPrivateData1; unsigned long myPrivateData2; char *myName; }; the second task is to determine if in
dividual data fields, within the data structure, are part of the API. One example may be the peerCert field, in an SSL data structure. Accessor functions, for these data elements, should be added to the API. There can be legitimate exceptions to this 'make everything opaque' rule. For example, in container structures, such as SECItem, or maybe linked list data structures. These data structures need ...
NSS tools : certutil
ases. -O Print the certificate chain. -R Create a certificate request file that can be submitted to a Certificate Authority (CA) for processing into a finished certificate. Output defaults to standard out unless you use -o output-file argument. Use the -a argument to specify ASCII output. -S Create an in
dividual certificate and add it to a certificate database. -T Reset the key database or token. -U List all available modules or print a single named module. -V Check the validity of a certificate and its attributes. -W Change the password to a key database. --merge Merge two databases into one. ...
...f a certificate, going from the initial CA (the root CA) through ever intermediary CA to the actual certificate. ...
certutil
and key databases. -O Print the certificate chain. -R Create a certificate request file that can be submitted to a Certificate Authority (CA) for processing into a finished certificate. Output defaults to standard out unless you use -o output-file argument. Use the -a argument to specify ASCII output. -S Create an in
dividual certificate and add it to a certificate database. -T Reset the key database or token. -U List all available modules or print a single named module. -V Check the validity of a certificate and its attributes. -W Change the password to a key database. --merge Merge a source database into the target databa...
...chain of a certificate, going from the initial CA (the root CA) through ever intermediary CA to the actual certificate. ...
Necko Architecture
ports, filenames, etc. URLs are the most commonly used form of a URI. Because of their importance, Necko provides its own standard implementation of URLs (with class id NS_STANDARDURL_CID), which does all of the standard parsing necessary for most URLs. Necko also provides a simple URI implementation for convenience. URIs (recall that a URL is just one implementation of a URI) can be created as in
dividual components independently of Necko, or they can be retrieved via the nsIIOService interface. For more information see URIs and URLs. If you want to provide your own resource implementation for foo URLs, you simply need to implement the nsIURI interface. nsIIOService acts as the central point of access to URLs and channels (nsIChannel) in Necko. Given a string representation of a URL, you can ...
... ...
Hacking Tips
enchmarks are publicly recognized benchmarks suggested by other companies and are used as a metric to evaluate how fast JavaScript engines. This tool is maintained by the JavaScript Team, to find regressions and to compare SpiderMonkey with other JavaScript engines when possible. To run these benchmarks localy, you can clone AreWeFastYet sources and look inside the benchmarks directory to run in
dividual benchmarks with your JS shell. Using the Gecko Profiler (browser / xpcshell) see the section dedicated to profiling with the gecko profiler. This method of profiling has the advantage of mixing the JavaScript stack with the C++ stack, which is useful to analyze library function issues. One tip is to start looking at a script with an inverted JS stack to locate the most expensive JS functi...
...'s OK to ignore OOM For example if you are performing a speculative optimisation you might abandon it and continue anyway. But in this case you may have to call cx->recoverFromOutOfMemory() if something further down the stack has already reported the failure. Debugging GC marking/rooting The js::debug namespace contains some functions that are useful for watching mark bits for an in
dividual JSObject* (or any Cell*). js/src/gc/Heap.h contains a comment describing an example usage. Reproduced here: // Sample usage from gdb: // // (gdb) p $word = js::debug::GetMarkWordAddress(obj) // $1 = (uintptr_t *) 0x7fa56d5fe360 // (gdb) p/x $mask = js::debug::GetMarkMask(obj, js::gc::GRAY) // $2 = 0x200000000 // (gdb) watch *$word // Hardware watchpoint 7: *$word // (gdb) cond...
Web Replay
gress indicator. Console error/messages are marked on the timeline and can be clicked to seek to that point. Advanced Options Preferences devtools.recordreplay.enableRewinding When disabled, Firefox records a page signifcantly faster. default true. devtools.recordreplay.fastLogpoints When enabled, Firefox Web Replay evaluates logpoints consecutively. Logpoints cannot have side-effects or
diverge from the recording in any othe way in this mode. default false. devtools.recordreplay.logging When enabled, Firefox will log Web Replay's internal actions to the terminal, which is helpful when debugging hangs and crashes. default false Architecture There are several main components to the project: The record/replay infrastructure records enough information during recording so that the...
...recorded by calling setjmp before idling). Restoring snapshots is also done from the main thread. As for taking a snapshot, all other threads enter an idle state. The dirty memory information computed since the last snapshot was taken is used to restore the heap to the state at that last snapshot, and then the memory diffs can be used to restore an earlier snapshot if necessary. Threads are in
dividually responsible for restoring their stacks; when they wake up from the idle state they see the main thread has prepared a new stack to restore to, so they longjmp to the new register state and copy in the new stack's contents. Managing system resources When the child process restores a snapshot, the state of any system resources it has open is unchanged. Care must be taken to make sure thes...
Mozilla Projects
onfiguration data used by the browser, such as bookmarks, history, preferences, bookmarks, and so forth among all your devices. JSHydra JSHydra is a static analysis tool that is capable of performing analysis of general JavaScript code. L20n L20n lets localizers reach higher levels of free linguistic expression by sharpening the
divide between localization and application logic. Leak Monitor Leak Monitor is a Firefox extension by L. David Baron that helps extension and chrome developers to find memory leaks. It will pop-up an alert when a window is closed and JavaScript still links to that window (for example, an observer that is not cleared when the window closes). ...
... It is completely free, open source and can be included in any tool whether open or closed, free or commercial. Zest is still at a very early stage of development, but is has been made available so that anyone can play around with it. All constructive feedback is very welcome. Anyone can contribute to the onward development of Zest, and teams or in
dividuals who develop security tools are especially welcome to join and help shape Zest's future. ...
Creating the Component Code
<< PreviousNext >> This chapter goes over the basic code required to handle the relationship between your component and XPCOM. Having the component found and registered properly is the goal of this first chapter of the tutorial. In the subsequent chapters, we can begin to work on the example WebLock component functionality itself. Use the Calculator (After Learning Long
Division) You have to write a fair amount of code to create a component library that gets loaded into XPCOM. An XPCOM component needs to implement at least three interfaces that XPCOM requires, and often others as well. There is more code in this chapter than you'll eventually need, however. Using XPCOM Utilities to Make Things Easier shows some simpler and more elegant ways to create an XPCOM component usin...
...onent needs to implement at least three interfaces that XPCOM requires, and often others as well. There is more code in this chapter than you'll eventually need, however. Using XPCOM Utilities to Make Things Easier shows some simpler and more elegant ways to create an XPCOM component using generic macros, and this chapter is more about learning the basics. As in grade school when you learned long
division, better tools like calculators come after you figure out what's actually happening. In this case, the long-hand implementation gives us an opportunity to talk about various features of XPCOM. What We'll Be Working On The component we'll be working on in this book controls a special mode in your browser that prevents users from leaving the current domain or a set of safe domains. Once enab...
Mozilla internal string guide
destructible, and therefore does not emit construction/destruction code when stored in statics, as opposed to the other string classes. The Major String Classes The list below describes the main base classes. Once you are familiar with them, see the appendix describing What Class to Use When. nsAString/nsACString: the abstract base class for all strings. It provides an API for assignment, in
dividual character access, basic manipulation of characters in the string, and string comparison. This class corresponds to the XPIDL AString parameter type. nsAString is not necessarily null-terminated. nsString/nsCString: builds on nsAString by guaranteeing a null-terminated storage. This allows for a method (.get()) to access the underlying character buffer. The remainder of the string classes ...
...ither direction. (Don't use if you use appends that convert between UTF-16 and UTF-8 in either direction.) Calling this method does not give you permission to use BeginWriting() to write past the logical length of the string. Use SetLength() or BulkWrite() as appropriate. Original Document Information Author: Alec Flett Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. Thanks to David Baron for actual docs, Peter Annema for lots of direction Myk Melez for some more docs David Bradley for a diagram Revised by Darin Fisher for Mozilla 1.7 Revised by Jungshik Shin to clarify character encoding issues ...
Index
plications. Though the emphasis is on the practical steps you take to make your C++ code into a component that can be used in Gecko, we hope that these steps will also give us an occasion to discuss all of the tools, techniques, and technologies that make up XPCOM. Accordingly, the book is arranged so that you can follow along and create your own components or learn about different XPCOM topics in
dividually, as in a reference work. For example, the introduction includes a discussion of components and what they are, and the first chapter - in which you compile the basic code and register it with Mozilla - prompts a discussion of the relationship between components and modules, of XPCOM interfaces, and of the registration process in general. 108 Resources Guide, XPCOM This ...
...e, XPCOM, XPCOM Interface Reference Jump lists are built and then applied. Modifying an applied jump list is not permitted. Callers should begin the creation of a new jump list using initListBuild(), add sub lists using addListToBuild(), then commit the jump list using commitListBuild(). Lists are built in real-time during the sequence of build calls, make sure to check for errors on each in
dividual step. 711 nsIJumpListItem Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference Compare this item to another. 712 nsILivemarkService Interfaces, Interfaces:Scriptable, Places, XPCOM, XPCOM Interface Reference Implemented by: @mozilla.org/browser/livemark-service;2. To use this service, use: 713 nsILoadGroup Interfaces, In...
mozIRegistry
ize the core XPCOM components to satisfy those requirements. i18n XUL/xpToolkit App Shell CLSID Binding Protocols This is a placeholder for potential encapsulations of particular idioms for storing CLSID information in the registry and using that information, along with nsRepository, to implement some instance creation protocol on top of the core XPCOM services. I think these things can be
divided into two categories, according to the basic service they provide: Identifying the implementers of a given interface. Figuring out an appropriate implementation given some arbitrary desired properties. nsRepository This is basically the same as is provided today (see mozilla/xpcom/public/nsRepository.h). The primary change to this component is that we will modify it to utilize the new mo...
... The contents of this RDF data base will be stored in a plain-text rdf/xml file so that it can easily be viewed edited. It will also facilitate building a browser-based application that will allow people to display and edit its contents. Original Document Information Author: Bill Law Last Updated Date: January 21, 1999 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
nsINavHistoryQueryOptions
cending annotation order. SORT_BY_FRECENCY_ASCENDING 21 Sort by ascending frecency order. SORT_BY_FRECENCY_DESCENDING 22 Sort by descending frecency order. Result type constants Constant Value Description RESULTS_AS_URI 0 "URI" results, one for each URI visited in the range. ...
...er. Result type constants Constant Value Description RESULTS_AS_URI 0 "URI" results, one for each URI visited in the range. In
dividual result nodes will be of type "URI". RESULTS_AS_VISIT 1 "Visit" results, with one for each time a page was visited (this will often give you multiple results for one URI). In
dividual result nodes will have type "Visit". RESULTS_AS_FULL_VISIT 2 This is identical to RESULT_TYPE_VISIT except that in
dividual result nodes will have type "FullVisit". This is used for the attributes that are not commonly accessed to save space in the common case (the lists can be very long). Note: Supported only for QUERY_TYPE_HISTORY. ...
XPCOM ownership guidelines
cause you need it. In fact often you own it because it needs you. If you own it, it shouldn't own you. Even transitively. Or put another way: the ownership graph for any system should be acyclic. Anytime there is a cycle of ownership, there is a situation that isn't automatically handled by destructors. Special code must be provided and called to break the cycle before the participants can be in
dividually released. You don't need to own it if it's lifetime is guaranteed to be longer than yours. As for instance, when it owns you. Parents own their children (and not the reverse). Though parents may not need to own their children. For instance, a tree may own all the nodes that are in it. All the nodes in the tree point to each other with non-owning pointers. In the simplest scheme, howeve...
... implement owning-pointers. It's explicit, efficient, and fairly bullet-proof. It's easier to write `getter's and `setter's; and you don't need to put anything in your destructor. Original Document Information Author: Scott Collins Last Updated Date: May 8, 2003 Copyright Information: Copyright(C) 1999 by Netscape; use is subject to the NPL. Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Mail client architecture overview
refer to modules outside of mail/news The base Module The base module provides a generic interface to a set of protocol-independant messaging services. This includes management of accounts, folders and messages. The base module consists of the following basic building blocks Account Management - The Account Manager is the root object of the server/folder/message hierarchy. It manages in
dividual accounts on mail servers and the identity of users as used to send mail. Folders - Mail folders contain messages and folders. All folders have folder indexes. Messages - Messages are always stored and streamed in RFC822 format. Whenever multiple messages are stored in one file, the berkeley mailbox format is used. Datasources - Datasources are the glue code that reflect mail data such as ...
...es, and displaying messages from a remote server, the URL system interacts with necko and reflects it's state to the mail window. There are also a number of protocol independant subsystems that have a symbiotic relationship with base: libMIME - for dealing with RFC822 messages and their MIME parts. This library has the cabability to stream messages to an HTML renderer such as Gecko, manage in
dividual parts of messages, and so forth. msgdb - A message database for a given folder is a summary of some of the key attributes in a folder such as the Author and Subject. Finally, there are larger modules outside of the mail client that are mail-oriented. Most of these modules have little dependancy on the mail reader itself: Compose - The mail compose module is responsible for anything tha...
WebIDL bindings
eturn values become a non-const owning union out param. The name of the struct is the concatenation of the names of the types in the union, with "Or" inserted between them, and for an owning struct "Owning" prepended. ...
...long) receiveUnion(); void passSequenceOfUnions(sequence<(object or long)> arg); void passOtherUnion((HTML
DivElement or ArrayBuffer or EventInit) arg); would correspond to these C++ function declarations: void PassUnion(const ObjectOrLong& aArg); void ReceiveUnion(OwningObjectObjectOrLong& aArg); void PassSequenceOfUnions(const Sequence<OwningObjectOrLong>& aArg); void PassOtherUnion(const HTML
DivElementOrArrayBufferOrEventInit& aArg); Union structs expose accessors to test whether they're of a given type and to get hold of the data of that type. They also expose setters that set the union as being of a particular type and return a reference to the union's internal storage where that type could be stored. The one exception is the object type, which uses a somewhat different form of sette...
Streams - Plugins
in an effort to pass the plug-in data that was already on the way, rather than just discarding it. All NPP_Write calls for streaming data eventually stop, and NPP_Write calls will be completed only for data requested with NPN_RequestRead. The browser does not create a new stream for each byte range it requests. Instead, additional NPP_WriteReady and NPP_Write calls occur on the same stream. An in
dividual call to NPN_RequestRead can request discontiguous ranges, and you can have many outstanding NPN_RequestRead calls. There is no guarantee that NPP_Write will receive requests for ranges in the same order as you requested (although this typically is the case; the server controls the order). So, you'll need to pay attention to the offsets as data is being written. The stream processes all byte...
...inked list of NPByteRange objects, which the plug-in must allocate. Because these objects are copied by the browser, the plug-in can delete them as soon as the call to NPN_RequestRead returns. The plug-in can request multiple ranges, either through a list of NPByteRange objects in a single call to NPN_RequestRead or through multiple calls to NPN_RequestRead. In this case, the browser can write in
dividual ranges in any order, with any number of NPP_WriteReady and NPP_Write calls. Sending the Stream in File Mode If the stream is sent in file mode, the browser saves the entire stream to a local file and passes the full file path to the plug-in instance through the NPP_StreamAsFile method. Use this feature only as a last resort; plug-ins should implement an incremental stream-based interface w...
ANGLE_instanced_arrays - Web APIs
le without the "ANGLE" suffix. Despite the name "ANGLE", this extension works on any device if the hardware supports it and not just on Windows when using the ANGLE library. "ANGLE" just indicates that this extension has been written by the ANGLE library authors. Constants This extension exposes one new constant, which can be used in the gl.getVertexAttrib() method: ext.VERTEX_ATTRIB_ARRAY_
DIVISOR_ANGLE Returns a GLint describing the frequency
divisor used for instanced rendering when used in the gl.getVertexAttrib() as the pname parameter. Methods This extension exposes three new methods. ext.drawArraysInstancedANGLE() Behaves identically to gl.drawArrays() except that multiple instances of the range of elements are executed, and the instance advances for each iteration. ...
... ext.drawArraysInstancedANGLE() Behaves identically to gl.drawArrays() except that multiple instances of the range of elements are executed, and the instance advances for each iteration. ext.drawElementsInstancedANGLE() Behaves identically to gl.drawElements() except that multiple instances of the set of elements are executed and the instance advances between each set. ext.vertexAttrib
DivisorANGLE() Modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with ext.drawArraysInstancedANGLE() and ext.drawElementsInstancedANGLE(). Examples Enabling the extension: var ext = gl.getExtension('ANGLE_instanced_arrays'); Specifications Specification Status Comment ANGLE_instanced_arraysThe definition of...
AnalyserNode - Web APIs
n AnalyserNode has exactly one input and one output. The node works even if the output is not connected. ...
... Properties Inherits properties from its parent, AudioNode. AnalyserNode.fftSize Is an unsigned long value representing the size of the FFT (Fast Fourier Transform) to be used to determine the frequency domain. AnalyserNode.frequencyBinCount Read o...
Animation.commitStyles() - Web APIs
d of the Web Animations API's Animation interface commits the end styling state of an animation to the element being animated, even after that animation has been removed. It will cause the end styling state to be written to the element being animated, in the form of properties inside a style attribute. Syntax animation.commitStyles(); Parameters None. Return value None. ...
...ation interface commits the end styling state of an animation to the element being animated, even after that animation has been removed. It will cause the end styling state to be written to the element being animated, in the form of properties inside a style attribute. Syntax animation.commitStyles(); Parameters None. Return value None. Examples const
divElem = document.querySelector('
div'); document.body.addEventListener('mousemove', evt => { let anim =
divElem.animate( { transform: `translate(${ evt.clientX}px, ${evt.clientY}px)` }, { duration: 500, fill: 'forwards' } ); anim.commitStyles(); }); Specifications Specification Status Comment Web AnimationsThe definition of 'commitStyles()' in that specification. Working Draft ...
AnimationEvent - Web APIs
The AnimationEvent interface represents events providing information related to animations. ...
... Properties Also inherits properties from its parent Event. AnimationEvent.animationName Read only Is a DOMString containing the value of the animation-name that generated the animation. AnimationEvent.elapsedTime Read only Is a float...
Attr - Web APIs
The Attr interface represents one of a DOM element's attributes as an object. In most DOM methods, you will directly retrieve the attribute as a string (e.g., Element.getAttribute()), but certain functions (e.g., Element.getAttributeNode()) or means of iterating return Attr types. ...
...You should revise your code accordingly. See Deprecated properties and methods for a complete list. Properties name Read only The attribute's name. namespaceURI Re...
AudioBufferSourceNode - Web APIs
It's especially useful for playing back audio which has particularly stringent timing accuracy requirements, such as for sounds that must match a specific rhythm and can be kept in memory rather than being played from disk or the network. To play sounds which require accurate timing but must be streamed from the network or played from disk, use a AudioWorkletNode to implement its playback. ...
...If there's no buffer set--that is, if buffer is null--the output contains a single channel of silence (every sample is 0). An AudioBufferSourceNode can only be played once; after ea...
AudioContext - Web APIs
ion of the nodes it contains and the execution of the audio processing, or decoding. You need to create an AudioContext before you do anything else, as everything happens inside a context. It's recommended to create one AudioContext and reuse it instead of initializing a new one each time, and it's OK to use a single AudioContext for several different audio source and pipeline concurrently. ...
... Properties Also inherits properties from its parent interface, BaseAudioContext. AudioContext.baseLatency Read only Returns the number of seconds of processing latency incurred by the AudioContext passing the audio from the AudioDestinationNode to ...
BaseAudioContext.createGain() - Web APIs
level specified by the node's GainNode.gain a-rate parameter. Example The following example shows basic usage of an AudioContext to create a GainNode, which is then used to mute and unmute the audio when a Mute button is clicked by changing the gain property value. ...
... parameter. Example The following example shows basic usage of an AudioContext to create a GainNode, which is then used to mute and unmute the audio when a Mute button is clicked by changing the gain property value. ...
BatteryManager.charging - Web APIs
A Boolean value indicating whether or not the device's battery is currently being charged. Syntax var charging = battery.charging On return, charging indicates whether or not the battery, which is a BatteryManager object, is currently being charged; if the battery is charging, this value is true. Otherwise, the value is false. ...
... Boolean value indicating whether or not the device's battery is currently being charged. Syntax var charging = battery.charging On return, charging indicates whether or not the battery, which is a BatteryManager object, is currently being charged; if the battery is charging, this value is true. Otherwise, the value is false. ...
BatteryManager.chargingTime - Web APIs
browsers round them to a higher interval (typically to the closest 15 minutes) for privacy reasons. Syntax var time = battery.chargingTime On return, time is the remaining time in seconds until the battery, which is a BatteryManager object, is fully charged, or 0 if the battery is already fully charged. If the battery is currently discharging, this value is Infinity. ...
...cally to the closest 15 minutes) for privacy reasons. Syntax var time = battery.chargingTime On return, time is the remaining time in seconds until the battery, which is a BatteryManager object, is fully charged, or 0 if the battery is already fully charged. If the battery is currently discharging, this value is Infinity. ...
BatteryManager.dischargingTime - Web APIs
s) for privacy reasons. Syntax var time = battery.dischargingTime On return, time is the remaining time in seconds until the battery, which is a BatteryManager object, is fully discharged and the system will suspend. This value is Infinity if the battery is currently charging rather than discharging, or if the system is unable to report the remaining discharging time. ...
...dischargingTime On return, time is the remaining time in seconds until the battery, which is a BatteryManager object, is fully discharged and the system will suspend. This value is Infinity if the battery is currently charging rather than discharging, or if the system is unable to report the remaining discharging time. ...
BatteryManager.level - Web APIs
the system's battery charge level scaled to a value between 0.0 and 1.0. A value of 0 means the battery, which is a BatteryManager object, is empty and the system is about to be suspended. A value of 1.0 means the battery is full. ...
... to a value between 0.0 and 1.0. A value of 0 means the battery, which is a BatteryManager object, is empty and the system is about to be suspended. A value of 1.0 means the battery is full. A value of 1.0 is also returned if the implementation isn't able to determine the battery charge level or if the system is not battery-powered. ...
BeforeInstallPromptEvent - Web APIs
The BeforeInstallPromptEvent is fired at the Window.onbeforeinstallprompt handler before a user is prompted to "install" a web site to a home screen on mobile. This interface inherits from the Event interface. ...
... Properties Inherits properties from its parent, Event. BeforeInstallPromptEvent.platforms Read only Returns an array of DOMString items containing the platforms on which the event was dispatched. This is provided for user agents that want to pre...
BeforeUnloadEvent - Web APIs
non-empty string is assigned to the returnValue Event property, a dialog box appears, asking the users for confirmation to leave the page (see example below). When no value is provided, the event is processed silently. Some implementations only show the dialog box if the frame or any embedded frame receives a user gesture or user interaction. See Browser compatibility for more information. ...
...1="86" y1="25" x2="116" y2="25" stroke="#D4DDE4"/><a xlink:href="/docs/Web/API/BeforeUnloadEvent" target="_top"><rect x="116" y="1" width="170" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="201" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">BeforeUnloadEvent</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} Bubbles No Cancelable Yes Target objects defaultView Interface Event Examples window.addEventListener("beforeunload", function( event ) { event.returnValue = "\o/"; }); // is equivalent to window.addEventListener("beforeunload", function( event ) { event.preventDefault(); })...
BluetoothDevice - Web APIs
The BluetoothDevice interface of the Web Bluetooth API represents a Bluetooth device inside a particular script execution environment. ...
...name; readonly attribute BluetoothRemoteGATTServer? gatt; readonly attribute FrozenArray uuids; Promise watchAdvertisements(); void unwatchAdvertisements(); readonly attribute boolean watchingAdvertisements; }; Bluetoot...
BroadcastChannel - Web APIs
BroadcastChannel interface represents a named channel that any browsing context of a given origin can subscribe to. It allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via a message event fired at all BroadcastChannel objects listening to the channel. Note: This feature is available in Web Workers. ...
... Properties This interface also inherits properties from its parent, EventTarget. BroadcastChannel.name Read only Returns a DOMString, the name of the channel. Event handlers BroadcastChannel.onmessage An EventHandler property that specifi...
CDATASection - Web APIs
a CDATA section looks like: <![CDATA[ ... ]]> For example: <foo>Here is a CDATA section: <![CDATA[ < > & ]]> with all kinds of unescaped text.</foo> The only sequence which is not allowed within a CDATA section is the closing sequence of a CDATA section itself, ]]>: <![CDATA[ ]]> will cause an error ]]> Note that CDATA sections should not be used within HTML; they only work in XML. ...
... Methods This interface has no specific methods and implements those of its parent Text. Specifications Specification Status Comment DOMThe definition of 'CDATASection' in that specification. Living Standard...
CSSCounterStyleRule - Web APIs
The CSSCounterStyleRule interface represents an @counter-style at-rule. ...
... CSSCounterStyleRule.name Is a DOMString object that contains the serialization of the <counter-style-name> defined for the associated rule. CSSCounterStyleRule.system Is a DOMString object that contains the serialization of the system descriptor defined...
CSSKeywordValue - Web APIs
Creates a new CSSKeywordValue object. Properties CSSKeywordValue.value Returns or sets the value of the CSSKeywordValue. Methods Inherits methods from CSSStyleValue. Examples The following example resets the CSS display property to its defaults, setting the inline style attribute to style="display: initial" if viewed in the developer tools inspector. ...
...ordValue. Methods Inherits methods from CSSStyleValue. Examples The following example resets the CSS display property to its defaults, setting the inline style attribute to style="display: initial" if viewed in the developer tools inspector. #myElement { display: flex; } <
div id="myElement">Check the developer tools to see the log in the console and to inspect the style attribute on this
div.</
div> let myElement = document.getElementById('myElement').attributeStyleMap; myElement.set('display', new CSSKeywordValue('initial')); console.log( myElement.get('display').value); // 'initial' Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSKeywordValue' in that specification. Working Draft Initial definition. ...
CSSPrimitiveValue - Web APIs
values. (For example, a pixel value cannot be converted to a centimeter value.) Percentage values can't be converted since they are relative to the parent value (or another property value). There is one exception for color percentage values: since a color percentage value is relative to the range 0-255, a color percentage value can be converted to a number (see also the RGBColor interface). ...
... CSSPrimitiveValue.primitiveType Read only An unsigned short representing the type of the value. Possible values are: Constant Description CSS_ATTR The value is an attr() function. The value can be obtained by using the getStringValue() met...
CSSValueList - Web APIs
The CSSValueList interface derives from the CSSValue interface and provides the abstraction of an ordered collection of CSS values. Some properties allow an empty list in their syntax. In that case, these properties take the none identifier. So, an empty list means that the property has the value none. The items in the CSSValueList are accessible via an integral index, starting from 0. ...
... CSSValueList.lengthRead only An unsigned long representing the number of CSSValues in the list. Methods CSSValueList.item() This method is used to retrieve a CSSValue by ordinal index. The order in this collection represents the order of the values in the CSS style ...
CSS Typed Object Model API - Web APIs
expected, it will return the value of CSSKeyword.value. CSSNumericValue An interface representing operations that all numeric values can perform, including: CSSNumericValue.add - Adds supplied numbers to the CSSNumericValue. CSSNumericValue.sub - Subtracts supplied numbers to the CSSNumericValue. CSSNumericValue.mul - Multiplies supplied numbers to the CSSNumericValue. CSSNumericValue.
div -
Divides a supplied number by other numbers, throwing an error if 0. CSSNumericValue.min - Returns the minimum value passed CSSNumericValue.max - Returns the maximum value passed CSSNumericValue.equals - Returns true if all the values are the exact same type and value, in the same order. Otherwise, false CSSNumericValue.to - Converts value into another one with the specified unit. CSSN...
...ne with the specified unit. CSSNumericValue.toSum CSSNumericValue.type CSSNumericValue.parse - Returns a number parsed from a CSS string CSSPositionValue Represents values for properties that take a position, for example object-position. CSSTransformValue An interface representing a list of transform list values. They "contain" one or more CSSTransformComponents, which represent in
dividual transform function values. CSSUnparsedValue Represents property values that reference custom properties. It consists of a list of string fragments and variable references. Specifications Specification Status Comment CSS Typed OM Level 1 Working Draft Initial definition. ...
CanvasRenderingContext2D.addHitRegion() - Web APIs
nPath(); ctx.arc(100, 110, 50, 0, Math.PI); ctx.stroke(); Edit the code below to see your changes update live in the canvas. ...
...ou don't see the full smiley, check the browser compatibility table to see if your current browser supports hit regions already; you might need to activate a preference.) Playable code <canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas> <
div class="playable-buttons"> <input id="edit" type="button" value="Edit" /> <input id="reset" type="button" value="Reset" /> </
div> <textarea id="code" class="playable-code" style="height:250px"> ctx.beginPath(); ctx.arc(100, 100, 75, 0, 2 * Math.PI, false); ctx.lineWidth = 5; ctx.stroke(); // eyes ctx.beginPath(); ctx.arc(70, 80, 10, 0, 2 * Math.PI, false); ctx.arc(130, 80, 10, 0, 2 * Math.PI, false); ctx.fill(); ctx.addHitRegion({id: "eyes"}); // mouth ctx.beginPath(); ctx.arc(100, 110, 50, 0, Math.PI, false); ctx.stroke...
CanvasRenderingContext2D.arcTo() - Web APIs
w the starting point. HTML <canvas id="canvas"></canvas> JavaScript const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.moveTo(180, 90); ctx.arcTo(180,130, 110,130, 130); ctx.lineTo(110, 130); ctx.stroke(); Result Live demo More sophisticated demo of the method. You can play around with range input to see how arc changes. ...
...th(); ctx.moveTo(180, 90); ctx.arcTo(180,130, 110,130, 130); ctx.lineTo(110, 130); ctx.stroke(); Result Live demo More sophisticated demo of the method. You can play around with range input to see how arc changes. ...
CanvasRenderingContext2D.filter - Web APIs
JavaScript const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); ctx.filter = 'blur(4px)'; ctx.font = '48px serif'; ctx.fillText('Hello world', 50, 100); Result Applying multiple filters You can combine as many filters as you like. This example applies the contrast, sepia, and drop-shadow filters to a photo of a gecko. ...
...(4px)'; ctx.font = '48px serif'; ctx.fillText('Hello world', 50, 100); Result Applying multiple filters You can combine as many filters as you like. This example applies the contrast, sepia, and drop-shadow filters to a photo of a gecko. ...
CanvasRenderingContext2D.miterLimit - Web APIs
e; Options value A number specifying the miter limit ratio, in coordinate space units. Zero, negative, Infinity, and NaN values are ignored. The default value is 10.0. Examples Using the miterLimit property See the chapter Applying styles and color in the Canvas tutorial for more information. ...
... are ignored. The default value is 10.0. Examples Using the miterLimit property See the chapter Applying styles and color in the Canvas tutorial for more information. ...
Applying styles and colors - Web APIs
encyValue Applies the specified transparency value to all future shapes drawn on the canvas. The value must be between 0.0 (fully transparent) to 1.0 (fully opaque). This value is 1.0 (fully opaque) by default. The globalAlpha property can be useful if you want to draw a lot of shapes on the canvas with similar transparency, but otherwise it's generally more useful to set the transparency on in
dividual shapes when setting their colors. Because the strokeStyle and fillStyle properties accept CSS rgba color values, we can use the following notation to assign a transparent color to them. // Assigning transparent colors to stroke and fill style ctx.strokeStyle = 'rgba(255, 0, 0, 0.5)'; ctx.fillStyle = 'rgba(255, 0, 0, 0.5)'; The rgba() function is similar to the rgb() function but it has ...
...} } <canvas id="canvas" width="150" height="150"></canvas> draw(); ScreenshotLive sample An example using rgba() In this second example, we do something similar to the one above, but instead of drawing circles on top of each other, I've drawn small rectangles with increasing opacity. Using rgba() gives you a little more control and flexibility because we can set the fill and stroke style in
dividually. function draw() { var ctx = document.getElementById('canvas').getContext('2d'); // Draw background ctx.fillStyle = 'rgb(255, 221, 0)'; ctx.fillRect(0, 0, 150, 37.5); ctx.fillStyle = 'rgb(102, 204, 0)'; ctx.fillRect(0, 37.5, 150, 37.5); ctx.fillStyle = 'rgb(0, 153, 255)'; ctx.fillRect(0, 75, 150, 37.5); ctx.fillStyle = 'rgb(255, 51, 0)'; ctx.fillRect(0, 112.5, 150, 37...
Drawing text - Web APIs
The following diagram from the WHATWG demonstrates the various baselines supported by the textBaseline property. ...
...ample Edit the code below and see your changes update live in the canvas: ctx.font = '48px serif'; ctx.textBaseline = 'hanging'; ctx.strokeText('Hello world', 0, 100); Playable code <canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas> <
div class="playable-buttons"> <input id="edit" type="button" value="Edit" /> <input id="reset" type="button" value="Reset" /> </
div> <textarea id="code" class="playable-code"> ctx.font = "48px serif"; ctx.textBaseline = "hanging"; ctx.strokeText("Hello world", 0, 100);</textarea> var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); var textarea = document.getElementById('code'); var reset = document.getElementById('reset'); var edit = document.getElementById('edit'); var code = textarea.value; ...
CharacterData - Web APIs
The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't abstract. ...
... CharacterData.data Is a DOMString representing the textual data contained in this object. CharacterData.length Read only Returns an unsigned long representing the size of the string contained in CharacterD...
Comment - Web APIs
The Comment interface represents textual notations within markup; although it is generally not visually shown, such comments are available to be read in the source view. Comments are represented in HTML and XML as content between '<!--' and '-->'. In XML, the character sequence '--' cannot be used within a comment. ...
... Constructor Comment() Returns a Comment object with the parameter as its textual content. Methods This interface has no specific method, but inherits those of its parent, CharacterData, and indi...
CompositionEvent - Web APIs
The DOM CompositionEvent represents events that occur due to the user indirectly entering text. ...
... Properties This interface also inherits properties of its parent, UIEvent, and its ancestor -- Event. CompositionEvent.data Read only Returns the characters generated by the input method that raised the event; its varies depending on the type of...
DOMRect - Web APIs
A DOMRect represents a rectangle. The type of box represented by the DOMRect is specified by the method or property that returned it. For example, VREyeParameters.renderRect from the defunct WebVR API specified the viewport of a canvas into which visuals for one eye of a head mounted display should be rendered. It inherits from its parent, DOMRectReadOnly. ...
... Properties DOMRect inherits properties from its parent, DOMRectReadOnly. The difference is that they are not read-only anymore. DOMRectReadOnly.x The x coordinate of the DOMRect's origin. DOMRectReadOnly.y The y coordinate of the DOMRect's origin. DOMRectReadOnly.wid...
DataTransfer.effectAllowed - Web APIs
llowed has no effect and the old value is retained. Internet Explorer will change the value to be lowercased; thus, linkMove will become linkmove, and so on. Example This example shows the use of the effectAllowed and dropEffect properties. ...
...lementById(data)); } function dragover_handler(ev) { console.log("dragOver: dropEffect = " + ev.dataTransfer.dropEffect + " ; effectAllowed = " + ev.dataTransfer.effectAllowed); ev.preventDefault(); // Set the dropEffect to move ev.dataTransfer.dropEffect = "move" } </script> <body> <h1>Examples <code>DataTransfer</code>.{<code>dropEffect</code>, <code>effectAllowed</code>} properties</h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Standa...
DataTransfer.setData() - Web APIs
e drag data to add to the drag object. data A DOMString representing the data to add to the drag object. Return value void Example This example shows the use of the DataTransfer object's getData(), setData() and clearData() methods. <!DOCTYPE html> <html lang=en> <title>Examples of DataTransfer's setData(), getData() and clearData()</title> <meta content="width=device-width"> <style>
div { margin: 0em; padding: 2em; } #source { color: blue; border: 1px solid black; } #target { border: 1px solid black; } </style> <script> function dragstart_handler(ev) { console.log("dragStart"); // Change the source element's background color to signify drag has started ev.currentTarget.style.border = "dashed"; // Set the drag's format and data. Use the event tar...
...ev.preventDefault(); // Get the data, which is the id of the drop target var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); // Clear the drag data cache (for all formats/types) ev.dataTransfer.clearData(); } </script> <body> <h1>Examples of <code>DataTransfer</code>: <code>setData()</code>, <code>getData()</code>, <code>clearData()</code></h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Standa...
DataTransfer.setDragImage() - Web APIs
mple shows how to use the setDragImage() method. Note the example refers to an image file named example.gif. If that file is present, it will be used as the drag image and if that file is not present, the browser will use its default drag image. demo <!DOCTYPE html> <html lang=en> <title>Example of DataTransfer.setDragImage()</title> <meta name="viewport" content="width=device-width"> <style>
div { margin: 0em; padding: 2em; } #source { color: blue; border: 1px solid black; } #target { border: 1px solid black; } </style> <script> function dragstart_handler(ev) { console.log("dragStart"); // Set the drag's format and data. Use the event target's id for the data ev.dataTransfer.setData("text/plain", ev.target.id); // Create an image and use it for the drag ...
..., 10); } function dragover_handler(ev) { console.log("dragOver"); ev.preventDefault(); } function drop_handler(ev) { console.log("Drop"); ev.preventDefault(); // Get the data, which is the id of the drop target var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); } </script> <body> <h1>Example of <code>DataTransfer.setDragImage()</code></h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Standa...
DataTransferItemList.DataTransferItem() - Web APIs
unction (s){ console.log("... ...
... "move" } function dragend_handler(ev) { console.log("dragEnd"); var dataList = ev.dataTransfer.items; // Clear any remaining drag data dataList.clear(); } HTML <
div> <p id="source" ondragstart="dragstart_handler(event);" ondragend="dragend_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> CSS
div { margin: 0em; padding: 2em; } #source { color: blue; border: 1px solid black; } #target { border: 1px solid black; } Result Drag and Drop demo link Specifications Specification Status Comment HTML Living StandardThe definition of 'DataTransfe...
DataTransferItemList.length - Web APIs
unction (s){ console.log("... ...
... "move" } function dragend_handler(ev) { console.log("dragEnd"); var dataList = ev.dataTransfer.items; // Clear any remaining drag data dataList.clear(); } HTML <
div> <p id="source" ondragstart="dragstart_handler(event);" ondragend="dragend_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> CSS
div { margin: 0em; padding: 2em; } #source { color: blue; border: 1px solid black; } #target { border: 1px solid black; } Result Drag and Drop demo link Specifications Specification Status Comment HTML Living StandardThe definition of 'length' in ...
Document.getElementsByClassName() - Web APIs
test', inside of an element that has the ID of 'main': document.getElementById('main').getElementsByClassName('test') Get the first element with a class of 'test', or undefined if there is no matching element: document.getElementsByClassName('test')[0] We can also use methods of Array.prototype on any HTMLCollection by passing the HTMLCollection as the method's this value. ...
...'test') Get the first element with a class of 'test', or undefined if there is no matching element: document.getElementsByClassName('test')[0] We can also use methods of Array.prototype on any HTMLCollection by passing the HTMLCollection as the method's this value. Here we'll find all
div elements that have a class of 'test': var testElements = document.getElementsByClassName('test'); var test
Divs = Array.prototype.filter.call(testElements, function(testElement){ return testElement.nodeName === '
DIV'; }); Get the first element whose class is 'test' This is the most commonly used method of operation. <html> <body> <
div id="parent-id"> <p>hello world 1</p> <p class="test">hello world 2</p> <p>hello world 3</p> <p>hello world 4</p> </
div> <sc...
Document.mozSetImageElement() - Web APIs
lement(imageElementId, imageElement); Parameters imageElementId is a string indicating the name of an element that has been specified as a background image using the -moz-element CSS function. imageElement is the new element to use as the background corresponding to that image element string. Specify null to remove the background element. Example This example changes the background of a <
div> block each time the block is clicked by the user. View this example live. <style type="text/css"> #mybox { background-image: -moz-element(#canvasbg); text-align: center; width: 400px; height: 400px; cursor: pointer; } </style> The CSS defined by the <style> block above is used by our <
div> to use an element with the id "canvasbg" as its background. var c = 0x00; func...
...It creates a new <canvas> with the width and height set to 100 pixels, then draws into it a 50 by 50 pixel square. Each time the function is called, the square is a different color (its red component is increased each time), so each time the user clicks the element, the background is filled with a brighter and brighter pattern of red tiles. Once the canvas is drawn, document.mozSetImag...
Document.queryCommandState() - Web APIs
The queryCommandState() method will tell you if the current selection has a certain Document.execCommand() command applied. Syntax queryCommandState(String command) Parameters command is a command from Document.execCommand() Return value queryCommandState() can return a Boolean value or null if the state is unknown. ...
... The queryCommandState() method will tell you if the current selection has a certain Document.execCommand() command applied. Syntax queryCommandState(String command) Parameters command is a command from Document.execCommand() Return value queryCommandState() can return a Boolean value or null if the state is unknown. ...
Document - Web APIs
The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. The DOM tree includes elements such as <body> and <table>, among many others. It provides functionality globally to the document, like how to obtain the page's URL and create new elements in the document. ...
...Depending on the document's type (e.g. HTML, XML, SVG, ...), a larger API is available: HTML documents, served with the "text/html" content type, also implement the HTMLDocument interface, whereas XML and SVG documents implement the XMLDocumen...
DocumentFragment - Web APIs
o parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is due to the fact that the document fragment isn't part of the active document tree structure. Changes made to the fragment don't affect the document (even on reflow) or incur any performance impact when changes are made. ...
... Properties This interface has no specific properties, but inherits those of its parent, Node, and implements those of the ParentNode interface. ParentNode.children Read only Returns a live HTMLCollection containing all objects of type Elemen...
DocumentType - Web APIs
The DocumentType interface represents a Node containing a doctype. ...
... DocumentType.entities Read only A NamedNodeMap of entities declared in the DTD. Every node in this map implements the Entity interface. DocumentType.internalSubset Read only A DOMString of the internal subset, or null if there is...
Element: click event - Web APIs
Set background-color: rgba(0,0,0,0) Set opacity: 0 and an explicit background-color other than transparent For IE8 and IE9: Set filter: alpha(opacity=0); and an explicit background-color other than transparent Safari Mobile Safari Mobile 7.0+ (and likely earlier versions too) suffers from a bug where click events aren't fired on elements that aren't typically interactive (e.g. <
div>) and which also don't have event listeners directly attached to the elements themselves (i.e. event delegation is being used). See this live example for a demonstration. See also Safari's docs on making elements clickable and the definition of "clickable element". Known workarounds for this bug: Set cursor: pointer; on the element or any of its ancestors. Add a dummy onclick="void(0)" attri...
...Safari's docs on making elements clickable and the definition of "clickable element". Known workarounds for this bug: Set cursor: pointer; on the element or any of its ancestors. Add a dummy onclick="void(0)" attribute to the element or any of its ancestors up to but not including <body>. Use a typically interactive element (e.g., <a>) instead of one that isn't typically interactive (e.g., <
div>). Stop using click event delegation. Safari Mobile considers the following elements to be typically interactive (and thus they aren't affected by this bug): <a> (but it must have an href) <area> (but it must have an href) <button> <img> <input> <label> (but it must be associated with a form control) <textarea> This list is incomplete; you can help MDN by doing further testing/resear...
Element: compositionend event - Web APIs
Chinese character using a Pinyin IME. ...
... document.querySelector('input[type="text"]'); inputElement.addEventListener('compositionend', (event) => { console.log(`generated characters were: ${event.data}`); }); Live example HTML <
div class="control"> <label for="name">On macOS, click in the textbox below,<br> then type <kbd>option</kbd> + <kbd>`</kbd>, then <kbd>a</kbd>:</label> <input type="text" id="example" name="example"> </
div> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents" rows="8" cols="25"></textarea> <button class="clear-log">Clear</button> </
div> CSS body { padding: .2rem; display: grid; grid-template-areas: "control log"; } .control { grid-area: control; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button ...
Element: compositionstart event - Web APIs
inese character using a Pinyin IME. ...
...ocument.querySelector('input[type="text"]'); inputElement.addEventListener('compositionstart', (event) => { console.log(`generated characters were: ${event.data}`); }); Live example HTML <
div class="control"> <label for="name">On macOS, click in the textbox below,<br> then type <kbd>option</kbd> + <kbd>`</kbd>, then <kbd>a</kbd>:</label> <input type="text" id="example" name="example"> </
div> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents" rows="8" cols="25"></textarea> <button class="clear-log">Clear</button> </
div> CSS body { padding: .2rem; display: grid; grid-template-areas: "control log"; } .control { grid-area: control; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button ...
Element: compositionupdate event - Web APIs
nese character using a Pinyin IME. ...
...cument.querySelector('input[type="text"]'); inputElement.addEventListener('compositionupdate', (event) => { console.log(`generated characters were: ${event.data}`); }); Live example HTML <
div class="control"> <label for="name">On macOS, click in the textbox below,<br> then type <kbd>option</kbd> + <kbd>`</kbd>, then <kbd>a</kbd>:</label> <input type="text" id="example" name="example"> </
div> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents" rows="8" cols="25"></textarea> <button class="clear-log">Clear</button> </
div> CSS body { padding: .2rem; display: grid; grid-template-areas: "control log"; } .control { grid-area: control; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button ...
Element.getElementsByClassName() - Web APIs
However the following code will not work as one might expect because "matches" will change as soon as any "colorbox" class is removed. var matches = element.getElementsByClassName('colorbox'); for (var i=0; i<matches.length; i++) { matches[i].classList.remove('colorbox'); matches.item(i).classList.add('hueframe'); } Instead, use another method, such as: v...
...ode finds descendant elements with the "colorbox" class, adds the class "hueframe", by calling item(0), then removes "colorbox" (using array notation). Another element (if any are left) will then become item(0). Filtering the results using array methods We can also use methods of Array.prototype on any HTMLCollection by passing the HTMLCollection as the method's this value. Here we'll find all <
div> elements that have a class of test: var testElements = document.getElementsByClassName('test'); var test
Divs = Array.prototype.filter.call(testElements, function(testElement) { return testElement.nodeName === '
DIV'; }); Specifications Specification Status Comment DOMThe definition of 'Element.getElementsByClassName()' in that specification. Living Standard Init...
Element.innerHTML - Web APIs
Use Node.textContent to get a raw copy of these text nodes' contents. To insert the HTML into the document rather than replace the contents of an element, use the method insertAdjacentHTML(). Syntax const content = element.innerHTML; element.innerHTML = htmlString; Value A DOMString containing the HTML serialization of the element's descendants. ...
... a number of mouse events on the box that contains our log: var boxElem = document.querySelector(".box"); boxElem.addEventListener("mousedown", logEvent); boxElem.addEventListener("mouseup", logEvent); boxElem.addEventListener("click", logEvent); boxElem.addEventListener("mouseenter", logEvent); boxElem.addEventListener("mouseleave", logEvent); HTML The HTML is quite simple for our example. <
div class="box"> <
div><strong>Log:</strong></
div> <
div class="log"></
div> </
div> The <
div> with the class "box" is just a container for layout purposes, presenting the contents with a box around it. The <
div> whose class is "log" is the container for the log text itself. CSS The following CSS styles our example content. .box { width: 600px; height: 300px; border: 1px solid black; padd...
Element: keypress event - Web APIs
stead. Interface KeyboardEvent Bubbles Yes Cancelable Yes Default Action Varies: keypress event; launch text composition system; blur and focus events; DOMActivate event; other event Examples addEventListener keypress example This example logs the KeyboardEvent.code value whenever you press a key after focussing the <input> element. ...
...tion Varies: keypress event; launch text composition system; blur and focus events; DOMActivate event; other event Examples addEventListener keypress example This example logs the KeyboardEvent.code value whenever you press a key after focussing the <input> element. ...
Element: mouseleave event - Web APIs
of its descendants, whereas mouseout is fired when the pointer leaves the element or leaves one of the element's descendants (even if the pointer is still within the element). One mouseleave event is sent to each element of the hierarchy when leaving them. ...
...
div represented here. One single mouseout event is sent to the deepest element of the DOM tree, then it bubbles up the hierarchy until it is canceled by a handler or reaches the root. Examples The mouseout documentation has an example illustrating the difference between mouseout and mouseleave. mouseleave The following trivial example uses the mouseenter event to change the border on the <
div> when the mouse enters the space alloted to it. It then adds an item to the list with the number of the mouseenter or mouseleave event. HTML <
div id='mouseTarget'> <ul id="unorderedList"> <li>No events yet!</li> </ul> </
div> CSS Styling the <
div> to make it more visible. #mouseTarget { box-sizing: border-box; width:15rem; border:1px solid #333; } JavaScript var enterEventCount = ...
Element.setCapture() - Web APIs
Specification Based on Internet Explorer's implementation. ...
... Specification Based on Internet Explorer's implementation. ...
Element - Web APIs
l kinds of elements. More specific classes inherit from Element. For example, the HTMLElement interface is the base interface for HTML elements, while the SVGElement interface is the basis for all SVG elements. Most functionality is specified further down the class hierarchy. Languages outside the realm of the Web platform, like XUL through the XULElement interface, also implement Element. ...
...It implements the properties of ParentNode, ChildNode, NonDocumentTypeChildNode, and Animatable. Element.attributes Read only Returns a NamedNodeMap object containing the assigned attributes of the corresponding...
ErrorEvent - Web APIs
The ErrorEvent interface represents events providing information related to errors in scripts or in files. ...
... ErrorEvent.message Read only Is a DOMString containing a human-readable error message describing the problem. ErrorEvent.filename Read only Is a DOMString containing the name of the script file in which the error occurred. ErrorEvent.lineno Read only Is an integer ...
EventTarget - Web APIs
plemented by objects that can receive events and may have listeners for them. Element, Document, and Window are the most common event targets, but other objects can be event targets, too. For example XMLHttpRequest, AudioNode, AudioContext, and others. Many event targets (including elements, documents, and windows) also support setting event handlers via onevent properties and attributes. ...
... Methods EventTarget.addEventListener() Registers an event handler of a specific event type on the EventTarget. EventTarget.removeEventListener() Removes an event listener from the EventTarget. EventTarget.dispatchEvent() Dispatches an event to this Even...
ExtendableEvent - Web APIs
es. If waitUntil() is called outside of the ExtendableEvent handler, the browser should throw an InvalidStateError; note also that multiple calls will stack up, and the resulting promises will be added to the list of extend lifetime promises. Note: The behaviour described in the above paragraph was fixed in Firefox 43 (see bug 1180274.) This interface inherits from the Event interface. ...
...It is not available when it is a Window, or the scope of another kind of worker. Constructor ExtendableEvent() Creates a new ExtendableEvent object. Properties Doesn't implement any specific properties, but inherits properties from it...
File - Web APIs
ag and drop operation's DataTransfer object, or from the mozGetAsFile() API on an HTMLCanvasElement. A File object is a specific kind of a Blob, and can be used in any context that a Blob can. In particular, FileReader, URL.createObjectURL(), createImageBitmap(), and XMLHttpRequest.send() accept both Blobs and Files. See Using files from web applications for more information and examples. ...
... Instance properties File.prototype.lastModified Read only Returns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight). File.prototype.lastModifiedDate Read only Returns the last modified Date of the file referenced ...
FocusEvent - Web APIs
The FocusEvent interface represents focus-related events, including focus, blur, focusin, and focusout. ...
... Properties This interface also inherits properties from its parent UIEvent, and indirectly from Event. FocusEvent.relatedTarget Is an EventTarget representing a secondary target for this event. In some cases (such as when tabbing in or out a page...
GainNode.gain - Web APIs
oParam returned is read-only, the value it represents is not. Example The following example shows basic usage of an AudioContext to create a GainNode, which is then used to mute and unmute the audio when a Mute button is clicked by changing the gain property value. ...
...ts is not. Example The following example shows basic usage of an AudioContext to create a GainNode, which is then used to mute and unmute the audio when a Mute button is clicked by changing the gain property value. ...
GainNode - Web APIs
specific method; inherits methods from its parent, AudioNode. Example The following example shows basic usage of an AudioContext to create a GainNode, which is then used to mute and unmute the audio when a Mute button is clicked by changing the gain property value. ...
... AudioNode. Example The following example shows basic usage of an AudioContext to create a GainNode, which is then used to mute and unmute the audio when a Mute button is clicked by changing the gain property value. ...
GlobalEventHandlers.oncontextmenu - Web APIs
. Examples Disabling context menus This snippet prevents context menus from opening in the window. The context menu typically appears upon a right click. HTML <p>Try opening the context menu. Is it disabled?<p> JavaScript window.oncontextmenu = (e) => { e.preventDefault(); } Result Pausing an animation This example pauses a spinning shape whenever you open the context menu. ...
...xt menus This snippet prevents context menus from opening in the window. The context menu typically appears upon a right click. HTML <p>Try opening the context menu. Is it disabled?<p> JavaScript window.oncontextmenu = (e) => { e.preventDefault(); } Result Pausing an animation This example pauses a spinning shape whenever you open the context menu. ...
GlobalEventHandlers.ondrag - Web APIs
drag event. Syntax var dragHandler = targetElement.ondrag; Return value dragHandler The drag event handler for element targetElement. Example This example includes the use of the ondrag attribute handler to set an element's drag event handler. ...
...Drop"); ev.currentTarget.style.background = "lightyellow"; ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); } function dragover_handler(ev) { console.log("dragOver"); ev.preventDefault(); } </script> <body> <h1>Examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <
div> <!-- <
div class="source"> --> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Sp...
GlobalEventHandlers.ondragend - Web APIs
agendHandler = targetElement.ondragend; Return value dragendHandler The dragend event handler for element targetElement. Example This example shows two ways to use the ondragend attribute handler to set an element's dragend event handler. ...
...t handlers for the source's enter/leave/end/exit events var el=document.getElementById("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>Examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Standa...
GlobalEventHandlers.ondragenter - Web APIs
ndler = targetElement.ondragenter; Return value dragenterHandler The dragenter event handler for element targetElement. Example This example demonstrates using the ondragenter attribute handler to set an element's dragenter event handler. ...
...t handlers for the source's enter/leave/end/exit events var el=document.getElementById("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>Examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Standa...
GlobalEventHandlers.ondragexit - Web APIs
xitHandler = targetElement.ondragexit; Return value dragexitHandler The dragexit event handler for element targetElement. Example This example demonstrates using the ondragexit attribute handler to set an element's dragexit event handler. ...
...t handlers for the source's enter/leave/end/exit events var el=document.getElementById("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>Examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Stand...
GlobalEventHandlers.ondragleave - Web APIs
ndler = targetElement.ondragleave; Return value dragleaveHandler The dragleave event handler for element targetElement. Example This example demonstrates using the ondragleave attribute handler to set an element's dragleave event handler. ...
...t handlers for the source's enter/leave/end/exit events var el=document.getElementById("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>Examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comment HTML Living Stand...
GlobalEventHandlers.ondragover - Web APIs
r dragoverHandler = targetElement.ondragover; Return value dragoverHandler The dragover event handler for element targetElement. Example This example demonstrates using the ondragover attribute handler to set an element's dragover event handler. ...
...Drop"); ev.currentTarget.style.background = "lightyellow"; ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); } function dragover_handler(ev) { console.log("dragOver"); ev.preventDefault(); } </script> <body> <h1>Examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <
div> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comme...
GlobalEventHandlers.ondragstart - Web APIs
startHandler = targetElement.ondragstart; Return value dragstartHandler The dragstart event handler for element targetElement. Example This example demonstrates using the ondragstart attribute handler to set an element's dragstart event handler. ...
...Drop"); ev.currentTarget.style.background = "lightyellow"; ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); } function dragover_handler(ev) { console.log("dragOver"); ev.preventDefault(); } </script> <body> <h1>Examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <
div> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification Status Comme...
GlobalEventHandlers.ondrop - Web APIs
drop event. Syntax var dropHandler = targetElement.ondrop; Return value dropHandler The drop event handler for element targetElement. Example This example demonstrates the use of the ondrop attribute to define an element's drop event handler. ...
...Drop"); ev.currentTarget.style.background = "lightyellow"; ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); } function dragover_handler(ev) { console.log("dragOver"); ev.preventDefault(); } </script> <body> <h1>Examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <
div class="source"> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> </body> </html> Specifications Specification ...
HTMLAnchorElement - Web APIs
The HTMLAnchorElement interface represents hyperlink elements and provides special properties and methods (beyond those of the regular HTMLElement object interface that they inherit from) for manipulating the layout and presentation of such elements. ...
... Element.accessKey Is a DOMString representing a single character that switches input focus to the hyperlink. HTMLAnchorElement.download Is a DOMString indicating that the linked resource is intended to be download...
HTMLAreaElement - Web APIs
The HTMLAreaElement interface provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <area> elements. ...
... Element.accessKey Is a DOMString containing a single character that switches input focus to the control. HTMLAreaElement.alt Is a DOMString that reflects the alt HTML attribute, containing alternative text for the e...
HTMLAudioElement - Web APIs
The HTMLAudioElement interface provides access to the properties of <audio> elements, as well as methods to manipulate them. It's based on, and inherits properties and methods from, the HTMLMediaElement interface. ...
... Properties No specific properties; inherits properties from its parent, HTMLMediaElement, and from HTMLElement. Methods Inherits methods from its parent, HTMLMediaE...
HTMLBRElement - Web APIs
The HTMLBRElement interface represents a HTML line break element (<br>). It inherits from HTMLElement. ...
... HTMLBRElement.clear Is a DOMString indicating the flow of text around floating objects. Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specification Status Comment HTML Living StandardThe definiti...
HTMLBaseElement - Web APIs
The HTMLBaseElement interface contains the base URI for a document. This object inherits all of the properties and methods as described in the HTMLElement interface. ...
... HTMLBaseElement.href Is a DOMString that reflects the href HTML attribute, containing a base URL for relative URLs in the document. HTMLBaseElement.target Is a DOMString that reflects the target HTML attribute, containing a default target browsing context or frame for...
HTMLBodyElement - Web APIs
The HTMLBodyElement interface provides special properties (beyond those inherited from the regular HTMLElement interface) for manipulating <body> elements. ...
... HTMLBodyElement.aLink Is a DOMString that represents the color of active hyperlinks. HTMLBodyElement.background Is a DOMString that represents the description of the location of the background image resource. Note that this is not an U...
HTMLButtonElement - Web APIs
The HTMLButtonElement interface provides properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <button> elements. ...
... HTMLButtonElement.accessKey Is a DOMString indicating the single-character keyboard key to give access to the button. HTMLButtonElement.autofocus Is a Boolean indicating whether or not the control should have input focus when the page loads, unless the user overrides ...
HTMLCanvasElement - Web APIs
The HTMLCanvasElement interface provides properties and methods for manipulating the layout and presentation of <canvas> elements. The HTMLCanvasElement interface also inherits the properties and methods of the HTMLElement interface. ...
... HTMLCanvasElement.height The height HTML attribute of the <canvas> element is a positive integer reflecting the number of logical pixels (or RGBA values) going down one column of the canvas. When the attribute is not specified, or if it is set to an invalid value, like ...
HTMLDListElement - Web APIs
The HTMLDListElement interface provides special properties (beyond those of the regular HTMLElement interface it also has available to it by inheritance) for manipulating definition list (<dl>) elements. ...
... HTMLDListElement.compact Is a Boolean indicating that spacing between list items should be reduced. Methods No specific methods; inherits methods from its parent, HTMLElement. Specifications Specification Status Comment HTML Living Standar...
HTMLDataElement - Web APIs
The HTMLDataElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <data> elements. ...
... HTMLDataElement.value Is a DOMString reflecting the value HTML attribute, containing a machine-readable form of the element's value. Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specification Status Commen...
HTMLDataListElement - Web APIs
The HTMLDataListElement interface provides special properties (beyond the HTMLElement object interface it also has available to it by inheritance) to manipulate <datalist> elements and their content. ...
... Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specification Status Comment HTM...
HTMLDetailsElement - Web APIs
The HTMLDetailsElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <details> elements. ...
... HTMLDetailsElement.open Is a boolean reflecting the open HTML attribute, indicating whether or not the element's contents (not counting the <summary>) is to be shown to the user. Methods No specific method; inherits methods from its parent, HTMLElement. Events List...
HTMLDialogElement - Web APIs
The HTMLDialogElement interface provides methods to manipulate <dialog> elements. It inherits properties and methods from the HTMLElement interface. ...
... HTMLDialogElement.open A Boolean reflecting the open HTML attribute, indicating whether the dialog is available for interaction. HTMLDialogElement.returnValue A DOMString that sets or returns the return value for the dialog. Methods Inherits methods from its parent...
HTMLDocument - Web APIs
The HTMLDocument interface, which may be accessed through the Window.HTMLDocument property, extends the Window.HTMLDocument property to include methods and properties that are specific to HTML documents. ...
...You can find documentation for the members of HTMLDocument under the Document interface. Specifications HTML Living StandardThe definition of 'HTMLDocument' in that specification. Livin...
HTMLElement.hidden - Web APIs
ntListener("click", function() { document.getElementById("welcome").hidden = true; document.getElementById("awesome").hidden = false; }, false); This code sets up a handler for the welcome panel's "OK" button that hides the welcome panel and makes the follow-up panel--with the curious name "awesome"--visible in its place. HTML The HTML for the two boxes are shown here. The welcome panel <
div id="welcome" class="panel"> <h1>Welcome to Foobar.com!</h1> <p>By clicking "OK" you agree to be awesome every day!</p> <button class="button" id="okButton">OK</button> </
div> This HTML creates a panel (in a <
div> block) that welcomes the user to a site and tells them what they're agreeing to by clicking the OK button. The follow-up panel Once the user clicks the "OK" button in the welcom...
...on" id="okButton">OK</button> </
div> This HTML creates a panel (in a <
div> block) that welcomes the user to a site and tells them what they're agreeing to by clicking the OK button. The follow-up panel Once the user clicks the "OK" button in the welcome panel, the JavaScript code swaps the two panels by changing their respective values for hidden. The follow-up panel looks like this in HTML: <
div id="awesome" class="panel" hidden> <h1>Thanks!</h1> <p>Thank you <strong>so</strong> much for agreeing to be awesome today! Now get out there and do awesome things awesomely to make the world more awesome!</p> </
div> CSS The content is styled using the CSS below. .panel { font: 16px "Open Sans", Helvetica, Arial, sans-serif; border: 1px solid #22d; padding: 12px; width: 500px; ...
HTMLElement - Web APIs
The HTMLElement interface represents any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it. ...
... HTMLElement.accessKey Is a DOMString representing the access key assigned to the element. HTMLElement.accessKeyLabel Read onl...
HTMLEmbedElement - Web APIs
The HTMLEmbedElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <embed> elements. This topic describes the HTMLEmbedElement interface as defined in the standard. It does not address earlier, non-standardized version of the interface. ...
... HTMLEmbedElement.align Is a DOMString representing an enumerated property indicating alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", "center", and "justify". HTMLEmbedElement.height Is a DOMString...
HTMLFieldSetElement - Web APIs
The HTMLFieldSetElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <fieldset> elements. ...
... HTMLFieldSetElement.disabled A Boolean reflecting the disabled HTML attribute, indicating whether the user can interact with the control. HTMLFieldSetElement.elementsRead only The elements belonging to this field set. The type of this property depends on the version ...
HTMLFormControlsCollection - Web APIs
The HTMLFormControlsCollection interface represents a collection of HTML form control elements. It represents the lists returned by the HTMLFormElement interface's elements property and the HTMLFieldSetElement interface's elements property. This interface replaces one method from HTMLCollection, on which it is based. ...
... Methods This interface inherits the methods of its parent, HTMLCollection. HTMLFormControlsCollection.namedItem() Returns the RadioNodeList or the Element in the collection whose name or id matches the specified name, or null if no nodes match. Not...
HTMLHRElement - Web APIs
The HTMLHRElement interface provides special properties (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating <hr> elements. ...
... HTMLHRElement.align Is a DOMString, an enumerated attribute indicating alignment of the rule with respect to the surrounding context. HTMLHRElement.color Is a DOMString representing the name of the color of the rule. HTMLHRElement.noshade Is a Boolean that s...
HTMLHeadElement - Web APIs
The HTMLHeadElement interface contains the descriptive information, or metadata, for a document. This object inherits all of the properties and methods described in the HTMLElement interface. ...
... HTMLHeadElement.profile Is a DOMString representing the URIs of one or more metadata profiles (white space separated). Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specification Status Comment H...
HTMLHeadingElement - Web APIs
The HTMLHeadingElement interface represents the different heading elements, <h1> through <h6>. It inherits methods and properties from the HTMLElement interface. ...
... HTMLHeadingElement.align Is a DOMString representing an enumerated attribute indicating alignment of the heading with respect to the surrounding context. The possible values are "left", "right", "justify", and "center". Methods No specific method; inherits methods ...
HTMLHtmlElement - Web APIs
The HTMLHtmlElement interface serves as the root node for a given HTML document. This object inherits the properties and methods described in the HTMLElement interface. You can retrieve the HTMLHtmlElement object for a given document by reading the value of the document.documentElement property. ...
... HTMLHtmlElement.version Is a DOMString representing the version of the HTML Document Type Definition (DTD) that governs this document. This property should not be used any more as it is non-conforming. Simply omit it. Methods No specific method; inherits methods fr...
HTMLIFrameElement - Web APIs
The HTMLIFrameElement interface provides special properties and methods (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of inline frame elements. ...
... HTMLIFrameElement.align Is a DOMString that specifies the alignment of the frame with respect to the surrounding context. HTMLIFrameElement.allow Is a list of origins the the frame is allowed to display content from. This attribute also accepts the values self and...
HTMLImageElement.loading - Web APIs
or offputting at best and can cause users to click the wrong thing at worst, depending on the exact timing of the deferred loads and reflows. Example The addImageToList() function shown below adds a photo thumbnail to a list of items, using lazy-loading to avoid loading the image from the network until it's actually needed. ...
...ng thing at worst, depending on the exact timing of the deferred loads and reflows. Example The addImageToList() function shown below adds a photo thumbnail to a list of items, using lazy-loading to avoid loading the image from the network until it's actually needed. ...
HTMLImageElement.naturalHeight - Web APIs
nlike height. If the intrinsic height is not available--either because the image does not specify an intrinsic height or because the image data is not available in order to obtain this information, naturalHeight returns 0. Example This example simply displays both the natural, density-adjusted size of an image as well as its rendered size as altered by the page's CSS and other factors. HTML <
div class="box"> <img src="/files/16797/clock-demo-400px.png" class="image"> </
div> <
div class="output"> </
div> The HTML features a 400x398 pixel image which is placed inside a <
div>. CSS .box { width: 200px; height: 200px; } .image { width: 100%; } .output { padding-top: 2em; } The main thing of note in the CSS above is that the style used for the container the image will be drawn in...
...This is done in response to the window's load event handler, in order to ensure that the image is available before attempting to examine its width and height. Result Specifications Specification Status Comment HTML Living StandardThe definition of 'HTMLImageElement.naturalheight' in that specification. Living Standard Browser ...
HTMLImageElement.naturalWidth - Web APIs
value of width. If the intrinsic width is not available--either because the image does not specify an intrinsic width or because the image data is not available in order to obtain this information, naturalWidth returns 0. Example This example simply displays both the natural, density-adjusted size of an image as well as its rendered size as altered by the page's CSS and other factors. HTML <
div class="box"> <img src="/files/16797/clock-demo-400px.png" class="image"> </
div> <
div class="output"> </
div> The HTML features a 400x398 pixel image which is placed inside a <
div>. CSS .box { width: 200px; height: 200px; } .image { width: 100%; } .output { padding-top: 2em; } The main thing of note in the CSS above is that the style used for the container the image will be drawn in...
...This is done in response to the window's load event handler, in order to ensure that the image is available before attempting to examine its width and height. Result Specifications Specification Status Comment HTML Living StandardThe definition of 'HTMLImageElement.naturalWidth' in that specification. Living Standard Browser c...
HTMLImageElement - Web APIs
The HTMLImageElement interface represents an HTML <img> element, providing the properties and methods used to manipulate image elements. ...
...It accepts optional width and height parameters. When called without parameters, new Image() is equivalent to calling document.createElement("img"). Properties I...
HTMLInputElement - Web APIs
The HTMLInputElement interface provides special properties and methods for manipulating the options, layout, and presentation of <input> elements. ...
... formAction string: Returns / Sets the element's formaction attribute, containing the URI of a program that processes information submitted by the element. This overrid...
HTMLLIElement - Web APIs
The HTMLLIElement interface exposes specific properties and methods (beyond those defined by regular HTMLElement interface it also has available to it by inheritance) for manipulating list elements. ...
... HTMLLIElement.type Is a DOMString representing the type of the bullets, "disc", "square" or "circle". As the standard way of defining the list type is via the CSS list-style-type property, use the CSSOM methods to set it via a script. HTMLLIElement.value Is a long i...
HTMLLabelElement - Web APIs
The HTMLLabelElement interface gives access to properties specific to <label> elements. It inherits methods and properties from the base HTMLElement interface. ...
... HTMLLabelElement.control Read only Is a HTMLElement representing the control with which the label is associated. HTMLLabelElement.form Read only Is a HTMLFormElement object representing the form with which the labeled control is associated, or null if there is no as...
HTMLLegendElement - Web APIs
The HTMLLegendElement is an interface allowing to access properties of the <legend> elements. It inherits properties and methods from the HTMLElement interface. ...
... HTMLLegendElement.form Read only Is a HTMLFormElement representing the form that this legend belongs to. If the legend has a fieldset element as its parent, then this attribute returns the same value as the form attribute on the parent fieldset element. Otherwise, it r...
HTMLLinkElement - Web APIs
The HTMLLinkElement interface represents reference information for external resources and the relationship of those resources to a document and vice-versa (corresponds to <link> element; not to be confused with <a>, which is represented by HTMLAnchorElement). This object inherits all of the properties and methods of the HTMLElement interface. ...
... HTMLLinkElement.as Is a DOMString representing the type of content being loaded by the HTML link. HTMLLinkElement.crossOrigin Is a DOMString that corresponds to the CORS setting for this link element. See CORS settings attributes for details. HTMLL...
HTMLMapElement - Web APIs
The HTMLMapElement interface provides special properties and methods (beyond those of the regular object HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of map elements. ...
... HTMLMapElement.name Is a DOMString representing the <map> element for referencing it other context. If the id attribute is set, this must have the same value; and it cannot be null or empty. HTMLMapElement.areas Read only Is a live HTMLCollection representing the <ar...
HTMLMarqueeElement - Web APIs
The HTMLMarqueeElement interface provides methods to manipulate <marquee> elements. It inherits properties and methods from the HTMLElement interface. ...
... HTMLMarqueeElement.behavior Sets how the text is scrolled within the marquee. Possible values are scroll, slide and alternate. If no value is specified, the default value is scroll. HTMLMarqueeElement.bgColor Sets the background color through color name or hexadecimal...
HTMLMediaElement.onencrypted - Web APIs
The onencrypted property of the HTMLMediaElement is an event handler, fired whenever an encrypted event occurs, denoting the media is encrypted. This interface inherits from the ExtendableEvent interface. ...
...} Specifications Specification Status Comment Encrypted Media ExtensionsThe definition of 'onencrypted' in that specification. Recommendation Initial definition. Browser Compatibility The compatibility table on this page is gener...
HTMLMediaElement.onwaitingforkey - Web APIs
The onwaitingforkey property of the HTMLMediaElement is an event handler, fired when a waitingforkey event occurs, when playback is blocked while waiting for an encryption key. This interface inherits from the ExtendableEvent interface. ...
...} Specifications Specification Status Comment Encrypted Media ExtensionsThe definition of 'onwaitingforkey' in that specification. Recommendation Initial definition. Browser Compatibility The compatibility table on this p...
HTMLMediaElement - Web APIs
The HTMLMediaElement interface adds to HTMLElement the properties and methods needed to support basic media-related capabilities that are common to audio and video. The HTMLVideoElement and HTMLAudioElement elements both inherit this interface. ...
... HTMLMediaElement.audioTracks A AudioTrackList that lists the AudioTrack objects contained in the element. HTMLMediaElement.autoplay A Boolean that reflects the autoplay HTML attribute, indicating whether playback...
HTMLMenuElement - Web APIs
The HTMLMenuElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating <menu> elements. ...
... Living Standard ...
HTMLMenuItemElement - Web APIs
The HTMLMenuItemElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating <menuitem> elements. ...
... Recommendation Snapshot...
HTMLMetaElement - Web APIs
The HTMLMetaElement interface contains descriptive metadata about a document. It inherits all of the properties and methods described in the HTMLElement interface. ...
... Name Type Description content DOMString Gets or sets the value of meta-data property. httpEquiv DOMString Gets or sets the name of an HTTP response header to define for a document. name DOMString Gets or sets ...
HTMLMeterElement - Web APIs
The HTML <meter> elements expose the HTMLMeterElement interface, which provides special properties and methods (beyond the HTMLElement object interface they also have available to them by inheritance) for manipulating the layout and presentation of <meter> elements. ...
... HTMLMeterElement.high A double representing the value of the high boundary, reflecting the high attribute. HTMLMeterElement.low A double representing the value of the low boundary, reflecting the lowattribute. HTMLMeterElement.max A double representing the maxi...
HTMLModElement - Web APIs
The HTMLModElement interface provides special properties (beyond the regular methods and properties available through the HTMLElement interface they also have available to them by inheritance) for manipulating modification elements, that is <del> and <ins>. ...
... HTMLModElement.cite Is a DOMString reflecting the cite HTML attribute, containing a URI of a resource explaining the change. HTMLModElement.dateTime Is a DOMString reflecting the datetime HTML attribute, containing a date-and-time string representing a timestamp for t...
HTMLOListElement - Web APIs
The HTMLOListElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating ordered list elements. ...
... HTMLOListElement.reversed Is a Boolean value reflecting the reversed and defining if the numbering is descending, that is its value is true, or ascending (false). HTMLOListElement.start Is a long value reflecting the start and defining the value of the first number of...
HTMLObjectElement - Web APIs
The HTMLObjectElement interface provides special properties and methods (beyond those on the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <object> element, representing external resources. ...
... HTMLObjectElement.align Is a DOMString representing an enumerated property indicating alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", "justify", and "center". HTMLObjectElement.archive Is a DOMS...
HTMLOptGroupElement - Web APIs
The HTMLOptGroupElement interface provides special properties and methods (beyond the regular HTMLElement object interface they also have available to them by inheritance) for manipulating the layout and presentation of <optgroup> elements. ...
... HTMLOptGroupElement.disabled Is a boolean representing whether or not the whole list of children <option> is disabled (true) or not (false). HTMLOptGroupElement.label Is a DOMString representing the label for the group. Methods No specific method; inherits methods ...
HTMLOptionElement - Web APIs
The HTMLOptionElement interface represents <option> elements and inherits all classes and methods of the HTMLElement interface. ...
... HTMLOptionElement.defaultSelected Is a Boolean that contains the initial value of the selected HTML attribute, indicating whether the option is selected by default or not. HTMLOptionElement.disabled Is a Boolean representing the value of the disabled HTML attribute, ...
HTMLOptionsCollection - Web APIs
The HTMLOptionsCollection interface represents a collection of <option> HTML elements (in document order) and offers methods and properties for selecting from the list as well as optionally altering its items. This object is returned only by the options property of select. ...
...You can either remove options from the end by lowering the value, or add blank options at the end by raising the value. Mozilla allows this, while other implementations could potent...
HTMLElement.focus() - Web APIs
Living Standard HTML 5.1The definition of 'focus' in that specification. Recommen...
... Living Standard HTML 5.1The definition of 'focus' in that specification. Recommendation HTML5The definition of 'focus' in that specification. Recommendation Document Object Model (DOM) Level 2 HTM...
HTMLOutputElement - Web APIs
The HTMLOutputElement interface provides properties and methods (beyond those inherited from HTMLElement) for manipulating the layout and presentation of <output> elements. ...
... HTMLOutputElement.defaultValue A DOMString representing the default value of the element, initially the empty string. HTMLOutputElement.formRead only An HTMLFormElement indicating the form associated with the control, reflecting the form HTML attr...
HTMLParagraphElement - Web APIs
The HTMLParagraphElement interface provides special properties (beyond those of the regular HTMLElement object interface it inherits) for manipulating <p> elements. ...
... HTMLParagraphElement.align A DOMString representing an enumerated property indicating alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", "justify", and "center". Methods No specific methods, inherit...
HTMLParamElement - Web APIs
The HTMLParamElement interface provides special properties (beyond those of the regular HTMLElement object interface it inherits) for manipulating <param> elements, representing a pair of a key and a value that acts as a parameter for an <object> element. ...
... HTMLParamElement.name Is a DOMString representing the name of the parameter. It reflects the name attribute. HTMLParamElement.value Is a DOMString representing the value associated to the parameter. It reflects the value attribute. HTMLParamElement.type Is a DOMSt...
HTMLPictureElement - Web APIs
The HTMLPictureElement interface represents a <picture> HTML element. It doesn't implement specific properties or methods. ...
... Methods No specific method, but inherits methods from its parent, HTMLElement. Specifications Specification Status Comment HTML Living StandardThe definition of 'HTMLPictureElement' in that specification. Living Stand...
HTMLPreElement - Web APIs
The HTMLPreElement interface exposes specific properties and methods (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating a block of preformatted text (<pre>). ...
... HTMLPreElement.width Is a long value reflecting the obsolete width attribute, containing a fixed-size length for the <pre> element. Methods No specific method; inherits properties from its parent, HTMLElement. Specifications Specification Status Co...
HTMLProgressElement - Web APIs
The HTMLProgressElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <progress> elements. ...
..." y1="90" x2="492" y2="90" stroke="#D4DDE4"/><a xlink:href="/docs/Web/API/HTMLProgressElement" target="_top"><rect x="301" y="65" width="190" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="396" y="94" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">HTMLProgressElement</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} Properties Inherits properties from its parent, HTMLElement. HTMLProgressElement.max Is a double value reflecting the content attribute of the same name, limited to numbers greater than zero. Its default value is 1.0. HTMLProgressElement.positionRead only Returns a double value returning the result of
dividing the current valu...
HTMLQuoteElement - Web APIs
The HTMLQuoteElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating quoting elements, like <blockquote> and <q>, but not the <cite> element. ...
... HTMLQuoteElement.cite Is a DOMString reflecting the cite HTML attribute, containing a URL for the source of the quotation. Methods No specific method; inherits properties from its parent, HTMLElement. Specifications Specification Status Comment ...
HTMLScriptElement - Web APIs
ipt> elements (beyond the inherited HTMLElement interface). JavaScript files should be served with the application/javascript MIME type, but browsers are lenient and block them only if the script is served with an image type (image/*), video type (video/*), audio type (audio/*), or text/csv. If the script is blocked, its element receives an error event; otherwise, it receives a load event. ...
... HTMLScriptElement.type Is a DOMString representing the MIME type of the script. It reflects the type attribute. HTMLScriptElement.src Is a DOMString representing the URL of an external script. It reflects the src attribute. HTMLScriptElement.event Is a DOMString...
HTMLSelectElement - Web APIs
The HTMLSelectElement interface represents a <select> HTML Element. These elements also share all of the properties and methods of other HTML elements via the HTMLElement interface. ...
... HTMLSelectElement.autofocus A Boolean reflecting the autofocus HTML attribute, which indicates whether the control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only...
HTMLShadowElement - Web APIs
The HTMLShadowElement interface represents a <shadow> HTML Element, which is used in Shadow DOM. ...
... Methods This interface inherits the methods of HTMLElement. HTMLShadowElement.getDistributedNodes() Returns a static NodeList of the distributed nodes associated with this <shadow> element. Specifications This feature is no longer defined by any specification...
HTMLSourceElement - Web APIs
The HTMLSourceElement interface provides special properties (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating <source> elements. ...
... HTMLSourceElement.media Is a DOMString reflecting the media HTML attribute, containing the intended type of the media resource. HTMLSourceElement.sizes Is a DOMString representing image sizes between breakpoints HTMLSourceElement.src Is a DOMString reflecting the ...
HTMLSpanElement - Web APIs
The HTMLSpanElement interface represents a <span> element and derives from the HTMLElement interface, but without implementing any additional properties or methods. ...
... Methods This interface has no methods, but inherits methods from: HTMLElement. Specifications Specification Status Comment HTML Living StandardThe definition of 'HTMLSpanElement' in that specification. Living Sta...
HTMLStyleElement - Web APIs
The HTMLStyleElement interface represents a <style> element. It inherits properties and methods from its parent, HTMLElement, and from LinkStyle. This interface doesn't allow to manipulate the CSS it contains (in most case). To manipulate CSS, see Using dynamic styling information for an overview of the objects used to manipulate specified CSS properties using the DOM. ...
... HTMLStyleElement.media Is a DOMString representing the intended destination medium for style information. HTMLStyleElement.type Is a DOMString representing the type of style being applied by this statement. HTMLStyleElement.disabled Is a Bo...
HTMLTableCaptionElement - Web APIs
The HTMLTableCaptionElement interface special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating table caption elements. ...
... HTMLTableCaptionElement.align Is a DOMString which represents an enumerated attribute indicating alignment of the caption with respect to the table. Methods No specific method; inherits properties from its parent, HTMLElement. Specifications Specificatio...
HTMLTableCellElement - Web APIs
The HTMLTableCellElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of table cells, either header or data cells, in an HTML document. ...
... HTMLTableCellElement.abbr A DOMString which can be used on <th> elements (not on <td>), specifying an alternative label for the header cell.. This alternate label can be used in other contexts, such as when describing the headers that apply to a data cell. This is used ...
HTMLTableColElement - Web APIs
The HTMLTableColElement interface provides special properties (beyond the HTMLElement interface it also has available to it inheritance) for manipulating single or grouped table column elements. ...
... HTMLTableColElement.align Is a DOMString that indicates the horizontal alignment of the cell data in the column. HTMLTableColElement.ch Is a DOMString representing the alignment character for cell data. HTMLTableColElement.chOff Is a DOMString representing t...
HTMLTableElement - Web APIs
The HTMLTableElement interface provides special properties and methods (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating the layout and presentation of tables in an HTML document. ...
... HTMLTableElement.caption Is a HTMLTableCaptionElement representing the first <caption> that is a child of the element, or null if none is found. When set, if the object doesn't represent a <caption>, a DOMException with the HierarchyRequestError name is thrown. If a cor...
HTMLTableRowElement - Web APIs
The HTMLTableRowElement interface provides special properties and methods (beyond the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of rows in an HTML table. ...
... HTMLTableRowElement.align Is a DOMString containing an enumerated value reflecting the align attribute. It indicates the alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", and "center". HTMLTableRowEl...
HTMLTableSectionElement - Web APIs
The HTMLTableSectionElement interface provides special properties and methods (beyond the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of sections, that is headers, footers and bodies, in an HTML table. ...
... HTMLTableSectionElement.align Is a DOMString containing an enumerated value reflecting the align attribute. It indicates the alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", and "center". HTMLTableS...
HTMLTemplateElement - Web APIs
The HTMLTemplateElement interface enables access to the contents of an HTML <template> element. ...
... content Read only A read-only DocumentFragment which contains the DOM subtree representing the <template> element's template contents. Methods This interface inherits the methods of HTMLElement. Specifications Specification Status Comment ...
HTMLTextAreaElement - Web APIs
The HTMLTextAreaElement interface provides special properties and methods for manipulating the layout and presentation of <textarea> elements. ...
... autocapitalize string: Returns / Sets the element's capitalization behavior for user input. Valid values are: none, off, characters, words, sentences. autocomplete autofocus boolean: Returns / Sets the e...
HTMLTimeElement - Web APIs
The HTMLTimeElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <time> elements. ...
... HTMLTimeElement.dateTime Is a DOMString that reflects the datetime HTML attribute, containing a machine-readable form of the element's date and time value. Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specificat...
HTMLTitleElement - Web APIs
The HTMLTitleElement interface contains the title for a document. This element inherits all of the properties and methods of the HTMLElement interface. ...
... HTMLTitleElement.text Is a DOMString representing the text of the document's title. Methods No specific method; inherits methods from its parent, HTMLElement. Specifications Specification Status Comment HTML Living StandardThe definition of ...
HTMLTrackElement - Web APIs
The HTMLTrackElement interface represents an HTML <track> element within the DOM. This element can be used as a child of either <audio> or <video> to specify a text track containing information such as closed captions or subtitles. ...
... HTMLTrackElement.kind Is a DOMString that reflects the kind HTML attribute, indicating how the text track is meant to be used. Possible values are: subtitles, captions, descriptions, chapters, or metadata. HTMLTrackElement.src Is a DOMString that reflects the src HTML...
HTMLUListElement - Web APIs
The HTMLUListElement interface provides special properties (beyond those defined on the regular HTMLElement interface it also has available to it by inheritance) for manipulating unordered list elements. ...
... HTMLUListElement.type Is a DOMString value reflecting the type and defining the kind of marker to be used to display. The values are browser dependent and have never been standardized. HTMLUListElement.compact Is a Boolean indicating that spacing between list item...
HTMLUnknownElement - Web APIs
The HTMLUnknownElement interface represents an invalid HTML element and derives from the HTMLElement interface, but without implementing any additional properties or methods. ...
... Methods No specific method; inherits properties from its parent, HTMLElement. Specifications Specification Status Comment HTML Living StandardThe definition of 'HTMLUnknownElement' in that specification. Living Standard ...
HTMLVideoElement - Web APIs
manipulating video objects. It also inherits properties and methods of HTMLMediaElement and HTMLElement. The list of supported media formats varies from one browser to the other. You should either provide your video in a single format that all the relevant browsers supports, or provide multiple video sources in enough different formats that all the browsers you need to support are covered. ...
... HTMLVideoElement.height Is a DOMString that reflects the height HTML attribute, which specifies the height of the display area, in CSS pixels. HTMLVideoElement.poster Is a DOMString that reflects the poster HTML attribute, which spec...
Drag Operations - Web APIs
Thus, the default handling of these events is not to allow a drop. If you want to allow a drop, you must prevent the default handling by cancelling both the dragenter and dragover events. You can do this either by returning false from attribute-defined event listeners, or by calling the event's preventDefault() method. The latter may be more feasible in a function defined in a separate script. <
div ondragover="return false"> <
div ondragover="event.preventDefault()"> Calling the preventDefault() method during both a dragenter and dragover event will indicate that a drop is allowed at that location. However, you will commonly wish to call the preventDefault() method only in certain situations (for example, only if a link is being dragged). To do this, call a function which checks a conditi...
...t exist. (Naturally, though, you would likely know that the right type of data was available, as it was previously checked during a dragover event.) In the example here, once the data has been retrieved, we insert the string as the textual content of the target. This has the effect of inserting the dragged text where it was dropped, assuming that the drop target is an area of text such as a p or
div element. In a web page, you should call the preventDefault() method of the event if you have accepted the drop, so that the browser's default handling is not triggered by the dropped data as well. For example, when a link is dragged to a web page, Firefox will open the link. By cancelling the event, this behavior will be prevented. You can retrieve other types of data as well. If the data is a ...
HTML Drag and Drop API - Web APIs
This event fires regardless of whether the drag completed or was canceled. The dragend event handler can check...
... This event fires regardless of whether the drag completed or was canceled. The dragend event handler can check the value of the dropEffect property to determine if the drag operation succeeded or not. F...
HashChangeEvent - Web APIs
The HashChangeEvent interface represents events that fire when the fragment identifier of the URL has changed. The fragment identifier is the part of the URL that follows (and includes) the # symbol. ...
... HashChangeEvent.newURL Read only The new URL to which the window is navigating. HashChangeEvent.oldURL Read only The previous URL from which the window was navigated. Methods This interface has no methods of its own, but inherits the methods of ...
IDBCursorWithValue - Web APIs
creasing in the order of record keys. The cursor enables an application to asynchronously process all the records in the cursor's range. You can have an unlimited number of cursors at the same time. You always get the same IDBCursorWithValue object representing a given cursor. Operations are performed on the underlying index or object store. Note: This feature is available in Web Workers. ...
... Properties Inherits properties from its parent interface, IDBCursor. IDBCursorWithValue.value Read only Returns the value of the current cursor. Example In this example we create a transaction, retrieve an object store, then use a cursor to iterate through all t...
IDBDatabase - Web APIs
ote: This feature is available in Web Workers. Note: Everything you do in IndexedDB always happens in the context of a transaction, representing interactions with data in the database. All objects in IndexedDB -- including object stores, indexes, and cursors -- are tied to a particular transaction. Thus, you cannot execute commands, access data, or open anything outside of a transaction. ...
... IDBDatabase.version Read only A 64-bit integer that contains the version of the connected database. When a database is first created, this attribute is an empty string. IDBDatabase.objectStoreNames Read only A DOMStringLis...
IDBOpenDBRequest - Web APIs
The IDBOpenDBRequest interface of the IndexedDB API provides access to the results of requests to open or delete databases (performed using IDBFactory.open and IDBFactory.deleteDatabase), using specific event handler attributes. Note: This feature is available in Web Workers. ...
... Methods No methods, but inherits methods from its parents IDBRequest and EventTarget. Events Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface. blocked Fired when an open ...
IDBRequest - Web APIs
made available through the result property and an event indicating success is fired at the request (IDBRequest.onsuccess). If an error occurs while performing the operation, the exception is made available through the result property and an error event is fired (IDBRequest.onerror). The interface IDBOpenDBRequest is derived from IDBRequest. Note: This feature is available in Web Workers. ...
... IDBRequest.error Read only Returns a DOMException in the event of an unsuccessful request, indicating what went wrong. IDBRequest.result Read only Returns the result of the request. If the the request failed and the result is not available, an InvalidStateError exception...
IDBTransaction - Web APIs
abase using event handler attributes. All reading and writing of data is done within transactions. You use IDBDatabase to start transactions, IDBTransaction to set the mode of the transaction (e.g. is it readonly or readwrite), and you access an IDBObjectStore to make a request. You can also use an IDBTransaction object to abort transactions. Note: This feature is available in Web Workers. ...
...ine x1="121" y1="25" x2="151" y2="25" stroke="#D4DDE4"/><a xlink:href="/docs/Web/API/IDBTransaction" target="_top"><rect x="151" y="1" width="140" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="221" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">IDBTransaction</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} Transactions are started when the transaction is created, not when the first request is placed; for example consider this: var trans1 = db.transaction("foo", "readwrite"); var trans2 = db.transaction("foo", "readwrite"); var objectStore2 = trans2.objectStore("foo") var objectStore1 = trans1.objectStore("foo") objectStore2.put("2", "k...
InputEvent - Web APIs
The InputEvent interface represents an event notifying of editable content change. ...
... Properties This interface inherits properties from its parents, UIEvent and Event. InputEvent.dataRead only Returns a DOMString with the inserted characters. This may be an empty string if the change doesn't insert text (such as when deleting characters, for example). ...
InstallEvent - Web APIs
The parameter passed into the oninstall handler, the InstallEvent interface represents an install action that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, it ensures that functional events such as FetchEvent are not dispatched during installation. This interface inherits from the ExtendableEvent interface. ...
... Properties Inherits properties from its ancestor, Event. InstallEvent.activeWorker Read only Returns the ServiceWorker that is currently controlling the page. Methods Inherits methods from its parent, ExtendableEvent. Examples This code snippet...
KeyboardEvent.code - Web APIs
ng an anticipated keyboard layout. To determine what character corresponds with the key event, use the KeyboardEvent.key property instead. Code values The code values for Windows, Linux, and macOS are list on the KeyboardEvent: code values page. ...
...eyboard layout. To determine what character corresponds with the key event, use the KeyboardEvent.key property instead. Code values The code values for Windows, Linux, and macOS are list on the KeyboardEvent: code values page. ...
KeyboardEvent - Web APIs
ccurred. Note: KeyboardEvent events just indicate what interaction the user had with a key on the keyboard at a low level, providing no contextual meaning to that interaction. When you need to handle text input, use the input event instead. Keyboard events may not be fired if the user is using an alternate means of entering text, such as a handwriting system on a tablet or graphics tablet. ...
... Constants The KeyboardEvent interface defines the following constants. Keyboard locations The following constants identify which part of the keyboard the key event originates from. They are accessed as KeyboardEvent.DOM_KEY_LOCATION_STANDARD and so forth. Keyb...
MediaKeySession.onkeystatuseschange - Web APIs
The onkeystatuseschange property of the MediaKeySession is an event handler, fired whenever a keystatuschange event ocurrs, denoting there has been a change in the keys or their statuses within a session. This interface inherits from the ExtendableEvent interface. ...
...} Specifications Specification Status Comment Encrypted Media ExtensionsThe definition of 'onkeystatuseschange' in that specification. Recommendation Initial definition. ...
MediaKeySession.onmessage - Web APIs
The onmessage property of the MediaKeySession is an event handler, fired whenever a MediaKeyMessageEvent occurs, denoting a message is generated by the content decryption module. This interface inherits from the ExtendableEvent interface. ...
...} Specifications Specification Status Comment Encrypted Media ExtensionsThe definition of 'onmessage' in that specification. Recommendation Initial definition. ...
MediaSource - Web APIs
The MediaSource interface of the Media Source Extensions API represents a source of media data for an HTMLMediaElement object. A MediaSource object can be attached to a HTMLMediaElement to be played in the user agent. ...
... Properties MediaSource.sourceBuffers Read only Returns a SourceBufferList object containing the list of SourceBuffer objects associated with this MediaSource. MediaSource.activeSourceBuffers Read only Returns a So...
MediaStreamTrackEvent - Web APIs
The MediaStreamTrackEvent interface represents events which indicate that a MediaStream has had tracks added to or removed from the stream through calls to Media Stream API methods. These events are sent to the stream when these changes occur. ...
... track Read only A MediaStreamTrack object representing the track which was added to the stream. Constructor MediaStreamTrackEvent() Constructs a new MediaStreamTrackEvent with the specified...
MediaTrackSupportedConstraints.aspectRatio - Web APIs
Syntax aspectConstraintSupported = supportedConstraintsDictionary.aspectRatio; Value This property is present in the dictionary (and its value is always true) if the user agent supports the aspectRatio constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...raintSupported = supportedConstraintsDictionary.aspectRatio; Value This property is present in the dictionary (and its value is always true) if the user agent supports the aspectRatio constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.channelCount - Web APIs
channelCountConstraintSupported = supportedConstraintsDictionary.channelCount; Value This property is present in the dictionary (and its value is always true) if the user agent supports the channelCount constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...intSupported = supportedConstraintsDictionary.channelCount; Value This property is present in the dictionary (and its value is always true) if the user agent supports the channelCount constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.deviceId - Web APIs
). Syntax deviceIdConstraintSupported = supportedConstraintsDictionary.deviceId; Value This property is present in the dictionary (and its value is always true) if the user agent supports the deviceId constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...dConstraintSupported = supportedConstraintsDictionary.deviceId; Value This property is present in the dictionary (and its value is always true) if the user agent supports the deviceId constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.echoCancellation - Web APIs
tionConstraintSupported = supportedConstraintsDictionary.echoCancellation; Value This property is present in the dictionary (and its value is always true) if the user agent supports the echoCancellation constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...rted = supportedConstraintsDictionary.echoCancellation; Value This property is present in the dictionary (and its value is always true) if the user agent supports the echoCancellation constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.facingMode - Web APIs
s(). Syntax facingModeConstraintSupported = supportedConstraintsDictionary.facingMode; Value This property is present in the dictionary (and its value is always true) if the user agent supports the facingMode constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...gModeConstraintSupported = supportedConstraintsDictionary.facingMode; Value This property is present in the dictionary (and its value is always true) if the user agent supports the facingMode constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.groupId - Web APIs
ts(). Syntax groupIdConstraintSupported = supportedConstraintsDictionary.groupId; Value This property is present in the dictionary (and its value is always true) if the user agent supports the groupId constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...pIdConstraintSupported = supportedConstraintsDictionary.groupId; Value This property is present in the dictionary (and its value is always true) if the user agent supports the groupId constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.height - Web APIs
aints(). Syntax heightConstraintSupported = supportedConstraintsDictionary.height; Value This property is present in the dictionary (and its value is always true) if the user agent supports the height constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...eightConstraintSupported = supportedConstraintsDictionary.height; Value This property is present in the dictionary (and its value is always true) if the user agent supports the height constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.latency - Web APIs
ts(). Syntax latencyConstraintSupported = supportedConstraintsDictionary.latency; Value This property is present in the dictionary (and its value is always true) if the user agent supports the latency constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...ncyConstraintSupported = supportedConstraintsDictionary.latency; Value This property is present in the dictionary (and its value is always true) if the user agent supports the latency constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.sampleRate - Web APIs
ntax sampleRateConstraintSupported = supportedConstraintsDictionary.sampleRate; Value This property is present in the dictionary (and its value is always true) if the user agent supports the sampleRate constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...straintSupported = supportedConstraintsDictionary.sampleRate; Value This property is present in the dictionary (and its value is always true) if the user agent supports the sampleRate constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.sampleSize - Web APIs
ntax sampleSizeConstraintSupported = supportedConstraintsDictionary.sampleSize; Value This property is present in the dictionary (and its value is always true) if the user agent supports the sampleSize constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
...straintSupported = supportedConstraintsDictionary.sampleSize; Value This property is present in the dictionary (and its value is always true) if the user agent supports the sampleSize constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MediaTrackSupportedConstraints.volume - Web APIs
aints(). Syntax volumeConstraintSupported = supportedConstraintsDictionary.volume; Value This property is present in the dictionary (and its value is always true) if the user agent supports the volume constraint. ...
...olumeConstraintSupported = supportedConstraintsDictionary.volume; Value This property is present in the dictionary (and its value is always true) if the user agent supports the volume constraint. ...
MediaTrackSupportedConstraints.width - Web APIs
straints(). Syntax widthConstraintSupported = supportedConstraintsDictionary.width; Value This property is present in the dictionary (and its value is always true) if the user agent supports the width constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
... widthConstraintSupported = supportedConstraintsDictionary.width; Value This property is present in the dictionary (and its value is always true) if the user agent supports the width constraint. If the property isn't present, this property is missing from the supported constraints dictionary, and you'll get undefined if you try to look at its value. ...
MessageEvent - Web APIs
kerGlobalScope.onmessage, etc.) Broadcast channels (see Broadcastchannel.postMessage()) and BroadcastChannel.onmessage). WebRTC data channels (see RTCDataChannel.onmessage). The action triggered by this event is defined in a function set as the event handler for the relevant message event (e.g. using an onmessage handler as listed above). Note: This feature is available in Web Workers. ...
... Properties This interface also inherits properties from its parent, Event. MessageEvent.data Read only The data sent by the message emitter. MessageEvent.origin Read only A USVString representing the origin of the message emitter. MessageEvent.lastEventId Read only...
MouseEvent - Web APIs
nts using this interface include click, dblclick, mouseup, mousedown. MouseEvent derives from UIEvent, which in turn derives from Event. Though the MouseEvent.initMouseEvent() method is kept for backward compatibility, creating of a MouseEvent object should be done using the MouseEvent() constructor. Several more specific events are based on MouseEvent, including WheelEvent and DragEvent. ...
... Properties This interface also inherits properties of its parents, UIEvent and Event. MouseEvent.altKey Read only Returns true if the alt key was down when the mouse event was fired. MouseEvent.button Read only The button number that was pressed (if applicable) when ...
Using Navigation Timing - Web APIs
ow - performance.timing.navigationStart; document.querySelector(".output").innerText = loadingTime + " ms"; }, false); This code, executed when the load event occurs, subtracts from the current time the time at which the navigation whose timing was recorded began (performance.timing.navigationStart), and outputs that information to the screen by inserting it into an element. HTML <
div class="output"> </
div> CSS .output { border: 1px solid #bbb; font: 16px "Open Sans", "Helvetica", "Arial", sans-serif; } In tandem with appropriate HTML and CSS, the result is: The values listed are for the <iframe> in which the sample is presented above. For a list of the available timing values you can look for in PerformanceTiming, see the PerformanceTiming interface's Properties s...
...gation.type indicates what kind of load operation took place: a navigation, a reload, or a shift through the browser's history. We also obtain the number of redirects that were incurred during the navigation from performance.navigation.redirectCount. This information is output to the screen just like the page load time was previously: by inserting it into the element with class "output". HTML <
div class="output"> </
div> CSS .output { border: 1px solid #bbb; font: 16px "Open Sans", "Helvetica", "Arial", sans-serif; } With this code in place, the result looks like this: The values listed are for the <iframe> in which the sample is presented. ...
Node.replaceChild() - Web APIs
order (new before old). ChildNode.replaceWith() may be easier to read and use. Syntax parentNode.replaceChild(newChild, oldChild); Parameters newChild The new node to replace oldChild. If it already exists in the DOM, it is first removed. oldChild The child to be replaced. Return value The returned value is the replaced node. This is the same node as oldChild. Example // Given: // <
div> // <span id="childSpan">foo bar</span> // </
div> // Create an empty element node // without an ID, any attributes, or any content var sp1 = document.createElement("span"); // Give it an id attribute called 'newSpan' sp1.id = "newSpan"; // Create some content for the new element. var sp1_content = document.createTextNode("new replacement span element."); // Apply that content to the new elem...
...nt.createElement("span"); // Give it an id attribute called 'newSpan' sp1.id = "newSpan"; // Create some content for the new element. var sp1_content = document.createTextNode("new replacement span element."); // Apply that content to the new element sp1.appendChild(sp1_content); // Build a reference to the existing node to be replaced var sp2 = document.getElementById("childSpan"); var parent
Div = sp2.parentNode; // Replace existing node sp2 with the new span element sp1 parent
Div.replaceChild(sp1, sp2); // Result: // <
div> // <span id="newSpan">new replacement span element.</span> // </
div> Specifications Specification Status Comment DOMThe definition of 'Node: replaceChild' in that specification. Living Standard ...
OfflineAudioContext - Web APIs
The OfflineAudioContext interface is an AudioContext interface representing an audio-processing graph built from linked together AudioNodes. In contrast with a standard AudioContext, an OfflineAudioContext doesn't render the audio to the device hardware; instead, it generates it, as fast as it can, and outputs the result to an AudioBuffer. ...
... Properties Also inherits properties from its parent interface, BaseAudioContext. OfflineAudioContext.length Read only An integer representing the size of the buffer in sample-frames. Event handlers OfflineAudioContext.onc...
PageTransitionEvent - Web APIs
The PageTransitionEvent event object is available inside handler functions for the pageshow and pagehide events, fired when a document is being loaded or unloaded. ...
... PageTransitionEvent.persisted Read only Indicates if the document is loading from a cache. Example HTML <!DOCTYPE html> <html> <body> </body> </html> JavaScript window.addEventListener('pageshow', myFunction); function myFunction(event) { if (ev...
PaymentAddress.region - Web APIs
This region has different names in different countries, such as: state, province, oblast, prefecture, or county. Usage notes In some countries, like Belgium, it's uncommon for people to provide a region as part of their postal address. ...
...This region has different names in different countries, such as: state, province, oblast, prefecture, or county. Usage notes In some countries, like Belgium, it's uncommon for people to provide a region as part of their postal address. ...
PerformanceFrameTiming - Web APIs
sh rate is the target for a good responsive user experience. This means the browser should process a frame in about 16.7ms. An application can register a PerformanceObserver for "frame" performance entry types and the observer can retrieve data about the duration of each frame event. This information can be used to help identify areas that take too long to provide a good user experience. ...
... PerformanceEntry.name Returns the document's address. PerformanceEntry.startTime Retur...
PerformanceLongTaskTiming - Web APIs
The PerformanceLongTaskTiming interface of the the Long Tasks API reports instances of long tasks. ...
... Specifications Specification Status Comment Long Tasks API 1The definition of 'PerformanceLongTaskTiming' in that specification. Working Draft Initial definition. Browser Compat...
PerformanceMark - Web APIs
PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline. ...
... PerformanceEntry.name Returns the name given to the mark when it was created via a call to performance.mark(). PerformanceEntry.st...
PerformanceMeasure - Web APIs
PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline. ...
... PerformanceEntry.name Returns the name given to the measure when it was created via a call to performance.measure(). Performan...
PerformanceNavigationTiming - Web APIs
The PerformanceNavigationTiming interface provides methods and properties to store and retrieve metrics regarding the browser's document navigation events. For example, this interface can be used to determine how much time it takes to load or unload a document. ...
... PerformanceEntry.name Read only Returns the document's address. PerformanceEntry.startTime Read only R...
PerformancePaintTiming - Web APIs
ut "paint" (also called "render") operations during web page construction. "Paint" refers to conversion of the render tree to on-screen pixels. An application can register a PerformanceObserver for "paint" performance entry types and the observer can retrieve the times that paint events occur. Use this information to help identify areas that take too long to provide a good user experience. ...
... PerformanceEntry.name Returns either "first-paint" or "first-contentful-paint". Perform...
PerformanceResourceTiming - Web APIs
eate a resource loading timeline with high-resolution timestamps for network events such as redirect start and end times, fetch start, DNS lookup start and end times, response start and end times, etc.. Additionally, the interface extends PerformanceEntry with other properties which provide data about the size of the fetched resource as well as the type of resource that initiated the fetch. ...
... Properties This interface extends the following PerformanceEntry properties for resource performance entry types by qualifying and constraining them as follows: PerformanceEntry.entryTypeRead only Returns "resource". PerformanceEntry.nameRead only Returns the resources URL. P...
ProcessingInstruction - Web APIs
gnize the instruction. A processing instruction is different from the XML declaration. User-defined processing instructions cannot begin with "xml", as xml-prefixed processing-instruction target names are reserved by the XML specification for particular, standard uses (see, for example, <?xml-stylesheet ?>). The ProcessingInstruction interface inherits methods and properties from Node. ...
... Living Standard XML specification ...
ProgressEvent - Web APIs
The ProgressEvent interface represents events measuring progress of an underlying process, like an HTTP request (for an XMLHttpRequest, or the loading of the underlying resource of an <img>, <audio>, <video>, <style> or <link>). ...
... Properties Also inherits properties from its parent Event. ProgressEvent.lengthComputable Read only Is a Boolean flag indicating if the total work to be done, and the amount of work already done, by the underlying process is calculable. In...
PromiseRejectionEvent - Web APIs
The PromiseRejectionEvent interface represents events which are sent to the global script context when JavaScript Promises are rejected. These events are particularly useful for telemetry and debugging purposes. For details on promise rejection events, see Promise rejection events in Using Promises. ...
... Properties Also inherits properties from its parent Event. PromiseRejectionEvent.promise Read only The JavaScript Promise that was rejected. PromiseRejectionEvent.r...
RTCDTMFSender - Web APIs
TMF with. The primary purpose for WebRTC's DTMF support is to allow WebRTC-based communication clients to be connected to a public-switched telephone network (PSTN) or other legacy telephone service, including extant voice over IP (VoIP) services. For that reason, DTMF can't be used between two WebRTC-based devices, because there is no mechanism provided by WebRTC for receiving DTMF codes. ...
...See toneBuffer for details on the format of the tone buffer. Methods RTCDTMFSender.insertDTMF() Given a string...
RTCDtlsTransport - Web APIs
RTCRtpReceiver objects. A DTLS transport is also used to provide information about SCTP packets transmitted and received by an connection's data channels. Features of the DTLS transport include the addition of security to the underlying transport; the RTCDtlsTransport interface can be used to obtain information about the underlying transport and the security added to it by the DTLS layer. ...
...box="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="/docs/Web/API/RTCDtlsTransport" target="_top"><rect x="1" y="1" width="160" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="81" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">RTCDtlsTransport</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} PropertiesiceTransport Read only The read-only RTCDtlsTransport property iceTransport contains a reference to the underlying RTCIceTransport.state Read only The state read-only property of the RTCDtlsTransport interface provides information which describes a Datagram Transport Layer Security (DTLS) transport state.MethodsThis interf...
RTCPeerConnection - Web APIs
The RTCPeerConnection interface represents a WebRTC connection between the local computer and a remote peer. It provides methods to connect to a remote peer, maintain and monitor the connection, and close the connection once it's no longer needed. ...
...="121" y1="25" x2="151" y2="25" stroke="#D4DDE4"/><a xlink:href="/docs/Web/API/RTCPeerConnection" target="_top"><rect x="151" y="1" width="170" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="236" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">RTCPeerConnection</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} ConstructorRTCPeerConnection() The RTCPeerConnection() constructor returns a newly-created RTCPeerConnection, which represents a connection between the local device and a remote peer.PropertiesAlso inherits properties from: EventTargetcanTrickleIceCandidatesThe read-only RTCPeerConnection property canTrickleIceCandidates returns a Bo...
RadioNodeList - Web APIs
The RadioNodeList interface represents a collection of radio elements in a <form> or a <fieldset> element. ...
... RadioNodeList.value If the underlying element collection contains radio buttons, the value property represents the checked radio button. On retrieving the value property, the value of the currently checked radio button is returned as a string. If the coll...
Resize Observer API - Web APIs
he box. We could just implement this using border-radius with a percentage, but that quickly leads to ugly-looking elliptical corners, whereas the above solution gives you nice square corners that scale with the box size. resize-observer-text.html (see source): Here we use the resize observer to change the font-size of a header and paragraph as a slider's value is changed causing the containing <
div> to change width. This shows that you can respond to changes in an element's size, even if they have nothing to do with the viewport. The code will usually follow this kind of pattern (taken from resize-observer-border-radius.html): const resizeObserver = new ResizeObserver(entries => { for (let entry of entries) { if(entry.contentBoxSize) { entry.target.style.borderRadius = Math.m...
... ...
SVGAltGlyphDefElement - Web APIs
The SVGAltGlyphDefElement interface corresponds to the <altGlyphDef> element. ...
... Properties This interface doesn't implement any specific properties, but inherits properties from its parent interface, SVGElement. Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGElement. Specificat...
SVGAltGlyphItemElement - Web APIs
The SVGAltGlyphItemElement interface corresponds to the <altGlyphItem> element. ...
... Properties This interface doesn't implement any specific properties, but inherits properties from its parent interface, SVGElement. Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGElement. Specificat...
SVGAnimateColorElement - Web APIs
The SVGAnimateColorElement interface corresponds to the <animateColor> element. ...
... Methods This interface has no methods but inherits methods from its parent, SVGAnimationElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The defin...
SVGAnimateElement - Web APIs
The SVGAnimateElement interface corresponds to the <animate> element. ...
... Methods This interface has no methods but inherits methods from its parent, SVGAnimationElement. Specifications Specification Status Comment SVG Animations Level 2The definition of 'SVGAnimateElement' ...
SVGAnimateMotionElement - Web APIs
The SVGAnimateMotionElement interface corresponds to the <animateMotion> element. ...
... Methods This interface has no methods but inherits methods from its parent, SVGAnimationElement. Specifications Specification Status Comment SVG Animations Level 2The definition of 'SVGAnimateMotionEle...
SVGAnimateTransformElement - Web APIs
The SVGAnimateTransformElement interface corresponds to the <animateTransform> element. ...
... Methods This interface has no methods but inherits methods from its parent, SVGAnimationElement. Specifications Specification Status Comment SVG Animations Level 2The definition of 'SVGAnimateTransform...
SVGAnimationElement - Web APIs
The SVGAnimationElement interface is the base interface for all of the animation element interfaces: SVGAnimateElement, SVGSetElement, SVGAnimateColorElement, SVGAnimateMotionElement and SVGAnimateTransformElement. ...
... SVGAnimationElement.targetElement Read only An SVGElement representing the element which is being animated. If no target element is being animated (for example, because the href specifies an unknown element) the value returned is null. Methods Thi...
SVGCircleElement - Web APIs
The SVGCircleElement interface is an interface for the <circle> element. ...
... SVGCircleElement.cx Read only This property defines the x-coordinate of the center of the <circle> element. It is denoted by the cx attribute of the element. SVGCircleElement.cy Read only This property defines the y-coordinate of the...
SVGClipPathElement - Web APIs
The SVGClipPathElement interface provides access to the properties of <clipPath> elements, as well as methods to manipulate them. ...
... SVGClipPathElement.clipPathUnits Read only An SVGAnimatedEnumeration corresponding to the clipPathUnits attribute of the given <clipPath> element. Takes one of the constants defined in SVGUnitTypes. Methods This interface doesn't implement any spe...
SVGComponentTransferFunctionElement - Web APIs
The SVGComponentTransferFunctionElement interface defines a base interface used by the component transfer function interfaces. ...
...It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY 1 Corresponds to the va...
SVGCursorElement - Web APIs
The SVGCursorElement interface provides access to the properties of <cursor> elements, as well as methods to manipulate them. ...
... SVGCursorElement.x Read only An SVGAnimatedLength corresponding to the x attribute of the given <cursor> element. SVGCursorElement.y Read only An SVGAnimatedLength corresponding to the y attribute of...
SVGDefsElement - Web APIs
The SVGDefsElement interface corresponds to the <defs> element. ...
... Methods This interface doesn't implement any specific methods, but inherits properties from its parent, SVGGraphicsElement. Specifications Specification Status Comment Scalable ...
SVGDescElement - Web APIs
The SVGDescElement interface corresponds to the <desc> element. ...
... Methods This interface has no methods but inherits methods from its parent, SVGGeometryElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 2The definition of 'SVGDescElement' in that spec...
SVGFontFaceElement - Web APIs
The SVGFontFaceElement interface corresponds to the <font-face> elements. Object-oriented access to the attributes of the <font-face> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGFontF...
SVGFontFaceFormatElement - Web APIs
The SVGFontFaceFormatElement interface corresponds to the <font-face-format> elements. Object-oriented access to the attributes of the <font-face-format> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGFontF...
SVGFontFaceNameElement - Web APIs
The SVGFontFaceNameElement interface corresponds to the <font-face-name> elements. Object-oriented access to the attributes of the <font-face-name> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGFontF...
SVGFontFaceSrcElement - Web APIs
The SVGFontFaceSrcElement interface corresponds to the <font-face-src> elements. Object-oriented access to the attributes of the <font-face-src> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGFontF...
SVGFontFaceUriElement - Web APIs
The SVGFontFaceUriElement interface corresponds to the <font-face-uri> elements. Object-oriented access to the attributes of the <font-face-uri> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGFontF...
SVGForeignObjectElement - Web APIs
The SVGForeignObjectElement interface provides access to the properties of <foreignObject> elements, as well as methods to manipulate them. ...
... SVGForeignObjectElement.x Read only An SVGAnimatedLength corresponding to the x attribute of the given <foreignObject> element. SVGForeignObjectElement.y Read only An SVGAnimatedLength corresp...
SVGGElement - Web APIs
The SVGGElement interface corresponds to the <g> element. ...
... Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGGraphicsElement. Specifications Specification Status Comment ...
SVGGeometryElement - Web APIs
The SVGGeometryElement interface represents SVG elements whose rendering is defined by geometry with an equivalent path, and which can be filled and stroked. This includes paths and the basic shapes. ...
...In SVG 2 they were moved to this interface. Properties This interface also inherits properties from its parent, SVGGraphicsElement. SVGGeometryElement.pathLength Read only This property r...
SVGGlyphElement - Web APIs
The SVGGlyphElement interface corresponds to the <glyph> element. Object-oriented access to the attributes of the <glyph> element via the SVG DOM is not possible. ...
... Properties This interface doesn't implement any specific properties, but inherits properties from its parent interface, SVGElement. Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGElement. Specificat...
SVGGlyphRefElement - Web APIs
The SVGGlyphRefElement interface corresponds to the <glyphRef> elements. ...
... SVGGlyphRefElement.glyphRef A DOMString corresponding to the glyphRef attribute of the given element. SVGGlyphRefElement.format A DOMString corresponding to the format attribute of the g...
SVGGradientElement - Web APIs
The SVGGradient interface is a base interface used by SVGLinearGradientElement and SVGRadialGradientElement. ...
...It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. SVG_SPREADMETHOD_PAD 1 Corresponds to value pad. SVG_SPREADMETHO...
SVGGraphicsElement - Web APIs
The SVGGraphicsElement interface represents SVG elements whose primary purpose is to directly render graphics into a group. ...
... Properties This interface also inherits properties from its parent, SVGElement. SVGGraphicsElement.transform Read only An SVGAnimatedTransformList reflecting the computed value of the transform property and...
SVGHKernElement - Web APIs
The SVGHKernElement interface corresponds to the <hkern> elements. Object-oriented access to the attributes of the <hkern> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGHKern...
SVGImageElement - Web APIs
The SVGImageElement interface corresponds to the <image> element. ...
... SVGImageElement.crossOrigin A DOMString corresponding to the crossorigin attribute of the given <image> element. SVGImageElement.decoding Returns a DOMString representing a hint given to the browser on how it should decode the image. SVGIma...
SVGLineElement - Web APIs
The SVGLineElement interface provides access to the properties of <line> elements, as well as methods to manipulate them. ...
... SVGLineElement.x1 Read only Returns an SVGAnimatedLength that corresponds to attribute x1 on the given <line> element. SVGLineElement.y1 Read only Returns an SVGAnimatedLength that corresponds to attribute y1 on the given <line> element. ...
SVGLinearGradientElement - Web APIs
The SVGLinearGradientElement interface corresponds to the <linearGradient> element. ...
... SVGLinearGradientElement.x1 Read only An SVGAnimatedLength corresponding to the x1 attribute of the given <linearGradient> element. SVGLinearGradientElement.y1 Read only An SVGAnimatedLength corresponding to the y1 attribute of the given <...
SVGMPathElement - Web APIs
The SVGMPathElement interface corresponds to the <mpath> element. ...
... Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGElement. Specifications Specification Status Comment SVG Anim...
SVGMaskElement - Web APIs
The SVGMaskElement interface provides access to the properties of <mask> elements, as well as methods to manipulate them. ...
... SVGMaskElement.maskUnits Read only An SVGAnimatedEnumeration corresponding to the maskUnits attribute of the given <mask> element. Takes one of the constants defined in SVGUnitTypes. SVGMaskElement.maskContentUnits Read only An SVGAnimatedEnumerat...
SVGMeshElement - Web APIs
The SVGMeshElement interface provides access to the properties of <mesh> elements. ...
... Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGGeometryElement, and implemen...
SVGMetadataElement - Web APIs
The SVGMetadataElement interface corresponds to the <metadata> element. ...
... Methods This interface doesn't implement any specific methods, but inherits methods from its parent interface, SVGElement. Specifications Specification Status Comment Scalable...
SVGMissingGlyphElement - Web APIs
The SVGMissingGlyphElement interface corresponds to the <missing-glyph> elements. Object-oriented access to the attributes of the <missing-glyph> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement and implements methods from SVGStylable. Specifications Specification Status Comment ...
SVGPathElement - Web APIs
The SVGPathElement interface corresponds to the <path> element. ...
... Properties This interface also inherits properties from its parent, SVGGeometryElement. SVGPathElement.pathLength An SVGAni...
SVGPatternElement - Web APIs
The SVGPatternElement interface corresponds to the <pattern> element. ...
... SVGPatternElement.patternUnits Read only An SVGAnimatedEnumeration corresponding to the patternUnits attribute of the given <pattern> element. Takes one of the constants defined in SVGU...
SVGPolygonElement - Web APIs
The SVGPolygonElement interface provides access to the properties of <polygon> elements, as well as methods to manipulate them. ...
... Methods This interface doesn't implement any specific methods, but inherits methods from its parent, SVGGeometryElement. Specifications Sp...
SVGPolylineElement - Web APIs
The SVGPolylineElement interface provides access to the properties of <polyline> elements, as well as methods to manipulate them. ...
... Methods This interface doesn't implement any specific methods, but inherits methods from its parent, SVGGeometryElement. Specifications Sp...
SVGRadialGradientElement - Web APIs
The SVGRadialGradientElement interface corresponds to the <RadialGradient> element. ...
... SVGRadialGradientElement.cx Read only An SVGAnimatedLength corresponding to the cx attribute of the given <RadialGradient> element. SVGRadialGradientElement.cx Read only An SVGAnimatedLength corresponding to the cy attribute of the given <...
SVGRect - Web APIs
The SVGRect represents a rectangle. Rectangles consist of an x and y coordinate pair identifying a minimum x value, a minimum y value, and a width and height, which are constrained to be non-negative. An SVGRect object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown. ...
...If the attribute is not specified, the effect is as if a value of 0 were specified. SVGRect.y The exact effect of this coordinate depends on each element.If the attribute is not specified, the effect is as if a value of 0 were specified. SVGRect.w...
SVGRectElement - Web APIs
The SVGRectElement interface provides access to the properties of <rect> elements, as well as methods to manipulate them. ...
... SVGRectElement.x Read only Returns an SVGAnimatedLength corresponding to the x attribute of the given <rect> element. SVGRectElement.y Read only Returns an SVGAnimatedLength corresponding to the y attribute of the given <rect> element. SV...
SVGRenderingIntent - Web APIs
The SVGRenderingIntent interface defines the enumerated list of possible values for rendering-intent attributes or descriptors. ...
... Constants Name Value Description RENDERING_INTENT_UNKNOWN 0 The type is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. RENDERING_IN...
SVGSVGElement - Web APIs
The SVGSVGElement interface provides access to the properties of <svg> elements, as well as methods to manipulate them. This interface contains also various miscellaneous commonly-used utility methods, such as matrix operations and the ability to control the time of redraw on visual rendering devices. ...
... SVGSVGElement.x Read only An SVGAnimatedLength corresponding to the x attribute of the given <svg> element. SVGSVGElement.y Read only An SVGAnimatedL...
SVGUseElement - Web APIs
SVG use DOM interface The SVGUseElement interface corresponds to the <use> element. ...
... SVGUseElement.x Read only An SVGAnimatedLength corresponding to the x attribute of the given element. SVGUseElement.y Read only An SVGAnimatedLength corresponding to the y attribute ...
SVGVKernElement - Web APIs
The SVGVKernElement interface corresponds to the <vkern> elements. Object-oriented access to the attributes of the <vkern> element via the SVG DOM is not possible. ...
... Methods This interface has no methods but inherits methods from its parent, SVGElement. Specifications Specification Status Comment Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'SVGVKern...
SVGZoomAndPan - Web APIs
The SVGZoomAndPan interface is used to reflect the zoomAndPan attribute, and is mixed in to other interfaces for elements that support this attribute. ...
...It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type. SVG_ZOOMANDPAN_DISABLE 1 Corresponds to the value disable. SVG_ZOO...
ServiceWorkerGlobalScope - Web APIs
or ServiceWorkerGlobalScope.onmessage. Additionally, synchronous requests are not allowed from within a service worker -- only asynchronous requests, like those initiated via the fetch() method, can be used. This interface inherits from the WorkerGlobalScope interface, and its parent EventTarget, and therefore implements properties from WindowTimers, WindowBase64, and WindowEventHandlers. ...
... ServiceWorkerGlobalScope.registration Read only Contains the ServiceWorkerRegistration object that represents the service worker's registration. ServiceWorkerGlobalScope.caches Read only Contains the CacheSt...
SourceBuffer - Web APIs
The SourceBuffer interface represents a chunk of media to be passed into an HTMLMediaElement and played, via a MediaSource object. This can be made up of one or several media segments. ...
... SourceBuffer.appendWindowStart Controls the timestamp for the start of the append window. This is a timestamp range that can be used to filter what media data is appended to the SourceBuffer. Coded media frames with timestamps within...
StaticRange - Web APIs
The DOM StaticRange interface extends AbstractRange to provide a method to specify a range of content in the DOM whose contents don't update to reflect changes which occur within the DOM tree. It offers the same set of properties and methods as AbstractRange. AbstractRange and StaticRange are not available from web workers. ...
... Properties The properties below are inherited from its parent interface, AbstractRange. StaticRange.collapsed Read only Returns a Boolean value which is true if the range's start...
StorageEvent - Web APIs
A StorageEvent is sent to a window when a storage area it has access to is changed within the context of another document. ...
..."/><line x1="86" y1="25" x2="116" y2="25" stroke="#D4DDE4"/><a xlink:href="/docs/Web/API/StorageEvent" target="_top"><rect x="116" y="1" width="120" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="176" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">StorageEvent</text></a></svg></
div> a:hover text { fill: #0095DD; pointer-events: all;} Method overview void initStorageEvent( in DOMString type, in boolean canBubble, in boolean cancelable, in DOMString key, in DOMString oldValue, in DOMString newValue, in USVString url, in Storage storageArea ); Attributes Attribute Type Description key DOMString Represents the key chang...
StylePropertyMap - Web APIs
The StylePropertyMap interface of the the CSS Typed Object Model API provides a representation of a CSS declaration block that is an alternative to CSSStyleDeclaration. ...
... Methods Inherits methods from its parent, StylePropertyMapReadOnly. StylePropertyMap.append() Adds a new CSS declaration to the StylePropertyMap with the given property and value. StylePropertyMap.clear() Removes all declarations in the StylePropertyMap...
SyncEvent - Web APIs
The SyncEvent interface represents a sync action that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker. This interface inherits from the ExtendableEvent interface. ...
... Properties Inherits properties from its ancestor, Event. SyncEvent.tag Read only Returns the developer-defined identifier for this SyncEvent. SyncEvent.lastChance Read only Returns true if the user agent will not make further synchronization attempts afte...
TaskAttributionTiming - Web APIs
The TaskAttributionTiming interface of the Long Tasks API returns information about the work involved in a long task and its associate frame context. The frame context, also called the container, is the iframe, embed or object that is being implicated, on the whole, for a long task. ...
... TaskAttributionTiming.containerSrc Read only Returns the container's src attribute. TaskAttributionTiming.containerId Read only Returns the container's id attribute. TaskAttributionTiming.container...
Text - Web APIs
hat contains the element's text. However, if the element contains markup, it is parsed into information items and Text nodes that form its children. New documents have a single Text node for each block of text. Over time, more Text nodes may be created as the document's content changes. The Node.normalize() method merges adjacent Text objects back into a single node for each block of text. ...
... Properties Inherits properties from its parent, CharacterData. Text.isElementContentWhitespace Read only Returns a Boolean flag indicating whether or not the text node contains only whitespace. Text.wholeText Read only Returns a DOM...
TimeEvent - Web APIs
The TimeEvent interface, a part of SVG SMIL animation, provides specific contextual information associated with Time events. ...
...For this event type, indicates the repeat number for the animation. TimeEvent.view Read only Is a WindowProxy that identifies the Window from which the event was generated. Methods i...
UIEvent - Web APIs
nt interface represents simple user interface events. UIEvent derives from Event. Although the UIEvent.initUIEvent() method is kept for backward compatibility, you should create a UIEvent object using the UIEvent() constructor. Several interfaces are direct or indirect descendants of this one: MouseEvent, TouchEvent, FocusEvent, KeyboardEvent, WheelEvent, InputEvent, and CompositionEvent. ...
... Properties This interface also inherits properties of its parent, Event. UIEvent.cancelBubble Is a Boolean indicating whether the bubbling of the event has been canceled or not. UIEvent.detailRead only Returns a long with details about the event, depending on the ev...
WebGLContextEvent - Web APIs
The WebContextEvent interface is part of the WebGL API and is an interface for an event that is generated in response to a status change to the WebGL rendering context. Inheritance This interface inherits properties and methods from its parent interface, Event. ...
... WebGLContextEvent.statusMessage A read-only property containing additional information about the event. Methods This interface doesn't define any own methods, but inherits methods from its parent interface, Event. Examples With the help of the WE...
WebGLRenderingContext.enableVertexAttribArray() - Web APIs
referenced by an index number into the list of attributes maintained by the GPU. Some vertex attribute indices may have predefined purposes, depending on the platform and/or the GPU. Others are assigned by the WebGL layer when you create the attributes. Either way, since attributes cannot be used unless enabled, and are disabled by default, you need to call enableVertexAttribArray() to enable in
dividual attributes so that they can be used. Once that's been done, other methods can be used to access the attribute, including vertexAttribPointer(), vertexAttrib*(), and getVertexAttrib(). Syntax void gl.enableVertexAttribArray(index); Parameters index A GLuint specifying the index number that uniquely identifies the vertex attribute to enable. If you know the name of the attribute but no...
...that is, it's greater than or equal to the maximum number of entries permitted in the context's vertex attribute list, as indicated by the value of WebGLRenderingContext.MAX_VERTEX_ATTRIBS. Example This code -- a snippet taken from the full example A basic 2D WebGL animation example -- shows the use of enableVertexArray() to activate the attribute that will be used by the WebGL layer to pass in
dividual vertexes from the vertex buffer into the vertex shader function. gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); aVertexPosition = gl.getAttribLocation(shaderProgram, "aVertexPosition"); gl.enableVertexAttribArray(aVertexPosition); gl.vertexAttribPointer(aVertexPosition, vertexNumComponents, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLES, 0, vertexCount); This code snippet i...
WebGLRenderingContext.stencilMask() - Web APIs
By default, the mask is all 1. Return value None. Examples gl.stencilMask(110101); To get the current stencil masks, query the STENCIL_WRITEMASK, STENCIL_BACK_WRITEMASK, or STENCIL_BITS constants. ...
...By default, the mask is all 1. Return value None. Examples gl.stencilMask(110101); To get the current stencil masks, query the STENCIL_WRITEMASK, STENCIL_BACK_WRITEMASK, or STENCIL_BITS constants. ...
A basic 2D WebGL animation example - Web APIs
nto the program. Each function has a type (one of gl.VERTEX_SHADER or gl.FRAGMENT_SHADER) and an ID (the ID of the <script> element containing the shader's code). The shader set is passed into the function buildShaderProgram(), which returns the compiled and linked shader program. We'll look at how this works next. Once the shader program is built, we compute the aspect ratio of our context by
dividing its width by its height. Then we set the current rotation vector for the animation to [0, 1], and the scaling vector to [1.0, aspectRatio]. The scaling vector, as we saw in the vertex shader, is used to scale the coordinates to fit the -1.0 to 1.0 range. The array of vertices is created next, as a Float32Array with six coordinates (three 2D vertices) per triangle to be drawn, for a total of...
...tachShader(). We could go a step farther here, actually, and look at the value of the <script> element's type attribute to determine the shader type. Once all of the shaders are compiled, the program is linked using gl.linkProgram(). If an error occurrs while linking the program, the error message is logged to console. Finally, the compiled program is returned to the caller. Compiling an in
dividual shader The compileShader() function, below, is called by buildShaderProgram() to compile a single shader. function compileShader(id, type) { let code = document.getElementById(id).firstChild.nodeValue; let shader = gl.createShader(type); gl.shaderSource(shader, code); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { console.log(`Error compi...
WebRTC API - Web APIs
to exchange arbitrary binary data using the RTCDataChannel interface. This can be used for back-channel information, metadata exchange, game status packets, file transfers, or even as a primary channel for data transfer. more details and links to relevant guides and tutorials needed WebRTC reference Because WebRTC provides interfaces that work together to accomplish a variety of tasks, we have
divided up the reference by category. Please see the sidebar for an alphabetical list. Connection setup and management These interfaces, dictionaries, and types are used to set up, open, and manage WebRTC connections. Included are interfaces representing peer media connections, data channels, and interfaces used when exchanging information on the capabilities of each peer in order to select the bes...
...CPeerConnection. The only event sent with this interface is datachannel. RTCSessionDescription Represents the parameters of a session. Each RTCSessionDescription consists of a description type indicating which part of the offer/answer negotiation process it describes and of the SDP descriptor of the session. RTCStatsReport Provides information detailing statistics for a connection or for an in
dividual track on the connection; the report can be obtained by calling RTCPeerConnection.getStats(). Details about using WebRTC statistics can be found in WebRTC Statistics API. RTCIceCandidate Represents a candidate Interactive Connectivity Establishment (ICE) server for establishing an RTCPeerConnection. RTCIceTransport Represents information about an ICE transport. RTCPeerConnectionIceEvent ...
Viewpoints and viewers: Simulating cameras in WebXR - Web APIs
therwise look as flat as a typical 2D screen and make it pop as if it were truly 3D. There are several kinds of perspective; those are defined and their mathematics explained in the article WebGL model view projection. Importantly, the effect of perspective on a vector can be represented by adding a fourth component to the vector: the perspective component, called w. The value of w is applied by
dividing each of the other three components by it to get the final position or vector; that is, for a coordinate given as (x, y, z, w), the point in the 3D space is actually (x/w, y/w, z/w, 1) or simply (x/w, y/w, z/w). If you're not using perspective, w is always 1. In that situation, the complete coordinates for an object located at (1, 0, 3) are (1, 0, 3, 1). But the location isn't enough to desc...
...XR asks your renderer to draw the scene twice for each frame of video--once for each eye. The two views are rendered into the same framebuffer, one on the left and one on the right. The XR device then uses screens and lenses to present the left half of the produced image to our left eye and the right half to our right eye. For example, consider a device which uses a 2560x1440 pixel frame buffer.
Dividing this into two parts--half for each eye--results in each eye's view being drawn at a resolution of 1280x1440 pixels. Here's what that looks like conceptually: Your code tells the WebXR engine that you want to provide the next animation frame by calling the XRSession method requestAnimationFrame(), providing a callback function that renders a frame of animation. When the browser needs you t...
Geometry and reference spaces in WebXR - Web APIs
the required math operations used to compute the positions, orientations, and movement of objects in virtual space--plus the need to integrate the human viewer of the scene into the mix--a thorough introduction to geometry and the use of matrices and vectors to manage 3D representations of a scene is well beyond the scope of what can be accomplished in this article. You can learn more about the in
dividual operations in Matrix math for the web. Units Before discussing the details of the geometry of the 3D space used by WebXR, it's first useful to understand the units of measure that are applied to the 3D world. Lengths and distances WebGL measures all distances and lengths in meters. WebXR inherits this standard, as well as the fact that the world is a cube two meters wide, two meters tall...
...atrix which represents the position and facing direction of the space relative to the world space, if the space represents a viewer such as the user's headset, an observer's headset, or a virtual camera. All of this is the browser's responsibility to handle, providing consistent behavior regardless of how capable each of the underlying reference spaces are. No matter how powerful or simple the in
dividual XR device is, code written using WebXR will still work, within the limitations of the available hardware. Regardless of the type of reference space you choose, its type is XRReferenceSpace or is a type derived from XRReferenceSpace. The currently available reference space types, which are defined by the XRReferenceSpaceType enumeration, are shown below. The reference space returned by XRSe...
Spaces and reference spaces: Spatial tracking in WebXR - Web APIs
environment. To accomplish this, software needs the ability to not only track the locations, orientation, and movements of objects in the virtual world, but the user's location, orientation, and movement as well. But WebXR goes beyond that by adding the ability to track the location, orientation, and motion of the input devices which generate data used to determine the position and movement of in
dividual parts of the viewer's body (with appropriate equipment). The location and movement of the user's headset represent their head's position and orientation in the virtual environment. Hand controllers represent their hands in the same manner. Other hardware elements can be used similarly to represent other parts of the body, providing additional data to use when simulating the user's actions i...
...es, to track the positions, orientations, and movements of objects and of the user's body in the virtual world. Note: This article presumes that you are familiar with the concepts introduced in Geometry and reference spaces in WebXR: that is, the basics of 3D coordinate systems, as well as WebXR spaces, reference spaces, and how reference spaces are used to create local coordinate systems for in
dividual objects or movable components within a scene. Representing a position using a reference space As covered in Defining spatial relationships with reference spaces in Geometry and reference spaces in WebXR, reference spaces establish a local coordinate system which is offset from another coordinate system that is itself defined by some other space. Thus, a reference space can be used to defi...
WebXR Device API - Web APIs
e the WebGL context for WebXR rendering. Returns a Promise which resolves once the context has been prepared, or is rejected if the context cannot be configured for use by WebXR. Guides and tutorials The following guides and tutorials are a great resource to learn how to comprehend WebXR and the underlying 3D and VR/AR graphics concepts. Foundations and basics Fundamentals of WebXR Before
diving into the details of how to create content using WebXR, it may be helpful to read this overview of the technology, which includes introductions to terminology that may be unfamiliar to you, or which may be used in a new way. Matrix math for the web A guide covering how matrices can be used on the web, including both for CSS transforms and for WebGL purposes, as well as to handle the positioni...
...ces can be used on the web, including both for CSS transforms and for WebGL purposes, as well as to handle the positioning and orientation of objects in WebXR contexts. WebXR application life cycle An overview of the overall life cycle of a WebXR application, from startup to shutdown. This article serves as an introduction to the basics of what's involved in creating a WebXR experience without
diving into the code in detail. It's a good way to prepare for the next steps. Creating a mixed reality experience Starting up and shutting down a WebXR session Before actually presenting a scene using an XR device such as a headset or goggles, you need to create a WebXR session bound to a rendering layer that draws the scene for presentation in each of the XR device's displays so that the 3D e...
Background audio processing using AudioWorklet - Web APIs
cess() method, which receives incoming audio data and writes back out the data as manipulated by the processor. The module installs the new audio worklet processor class by calling registerProcessor(), specifying a name for the audio processor and the class that defines the processor. A single audio worklet processor module may define multiple processor classes, registering each of them with in
dividual calls to registerProcessor(). As long as each has its own unique name, this will work just fine. It's also more efficient than loading multiple modules from over the network or even the user's local disk. Basic code framework The barest framework of an audio processor class looks like this: class MyAudioProcessor extends AudioWorkletProcessor { constructor() { super(); } proces...
... and outputs. The input and output lists The lists of inputs and outputs can be a little confusing at first, even though they're actually very simple once you realize what's going on. Let's start at the inside and work our way out. Fundamentally, the audio for a single audio channel (such as the left speaker or the subwoofer, for example) is represented as a Float32Array whose values are the in
dividual audio samples. By specification, each block of audio your process() function receives contains 128 frames (that is, 128 samples for each channel), but it is planned that this value will change in the future, and may in fact vary depending on circumstances, so you should always check the array's length rather than assuming a particular size. It is, however, guaranteed that the inputs and outp...
Visualizations with Web Audio API - Web APIs
var sliceWidth = WIDTH * 1.0 / bufferLength; var x = 0; Now we run through a loop, defining the position of a small segment of the wave for each point in the buffer at a certain height based on the da...
...a loop with requestAnimationFrame() so that the displayed data keeps updating, and clearing the display with each animation frame. function draw() { drawVisual = requestAnimationFrame(draw); analyser.getByteFrequencyData(dataArray); canvasCtx.fillStyle = 'rgb(0, 0, 0)'; canvasCtx.fillRect(0, 0, WIDTH, HEIGHT); Now we set our barWidth to be equal to the canvas width
divided by the number of bars (the buffer length). However, we are also multiplying that width by 2.5, because most of the frequencies will come back as having no audio in them, as most of the sounds we hear every day are in a certain lower frequency range. We don't want to display loads of empty bars, therefore we simply shift the ones that will display regularly at a noticeable height across so the...
WheelEvent - Web APIs
ation-defined. Thus, a wheel event doesn't necessarily dispatch a scroll event. Even when it does, that doesn't mean that the delta* values in the wheel event necessarily reflect the content's scrolling direction. Therefore, do not rely on delta* properties to get the content's scrolling direction. Instead, detect value changes to scrollLeft and scrollTop of the target in the scroll event. ...
... Properties This interface inherits properties from its ancestors, MouseEvent, UIEvent, and Event. WheelEvent.deltaXRead only Returns a double representing the horizontal scroll amount. WheelEvent.deltaYRead only Returns a double representing the vertical scroll amoun...
Window.getDefaultComputedStyle() - Web APIs
The object is of the same type as the object returned by Window.getComputedStyle(), but only takes into account user-agent and user rules. ...
... as the object returned by Window.getComputedStyle(), but only takes into account user-agent and user rules. Example Simple example var elem1 = document.getElementById("elemId"); var style = window.getDefaultComputedStyle(elem1); Longer example <style> #elem-container { position: absolute; left: 100px; top: 200px; height: 100px; } </style> <
div id="elem-container">dummy</
div> <
div id="output"></
div> <script> var elem = document.getElementById("elem-container"); var theCSSprop = window.getDefaultComputedStyle(elem).position; document.getElementById("output").innerHTML = theCSSprop; // Will output "static" </script> Use with pseudo-elements The getDefaultComputedStyle() method can pull style info from pseudo-elements (e.g., ::before or ::after). <style> h3:a...
Window - Web APIs
own Window object; the global window seen by JavaScript code running within a given tab always represents the tab in which the code is running. That said, even in a tabbed browser, some properties and methods still apply to the overall window that contains the tab, such as resizeTo() and innerHeight. Generally, anything that can't reasonably pertain to a tab pertains to the window instead. ...
... DOMParser DOMParser can parse XML or HTML source stored in a string into a DOM Document. DOMParser is specified in DOM Parsing and Serialization. Image Used for creating an HTMLImageElement. Option Used for creating an HTMLOptionElement. StaticRange Read only Returns a StaticRang...
XMLDocument - Web APIs
The XMLDocument interface represents an XML document. It inherits from the generic Document and does not add any specific methods or properties to it: nevertheless, several algorithms behave differently with the two types of documents. ...
... Methods Also inherits methods from: Document XMLDocument.load() Loads an XML document. Specifications Specification Status Comment DOMThe definition of 'XML...
XMLHttpRequest: abort event - Web APIs
The abort event is fired when a request has been aborted, for example because the program called XMLHttpRequest.abort(). ...
... ProgressEvent Event handler property onabort Examples Live example HTML <
div class="controls"> <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" /> <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" /> <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" /> </
div> <textarea readonly class="event-log"></textarea> CSS .event-log { width: 25rem; height: 4rem; border: 1px solid black; margin: .5rem; padding: .2rem; } input { width: 11rem; margin: .5rem; } JS const xhrButtonSuccess = document.querySelector('.xhr.success'); const xhrButtonError = document.querySelector('.xhr.error'); const xhrButtonAbort = document.querySele...
XMLHttpRequest: error event - Web APIs
The error event is fired when the request encountered an error. ...
... ProgressEvent Event handler property onerror Examples Live example HTML <
div class="controls"> <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" /> <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" /> <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" /> </
div> <textarea readonly class="event-log"></textarea> CSS .event-log { width: 25rem; height: 4rem; border: 1px solid black; margin: .5rem; padding: .2rem; } input { width: 11rem; margin: .5rem; } JS const xhrButtonSuccess = document.querySelector('.xhr.success'); const xhrButtonError = document.querySelector('.xhr.error'); const xhrButtonAbort = document.querySele...
XMLHttpRequest.getAllResponseHeaders() - Web APIs
\n). These are essentially delimiters separating each of the headers. Note: In modern browsers, the header names are returned in all lower case, as per the latest spec. Example This example examines the headers in the request's readystatechange event handler, XMLHttpRequest.onreadystatechange. The code shows how to obtain the raw header string, as well as how to convert it into an array of in
dividual headers and then how to take that array and create a mapping of header names to their values. var request = new XMLHttpRequest(); request.open("GET", "foo.txt", true); request.send(); request.onreadystatechange = function() { if(this.readyState == this.HEADERS_RECEIVED) { // Get the raw header string var headers = request.getAllResponseHeaders(); // Convert the header strin...
...o take that array and create a mapping of header names to their values. ...
XMLHttpRequest: load event - Web APIs
The load event is fired when an XMLHttpRequest transaction completes successfully. ...
... ProgressEvent Event handler property onload Examples Live example HTML <
div class="controls"> <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" /> <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" /> <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" /> </
div> <textarea readonly class="event-log"></textarea> CSS .event-log { width: 25rem; height: 4rem; border: 1px solid black; margin: .5rem; padding: .2rem; } input { width: 11rem; margin: .5rem; } JS const xhrButtonSuccess = document.querySelector('.xhr.success'); const xhrButtonError = document.querySelector('.xhr.error'); const xhrButtonAbort = document.querySele...
XMLHttpRequest: loadend event - Web APIs
The loadend event is fired when a request has completed, whether successfully (after load) or unsuccessfully (after abort or error). ...
...rogressEvent Event handler property onloadend Examples Live example HTML <
div class="controls"> <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" /> <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" /> <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" /> </
div> <textarea readonly class="event-log"></textarea> CSS .event-log { width: 25rem; height: 4rem; border: 1px solid black; margin: .5rem; padding: .2rem; } input { width: 11rem; margin: .5rem; } JS const xhrButtonSuccess = document.querySelector('.xhr.success'); const xhrButtonError = document.querySelector('.xhr.error'); const xhrButtonAbort = document.querySele...
XMLHttpRequest: loadstart event - Web APIs
The loadstart event is fired when a request has started to load data. ...
...gressEvent Event handler property onloadstart Examples Live example HTML <
div class="controls"> <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" /> <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" /> <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" /> </
div> <textarea readonly class="event-log"></textarea> CSS .event-log { width: 25rem; height: 4rem; border: 1px solid black; margin: .5rem; padding: .2rem; } input { width: 11rem; margin: .5rem; } JS const xhrButtonSuccess = document.querySelector('.xhr.success'); const xhrButtonError = document.querySelector('.xhr.error'); const xhrButtonAbort = document.querySele...
XMLHttpRequest: progress event - Web APIs
The progress event is fired periodically when a request receives more data. ...
...ogressEvent Event handler property onprogress Examples Live example HTML <
div class="controls"> <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" /> <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" /> <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" /> </
div> <textarea readonly class="event-log"></textarea> CSS .event-log { width: 25rem; height: 4rem; border: 1px solid black; margin: .5rem; padding: .2rem; } input { width: 11rem; margin: .5rem; } JS const xhrButtonSuccess = document.querySelector('.xhr.success'); const xhrButtonError = document.querySelector('.xhr.error'); const xhrButtonAbort = document.querySele...
XMLHttpRequest - Web APIs
XMLHttpRequest (XHR) objects are used to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. XMLHttpRequest is used heavily in AJAX programming. ...
... If your communication needs to involve receiving event data or message data from a server, consider using server-sent events through the EventSource interface. For full-duplex communication, WebSockets may be a better choice. Constructor XMLH...
XMLHttpRequestEventTarget - Web APIs
XMLHttpRequestEventTarget is the interface that describes the event handlers you can implement in an object that will handle events for an XMLHttpRequest. ...
... XMLHttpRequestEventTarget.onerror Contains the function to call when a request encounters an error and the error event is received by this object. XMLHttpRequestEventTarget.onload ...
ARIA: article role - Accessibility
The article role indicates a section of a page that could easily stand on its own on a page, in a document, or on a website. It is usually set on related content items such as comments, forum posts, newspaper articles or other items grouped together on one page. <
div role="article"> <h2>Heading of the segment</h2> <p>Paragraph for the segment.</p> <p>Another paragraph.</p> ... controls to interact with the article, share it, etc. ... </
div> <
div role="article"> ... </
div> This example shows two articles side by side on one page that could be structured similarly and are related. Instead of a
div with an article role, use the <article> element. Always use native element if available. Instead of using role="article", the <article> element can be used. <article> <h2>Heading of the segme...
...any specific keyboard interaction. Required JavaScript features Event handlers This role does not require any event handlers to be present. Changing attribute values When constructing a feed, set the aria-posinset and aria-setsize attributes on each article role to the appropriate values, bearing in mind that aria-posinset is 1-based. Always use native element if available. Instead of a
div with the article role, the <article> element should be used. Examples The restaurant recommendations feed display along with its separate documentation from the WAI-ARIA 1.1 authoring practices feed design pattern Specifications Specification Status Accessible Rich Internet Applications (WAI-ARIA) 1.1The definition of 'article' in that specification. Recommendation...
Cognitive accessibility - Accessibility
d range of disabilities, from people with intellectual disabilities who may have the most-limited capabilities, to age-related issues with thinking and remembering. The range includes people with mental illnesses, such as depression and schizophrenia. It also includes people with learning disabilities, such as dyslexia and attention deficit hyperactivity disorder (ADHD). Though there is a lot of
diversity within clinical definitions of cognitive impairments, people with them experience a common set of functional problems. These problems include difficulty with understanding content, remembering how to complete tasks, and confusion caused by inconsistent or non-traditional web page layouts. In this document, we focus on steps developers should take to improve the cognitive accessibility of th...
... WCAG Guidelines WCAG, Web Content Accessibility Guidelines, includes several guidelines to improve cognitive accessibility. These guidelines are p...
Accessibility Information for Web Authors - Accessibility
avigable custom DHTML widgets in Mozilla & IE This document discusses how to use tabindex, element.focus() and onkeypress to make custom DHTML widgets such as menus or tree views keyboard accessible. Accessible Web Page Authoring IBM has put together a simple, practical resource for web authors to learn accessibility the fast and painless way. Highly recommended, an excellent resource.
Dive Into Accessibility by Mark Pilgrim An excellent, easy-to-understand resource (available in English and in 9 other languages) on accessible website authoring, which goes into greater depth. In 30 days, you will know why your website should be accessible and how to make it more accessible. Automated Checking & Repair Cynthia says(TM) from HiSoftware(R) Company "Cynthia says(TM)" is a f...
...ghtness differences involved in your stylesheets. The Future: Accessible DHTML DHTML Accessibility Roadmap: a peek into how DHTML will be made accessible in the future. This document gives a plan which is being developed by IBM, Mozilla and WAI Protocols and Formats Working Group (PFWG) to address the issue of Accessible DHTML. Dynamic web content is not accessible, because it uses vanilla <
div>'s and <span>'s combined with Javascript rather than declarative markup to describe the behavior of custom widgets such as menus and tree views. These widgets are usually not even keyboard focusable. Furthermore, assistive technologies do not understand what these widgets are supposed to be, or what state they are in or what they are capable of. This document tackles such difficulties and shows ...
Keyboard-navigable JavaScript widgets - Accessibility
This document describes techniques to make JavaScript widgets accessible with the keyboard. Using tabindex By default, when people use the tab key to browse a webpage, only interactive elements (like links, form controls) get focused. ...
... smaller values will position elements earlier in the tab order than larger values (for example, tabindex="7" will be positioned before tabindex="11"). Non-native controls Native HTML elements that are interactive, like <a>, <input> and <select>, are already accessible by keyboards, so to use one of them is the fastest path to make components work with keyboards. Authors can also make a <
div> or <span> keyboard accessible by adding a tabindex of 0. This is particularly useful for components that use interactive elements that do not exist in HTML. Grouping controls For grouping widgets such as menus, tablists, grids, or tree views, the parent element should be in the tab order (tabindex="0"), and each descendent choice/tab/cell/row should be removed from the tab order (tabindex="-1"...
Web Accessibility: Understanding Colors and Luminance - Accessibility
to read text against a background. There's (at least) two kinds of adaptation that take place: local adaptation, and adaptation to an ambient environment. Local adaptation takes place right on the "page" a reader is looking at. For example, if you have blue text within a gray "highlighted" area, your eyes will perceive that same blue text with a gray highlight differently if it is in a black
div, or a white one. This is called local adaptation. This difference in the ability to perceive the text is affected even though the ambient lighting of the room does not change. The implication is that web developers who seek to improve legibility of text against a background can take advantage of the principles of local adaptation. Dark adaptation, to low luminance, is slow. When you come in...
... color space used by the data type <color>, note that there are actually multiple "versions" of the RGB color space, such as sRGB, scRGB, and RGBA. There are also different ways to refrence RGB: RGB Decimal reference: 153, 0, 0 and an RGB Percent reference: 60, 0, 0. Window.getComputedStyle() returns values using RGB Decimal Reference scale. For example, calling Window.getComputedStyle() on a
div with a background-color: #990000; set returns the computed background color as rgb(153, 0, 0) -- the RGB Decimal reference. Window.getComputedStyle() measures color in terms of RGB. CSS Color Module Level 3 added HSL color values, stating "CSS3 adds numerical hue-saturation-lightness (HSL) colors as a complement to numerical RGB colors. It has been observed that RGB colors have ... limitations...
:nth-last-of-type() - CSS: Cascading Style Sheets
pt it counts items backwards from the end, not forwards from the beginning. Syntax The nth-last-of-type pseudo-class is specified with a single argument, which represents the pattern for matching elements, counting from the end. See :nth-last-child for a more detailed explanation of its syntax. ...
... See :nth-last-child for a more detailed explanation of its syntax. Formal syntax :nth-last-of-type( <nth> )where <nth> = <an-plus-b> | even | odd Examples HTML <
div> <span>This is a span.</span> <span>This is another span.</span> <em>This is emphasized.</em> <span>Wow, this span gets limed!!!</span> <strike>This is struck through.</strike> <span>Here is one last span.</span> </
div> CSS span:nth-last-of-type(2) { background-color: lime; } Result Specifications Specification Status Comment Selectors Level 4The definition of ':nth-last-of-type' in that specification. Working Draft Matching elements are not required to have a parent. Selectors Level 3The definition of ':nth-last-of-type' in that specification. Recommendati...
:valid - CSS: Cascading Style Sheets
ted properly. /* Selects any valid <input> */ input:valid { background-color: powderblue; } This pseudo-class is useful for highlighting correct fields for the user. ...
...l for highlighting correct fields for the user. ...
unicode-range - CSS: Cascading Style Sheets
nese. For users viewing the English version of a page, the font resources for Greek and Japanese fonts wouldn't need to be downloaded, saving bandwidth. Formal definition Related at-rule@font-faceInitial valueU+0-10FFFFComputed valueas specified Formal syntax <unicode-range># Examples Using a different font for a single character In this example we create a simple HTML containing a single <
div> element, including an ampersand, that we want to style with a different font. To make it obvious, we will use a sans-serif font, Helvetica, for the text, and a serif font, Times New Roman, for the ampersand. In the CSS we are in effect defining a completely separate @font-face that only includes a single character in it, meaning that only this character will be styled with this font. We could a...
...xt, and a serif font, Times New Roman, for the ampersand. In the CSS we are in effect defining a completely separate @font-face that only includes a single character in it, meaning that only this character will be styled with this font. We could also have done this by wrapping the ampersand in a <span> and applying a different font just to that, but that is an extra element and rule set. HTML <
div>Me & You = Us</
div> CSS @font-face { font-family: 'Ampersand'; src: local('Times New Roman'); unicode-range: U+26; }
div { font-size: 4em; font-family: Ampersand, Helvetica, sans-serif; } Result Specifications Specification Status Comment CSS Fonts Module Level 3The definition of 'unicode-range' in that specification. Candidate Recommendation In...
CSS Box Alignment - CSS: Cascading Style Sheets
typically be the alignment subject's containing block. An alignment container may contain one or many alignment subjects. The below image shows an alignment container with two alignment subjects inside. Fallback alignment If you set an alignment that cannot be fulfilled, then the fallback alignment will come into play and deal with the available space. This fallback alignment is specified in
dividually for each layout method and detailed on the page for that method. Types of alignment There are three different types of alignment that the specification details; these use keyword values. Positional alignment: specifying the position of an alignment subject with relation to its alignment container. Baseline alignment: These keywords define alignment as a relationship among the baselin...
...refixed versions will be maintained as an alias of the unprefixed ones, however you can always double up in the way that you would with vendor prefixes, adding the grid-gap property and then the gap property with the same values. Also, be aware that other things may increase the visual gap displayed, for example using the space distribution keywords or adding margins to items. ...
Controlling Ratios of Flex Items Along the Main Axis - CSS: Cascading Style Sheets
all of the items have the same flex-grow factor, they each get an equal amount of space distributed. The end result is three equal width, flexible items. Try changing the flex-grow factor from 1 to 0 in this live example to see the different behavior: Giving items different flex-grow factors Our understanding of how flex-grow works with flex-basis allows us to have further control over our in
dividual item sizes by assigning items different flex-grow factors. If we keep our flex-basis at 0 so all of the space can be distributed, we could assign each of the three flex items a different flex-grow factor. In the example below I am using the following values: 1 for the first item. 1 for the second item. 2 for the third item. Working from a flex-basis of 0 this means that the available ...
... flex-basis at 0 so all of the space can be distributed, we could assign each of the three flex items a different flex-grow factor. In the example below I am using the following values: 1 for the first item. 1 for the second item. 2 for the third item. Working from a flex-basis of 0 this means that the available space is distributed as follows. We need to add up the flex grow factors, then
divide the total amount of positive free space in the flex container by that number, which in this case is 4. We then share out the space according to the in
dividual values -- the first item gets one part, the second one part, the third two parts. This means that the third item is twice the size of the first and second items. Remember that you can use any positive value here. It is the ratio betwe...
Cross-browser Flexbox mixins - CSS: Cascading Style Sheets
st($args...) { @include justify-content($args...); } Flexbox align items Flex items can be aligned in the cross axis of the current line of the flex container, similar to justify-content but in the perpendicular direction. align-items sets the default alignment for all of the flex container's items, including anonymous flex items. align-self allows this default alignment to be overridden for in
dividual flex items. (For anonymous flex items, align-self always matches the value of align-items on their associated flex container.) Values: flex-start | flex-end | center | baseline | stretch (default) Spec: https://drafts.csswg.org/css-flexbox/#align-items-property @mixin align-items($value: stretch) { @if $value == flex-start { -webkit-box-align: start; -moz-box-align: start; ...
...Note that this property has no effect when the flexbox has only a single line. Values: flex-start | flex-end | center | space-between | space-around | stretch (default) Spec: https://drafts.csswg.org/css-flexbox/#align-content-property @mixin align-content($value: stretch) { // No Webkit Box Fallback. -webkit-align-content: $value; @if $value == flex-...
Variable fonts guide - CSS: Cascading Style Sheets
erating system is not up to date, you will not be able to use variable fonts in web pages or the Firefox Developer Tools. Variable Fonts: what they are, and how they differ To better understand what's different about variable fonts, it is worth reviewing what non-variable ones are like and how they compare. Standard (or Static) fonts In the past, a typeface would be produced as a number of in
dividual fonts, and each font would represent one specific width/weight/style combination. So you would have separate files for 'Roboto Regular', 'Roboto Bold', and 'Roboto Bold Italic' -- meaning that you could end up with 20 or 30 different font files to represent a complete typeface (it could be several times that for a large typeface that has different widths as well). In such a scenario, in ord...
...' 375, 'GRAD' 88; wght (weight) is a registered axis, and GRAD (grade) is a custom one. If you have set values using font-variation-settings and want to change one of those values, you must redeclare all of them (in the same way as when you set OpenType font features using font-feature-settings). You can work around this limitation by using CSS Custom Properties (CSS variables) for the in
dividual values, and simply modifying the value of an in
dividual custom property. Example code follows at the end of the guide. Weight Weight (represented by the wght tag) defines the design axis of how thin or thick (light or heavy, in typical typographic terms) the strokes of the letterforms can be. For a long time in CSS there has existed the ability to specify this via the font-weight proper...
CSS Motion Path - CSS: Cascading Style Sheets
nt to animate an element moving along a path, you previously only had animating translation, position, etc. at your disposal, which wasn't ideal and only allowed for simple movements. With offset-path you can define a specific path of any shape you want. You then animate it along that path by animating offset-distance, and can choose to rotate it at any point using offset-rotate. ...
...t moving along a path, you previously only had animating translation, position, etc. at your disposal, which wasn't ideal and only allowed for simple movements. With offset-path you can define a specific path of any shape you want. You then animate it along that path by animating offset-distance, and can choose to rotate it at any point using offset-rotate. ...
CSS Scrollbars - CSS: Cascading Style Sheets
CSS Scrollbars standardizes the obsolete scrollbar color properties introduced in 2000 by Windows IE 5.5. Basic Example In this example we have chosen to use a thin scrollbar, with a green track and purple thumb. ...
...chosen to use a thin scrollbar, with a green track and purple thumb. .scroller { width: 300px; height: 100px; overflow-y: scroll; scrollbar-color: rebeccapurple green; scrollbar-width: thin; } HTML <
div class="scroller"> Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens corn soko en
dive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini. </
div> Result Reference CSS Properties scrollbar-width scrollbar-color Specifications Specification Status Comment CSS Scrollbars Level 1 Working Draft Initial definition. Acc...
Column layouts - CSS: Cascading Style Sheets
ltiple rows of columns lined up by row and column. The recipes You need to choose different layout methods in order to achieve your requirements. A continuous thread of content -- multi-column layout If you create columns using multi-column layout your text will remain as a continuous stream filling each column in turn. ...
...and column. The recipes You need to choose different layout methods in order to achieve your requirements. A continuous thread of content -- multi-column layout If you create columns using multi-column layout your text will remain as a continuous stream filling each column in turn. The columns must all be the same size, and you are unable to target an in
dividual column or the content of an in
dividual column. You can control the gaps between columns with the column-gap property, and add a rule between columns using column-rule. Download this example Use multicol when: You want your text to display in newspaper-like columns. You have a set of small items you want to break into columns. You do not need to target in
dividual column boxes for styling. A single row of items with e...
Using media queries - CSS: Cascading Style Sheets
or joining media features with media types. not The not operator is used to negate a media query, returning true if the query would otherwise return false. If present in a comma-separated list of queries, it will only negate the specific query to which it is applied. If you use the not operator, you must also specify a media type. Note: In Level 3, the not keyword can't be used to negate an in
dividual media feature expression, only an entire media query. only The only operator is used to apply a style only if an entire query matches, and is useful for preventing older browsers from applying selected styles. When not using only, older browsers would interpret the query screen and (max-width: 500px) simply as screen, ignoring the remainder of the query, and applying its styles on all scr...
...th a viewport height of 480px, the second query would apply and the media statement would still return true. Inverting a query's meaning The not keyword inverts the meaning of an entire media query. It will only negate the specific media query it is applied to. (Thus, it will not apply to every media query in a comma-separated list of media queries.) The not keyword can't be used to negate an in
dividual feature query, only an entire media query. The not is evaluated last in the following query: @media not all and (monochrome) { ... } ... so that the above query is evaluated like this: @media not (all and (monochrome)) { ... } ... rather than like this: @media (not all) and (monochrome) { ... } As another example, the following media query: @media not screen and (color), print and (...
Visual formatting model - CSS: Cascading Style Sheets
is a run of text not contained in another element. In order to fix the box tree, an anonymous box is created around that run of text. It will then behave as a flex item, however, it cannot be targeted and styled like a regular box because there is no element to target. The same thing happens when you have text runs interspersed with block elements. In the next example I have a string inside a <
div>; in the middle of my string is a <p> element containing part of the text. The string is split into three boxes in the box tree. The part of the string before the paragraph element is wrapped in an anonymous box, then we have the <p>, which generates a box, and then another anonymous box. Something to consider about these anonymous boxes is that they inherit styles from their direct parent, b...
...roper table structure -- for example adding an anonymous table row -- if there was no box with display: table-row. Line boxes Line boxes are the boxes that wrap each line of text. You can see the difference between line boxes and their containing block if you float an item and then follow it by a block that has a background color. In the following example, the line boxes following the floated <
div> are shortened to wrap around the float. The background of the box runs behind the float, as the floated item has been taken out of flow. Positioning schemes and in-flow and out-of-flow elements In CSS, a box may be laid out according to three positioning schemes -- normal flow, floats, or absolute positioning. Normal flow In CSS, the normal flow includes block-level formatting of block box...
border-block-color - CSS: Cascading Style Sheets
her dimension can be set with border-inline-color which sets border-inline-start-color, and border-inline-end-color. Syntax Values <'color'> The color of the border. See color. ...
... which sets border-inline-start-color, and border-inline-end-color. Syntax Values <'color'> The color of the border. See color. Formal definition Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typediscrete Formal syntax <'border-top-color'>{1,2} Examples Border with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-block-color: red; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-color' in that specification. Editor's Draft Initial defi...
border-block-end-color - CSS: Cascading Style Sheets
ck-start-color, border-inline-start-color, and border-inline-end-color, which define the other border colors of the element. Values <'color'> The color of the border. See color. ...
...rder-inline-end-color, which define the other border colors of the element. Values <'color'> The color of the border. See color. Formal definition Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typea color Formal syntax <'border-top-color'> Examples Border color with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-block-end-color: red; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-end-color' in that specification. Editor's Draft Init...
border-block-end-style - CSS: Cascading Style Sheets
yle, border-inline-start-style, and border-inline-end-style, which define the other border styles of the element. Values <'border-style'> The line style of the border. See border-style. ...
...-end-style, which define the other border styles of the element. Values <'border-style'> The line style of the border. See border-style. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'border-top-style'> Examples Dashed border with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-block-end-style: dashed; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-end-style' in that specification. Editor's Draft In...
border-block-end-width - CSS: Cascading Style Sheets
border widths of the element. Values <'border-width'> The width of the border. See border-width. ...
...-width'> The width of the border. See border-width. Formal definition Initial valuemediumApplies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueabsolute length; 0 if the border style is none or hiddenAnimation typea length Formal syntax <'border-top-width'> Examples Border width with veritcal text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 1px solid blue; border-block-end-width: 5px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-end-width' in that specification. Editor's Draft Initi...
border-block-start-color - CSS: Cascading Style Sheets
erties are border-block-end-color, border-inline-start-color, and border-inline-end-color, which define the other border colors of the element. ...
...start-color, and border-inline-end-color, which define the other border colors of the element. Values <'color'> See border-color Formal definition Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typea color Formal syntax <'border-top-color'> Examples Border color with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-block-start-color: red; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-start-color' in that specification. Editor's Draft ...
border-block-start-style - CSS: Cascading Style Sheets
yle, border-inline-start-style, and border-inline-end-style, which define the other border styles of the element. Values <'border-style'> The line style of the border. See border-style. ...
...-end-style, which define the other border styles of the element. Values <'border-style'> The line style of the border. See border-style. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'border-top-style'> Examples Dashed border wtih vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-block-start-style: dashed; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-start-style' in that specification. Editor's Draft ...
border-block-start-width - CSS: Cascading Style Sheets
hiddenAnimation typea length Values <'border-width'> The width of the border. See border-width. ...
...-width'> The width of the border. See border-width. Formal definition Initial valuemediumApplies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueabsolute length; 0 if the border style is none or hiddenAnimation typea length Formal syntax <'border-top-width'> Examples Border width with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 1px solid blue; border-block-start-width: 5px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-start-width' in that specification. Editor's Draft I...
border-block-style - CSS: Cascading Style Sheets
n can be set with border-inline-style, which sets border-inline-start-style, and border-inline-end-style. Syntax Values <'border-style'> The line style of the border. See border-style. ...
... border-inline-start-style, and border-inline-end-style. Syntax Values <'border-style'> The line style of the border. See border-style. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'border-top-style'> Examples Dashed border with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-block-style: dashed; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-style' in that specification. Editor's Draft Initial de...
border-block-width - CSS: Cascading Style Sheets
der-inline-end-width. Syntax Values <'border-width'> The width of the border. See border-width. ...
...-width'> The width of the border. See border-width. Formal definition Initial valuemediumApplies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueabsolute length; 0 if the border style is none or hiddenAnimation typediscrete Formal syntax <'border-top-width'> Examples Border width with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 1px solid blue; border-block-width: 5px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-block-width' in that specification. Editor's Draft Initial defin...
border-bottom - CSS: Cascading Style Sheets
Candidate...
...entage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples Applying a bottom border HTML <
div> This box has a border on the bottom side. </
div> CSS
div { border-bottom: 4px dashed blue; background-color: gold; height: 100px; width: 100px; font-weight: bold; text-align: center; } Results Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-bottom' in that specification. Candidate Recommendation No direct changes, though the mo...
border-image-outset - CSS: Cascading Style Sheets
as 2em 4px 0 3rem. Formal definition Initial value0Applies toall elements, except internal table elements when border-collapse is collapse. ...
...ies toall elements, except internal table elements when border-collapse is collapse. It also applies to ::first-letter.InheritednoComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typeby computed value type Formal syntax [ <length> | <number> ]{1,4} Examples Outsetting a border image HTML <
div id="outset">This element has an outset border image!</
div> CSS #outset { width: 10rem; background: #cef; border: 1.4rem solid; border-image: radial-gradient(#ff2, #55f) 40; border-image-outset: 1.5; /* 1.5 x 1.4rem = 2.1rem */ margin: 2.1rem; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-image-outset' in that specification. Cand...
border-image - CSS: Cascading Style Sheets
ormal syntax <'border-image-source'> | <'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? | <'border-image-repeat'> Examples Bitmap In this example, we will apply a diamond pattern to an element's borders. The source for the border image is a ".png" file of 81 by 81 pixels, with three diamonds going vertically and horizontally: HTML <
div id="bitmap">This element is surrounded by a bitmap-based border image!</
div> CSS To match the size of a single diamond, we will use a value of 81
divided by 3, or 27, for slicing the image into corner and edge regions. To center the border image on the edge of the element's background, we will make the outset values equal to half of the width values. Finally, a repeat value of round will make ...
...th: 200px; background-color: #ffa; border: 36px solid orange; margin: 30px; padding: 10px; border-image: url("https://udn.realityripple.com/samples/2c/fa0192d18e.png") /* source */ 27 / /* slice */ 36px 28px 18px 8px / /* width */ 18px 14px 9px 4px /* outset */ round; /* repeat */ } Result Gradient HTML <
div id="gradient">This element is surrounded by a gradient-based border image!</
div> CSS #gradient { width: 200px; border: 30px solid; border-image: repeating-linear-gradient(45deg, #f33, #3bf, #f33 30px) 60; padding: 20px; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-image' in tha...
border-inline-color - CSS: Cascading Style Sheets
dimension can be set with border-block-color which sets border-block-start-color, and border-block-end-color. Syntax Values <'color'> The color of the border. See color. ...
...ch sets border-block-start-color, and border-block-end-color. Syntax Values <'color'> The color of the border. See color. Formal definition Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typediscrete Formal syntax <'border-top-color'>{1,2} Examples Border color with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-inline-color: red; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-color' in that specification. Editor's Draft Initial de...
border-inline-end-color - CSS: Cascading Style Sheets
h define the other border colors of the element. Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typea color Values <'color'> The color of the border. See color. ...
... Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typea color Values <'color'> The color of the border. See color. Formal definition Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typea color Formal syntax <'border-top-color'> Examples HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-inline-end-color: red; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-end-color' in that specification. Editor's Draft Initial def...
border-inline-end-style - CSS: Cascading Style Sheets
roperties are border-block-start-style, border-block-end-style, and border-inline-start-style, which define the other border styles of the element. Values <'border-style'> The line style of the border. See border-style. ...
...ock-end-style, and border-inline-start-style, which define the other border styles of the element. Values <'border-style'> The line style of the border. See border-style. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'border-top-style'> Examples HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-inline-end-style: dashed; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-end-style' in that specification. Editor's Draft ...
border-inline-end-width - CSS: Cascading Style Sheets
enAnimation typea length Values <'border-width'> The width of the border. See border-width. ...
...h'> The width of the border. See border-width. Formal definition Initial valuemediumApplies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueabsolute length; 0 if the border style is none or hiddenAnimation typea length Formal syntax <'border-top-width'> Examples Applying a border with vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 1px solid blue; border-inline-end-width: 5px; } Results Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-end-width' in that specification. Editor's Draft Ini...
border-inline-start-color - CSS: Cascading Style Sheets
Related properties are border-block-start-color, border-block-end-color, and border-inline-end-color, which define the other border colors of the element. Values <'color'> The color of the border. See color. ...
...r, border-block-end-color, and border-inline-end-color, which define the other border colors of the element. Values <'color'> The color of the border. See color. Formal definition Initial valuecurrentcolorApplies toall elementsInheritednoComputed valuecomputed colorAnimation typea color Formal syntax <'border-top-color'> Examples HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-inline-start-color: red; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-start-color' in that specification. Editor's Draft Initial...
border-inline-start-style - CSS: Cascading Style Sheets
define the other border styles of the element. Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Values <'border-style'> The line style of the border. See border-style. ...
...Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Values <'border-style'> The line style of the border. See border-style. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'border-top-style'> Examples HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-inline-start-style: dashed; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-start-style' in that specification. Editor's Draft Initi...
border-inline-start-width - CSS: Cascading Style Sheets
nd-width, which define the other border widths of the element. Values <'border-width'> The width of the border. See border-width. ...
... the element. Values <'border-width'> The width of the border. See border-width. Formal definition Initial valuemediumApplies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueabsolute length; 0 if the border style is none or hiddenAnimation typea length Formal syntax <'border-top-width'> Examples HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 1px solid blue; border-inline-start-width: 5px; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-start-width' in that specification. Editor's Draft Initial ...
border-inline-style - CSS: Cascading Style Sheets
r style in the other dimension can be set with border-block-style, which sets border-block-start-style, and border-block-end-style. Syntax Values <'border-style'> The line style of the border. See border-style. ...
...rder-block-style, which sets border-block-start-style, and border-block-end-style. Syntax Values <'border-style'> The line style of the border. See border-style. Formal definition Initial valuenoneApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax <'border-top-style'> Examples HTML Content <
div> <p class="exampleText">Example text</p> </
div> CSS Content
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-inline-style: dashed; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-style' in that specification. Editor's Draft Initial d...
border-inline-width - CSS: Cascading Style Sheets
border-block-start-width, and border-block-end-width. Syntax Values <'border-width'> The width of the border. See border-width. ...
...idth. Syntax Values <'border-width'> The width of the border. See border-width. Formal definition Initial valuemediumApplies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueabsolute length; 0 if the border style is none or hiddenAnimation typediscrete Formal syntax <'border-top-width'> Examples HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 1px solid blue; border-inline-width: 5px 10px; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'border-inline-width' in that specification. Editor's Draft Initial definit...
border-left - CSS: Cascading Style Sheets
Candidate Recom...
...percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples Applying a left border HTML <
div> This box has a border on the left side. </
div> CSS
div { border-left: 4px dashed blue; background-color: gold; height: 100px; width: 100px; font-weight: bold; text-align: center; } Results Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-left' in that specification. Candidate Recommendation No direct changes, though the modifi...
border-top-left-radius - CSS: Cascading Style Sheets
es to ::first-letter.InheritednoPercentagesrefer to the corresponding dimension of the border boxComputed valuetwo absolute <length>s or <percentage>sAnimation typea length, percentage or calc(); Formal syntax <length-percentage>{1,2}where <length-percentage> = <length> | <percentage> Examples Live example Code An arc of ellipse is used as the border
div { border-top-left-radius: 40px 40px; } An arc of ellipse is used as the border
div { border-top-left-radius: 40px 20px; } The box is a square: an arc of circle is used as the border
div { border-top-left-radius: 40%; } The box is not a square: an arc of ellipse is used as the border
div { borde...
...rder
div { border-top-left-radius: 40px 20px; } The box is a square: an arc of circle is used as the border
div { border-top-left-radius: 40%; } The box is not a square: an arc of ellipse is used as the border
div { border-top-left-radius: 40%; } The background color is clipped at the border
div { border-top-left-radius:40%; border-style: black 3px double; background-color: rgb(250,20,70); background-clip: content-box; } Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-top-left-radius' in that specification. Candidate Recommendation Initial definition ...
border-top - CSS: Cascading Style Sheets
Candidate Recommen...
... <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples Applying a top border HTML <
div> This box has a border on the top side. </
div> CSS
div { border-top: 4px dashed blue; background-color: gold; height: 100px; width: 100px; font-weight: bold; text-align: center; } Results Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-top' in that specification. Candidate Recommendation No direct changes, though the modifica...
border - CSS: Cascading Style Sheets
3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
... <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )where <alpha-value> = <number> | <percentage><hue> = <number> | <angle> Examples Setting a pink outset border HTML <
div>I have a border, an outline, AND a box shadow! Amazing, isn't it?</
div> CSS
div { border: 0.5rem outset pink; outline: 0.5rem solid khaki; box-shadow: 0 0 0 2rem skyblue; border-radius: 12px; font: bold 1rem sans-serif; margin: 2rem; padding: 1rem; outline-offset: 0.5rem; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border' in that specification. ...
box-flex-group - CSS: Cascading Style Sheets
. The box-flex-group CSS property assigns the flexbox's child elements to a flex group. /* <integer> values */ box-flex-group: 1; box-flex-group: 5; /* Global values */ box-flex-group: inherit; box-flex-group: initial; box-flex-group: unset; For flexible elements assigned to flex groups, the first flex group is 1 and higher values specify subsequent flex groups. The initial value is 1. When
dividing up the box's extra space, the browser first considers all elements within the first flex group. Each element within that group is given extra space based on the ratio of that element's flexibility compared to the flexibility of other elements within the same flex group. If the space of all flexible children within the group has been increased to the maximum, the process repeats for the child...
...t element's flexibility compared to the flexibility of other elements within the same flex group. If the space of all flexible children within the group has been increased to the maximum, the process repeats for the children within the next flex group, using any space left over from the previous flex group. Once there are no more flex groups, and there is still space remaining, the extra space is
divided within the containing box according to the box-pack property. If the box would overflow after the preferred space of the children has been computed, then space is removed from flexible elements in a manner similar to that used when adding extra space. Each flex group is examined in turn and space is removed according to the ratio of the flexibility of each element. Elements do not shrink bel...
clamp() - CSS: Cascading Style Sheets
the value of the property will be assigned if the preferred value is greater than this upper bound. The expressions can be math functions (see calc() for more information), literal values, or other expressions, such as attr(), that evaluate to a valid argument type (like <length>), or nested min() and max() functions. As math expressions, so you can use addition, subtraction, multiplication and
division without using the calc() function itself. You may also use parentheses to establish computation order when needed. You can use different units for each value in your expressions, and different units in any math function making up any of the arguments. Notes Math expressions involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, ...
...umns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables may be treated as if auto had been specified. It is permitted to nest max() and min() functions as expression values, in which case the inner ones are treated as simple parentheses. The expressions are full math expressions, so you can use direct addition, subtraction, multiplication and
division without using the calc() function itself. The expression can be values combining the addition ( + ), subtraction ( - ), multiplication ( * ) and
division ( / ) operators, using standard operator precedence rules. Make sure to put a space on each side of the + and - operands. The operands in the expression may be any <length> syntax value. You can use different units for each value in your e...
column-gap (grid-column-gap) - CSS: Cascading Style Sheets
s, flex containers, grid containersInheritednoPercentagesrefer to corresponding dimension of the content areaComputed valueas specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typea length, percentage or calc(); Formal syntax normal | <length-percentage>where <length-percentage> = <length> | <percentage> Examples Flex layout HTML <
div id="flexbox"> <
div></
div> <
div></
div> <
div></
div> </
div> CSS #flexbox { display: flex; height: 100px; column-gap: 20px; } #flexbox >
div { border: 1px solid green; background-color: lime; flex: auto; } Result Grid layout HTML <
div id="grid"> <
div></
div> <
div></
div> <
div></
div> </
div> CSS #grid { grid-column-gap: 20px; } #grid { display: grid; height: ...
... 100px; column-gap: 20px; } #flexbox >
div { border: 1px solid green; background-color: lime; flex: auto; } Result Grid layout HTML <
div id="grid"> <
div></
div> <
div></
div> <
div></
div> </
div> CSS #grid { grid-column-gap: 20px; } #grid { display: grid; height: 100px; grid-template-columns: repeat(3, 1fr); grid-template-rows: 100px; column-gap: 20px; } #grid >
div { border: 1px solid green; background-color: lime; } Result Multi-column layout HTML <p class="content-box"> This is some multi-column text with a 40px column gap created with the CSS `column-gap` property. Don't you think that's fun and exciting? I sure do! </p> CSS .content-box { column-count: 3; column-gap: 40px; } Result Specifications Specification S...
content - CSS: Cascading Style Sheets
www.w3.org/People/Berners-Lee/FAQ.html#Internet">I was lucky enough to invent the Web at the time when the Internet already existed - and had for a decade and a half.</q> We must understand that there is nothing fundamentally wrong with building on the contributions of others. </p> <h1>6</h1> <p>According to the Mozilla Manifesto, <q cite="http://www.mozilla.org/about/manifesto/">In
dividuals must have the ability to shape the Internet and their own experiences on the Internet.</q> Therefore, we can infer that contributing to the open web can protect our own in
dividual experiences on it. </p> CSS q { color: blue; } q::before { content: open-quote; } q::after { content: close-quote; } h1::before { content: "Chapter "; /* The trailing space creates separ...
... { content: url("https://mdn.mozillademos.org/files/7691/mdn-favicon16.png"); } li { margin: 1em; } Result Element replacement This example replaces an element's content with an image. You can replace the contents of an element with either a <url> or an <image> value. Content added with ::before or ::after will not be generated as the contents of the element have been replaced. HTML <
div id="replaced">Mozilla</
div> CSS #replaced { content: url("https://mdn.mozillademos.org/files/12668/MDN.svg"); } #replaced::after { /* will not show if element replacement is supported */ content: " (" attr(id) ")"; } Result Specifications Specification Status Comment CSS Generated Content Module Level 3The definition of 'content' in that specification. ...
<display-internal> - CSS: Cascading Style Sheets
behave like <rb> HTML elements. ruby-text These elements behave like <rt> HTML elements. ruby-base-container These elements behave like <rbc> HTML elements generated as anonymous boxes. ruby-text-container These elements behave like <rtc> HTML elements. Examples CSS tables example The following example demonstrates laying out a simple form using CSS table layout. ...
...ts. ruby-base-container These elements behave like <rbc> HTML elements generated as anonymous boxes. ruby-text-container These elements behave like <rtc> HTML elements. Examples CSS tables example The following example demonstrates laying out a simple form using CSS table layout. HTML <main> <
div> <label for="name">Name</label> <input type="text" id="name" name="name"> </
div> <
div> <label for="age">Age</label> <input type="text" id="age" name="age"> </
div> </main> CSS main { display: table; }
div { display: table-row; } label, input { display: table-cell; margin: 5px; } Result Specifications Specification Status CSS Display Module Level 3The definition of 'display-internal' in that specification. Candidate Reco...
flex-direction - CSS: Cascading Style Sheets
li MDN Understanding WCAG, Guideline 1.3 explanations Understanding Success Criterion 1.3.2 | W3C Understanding WCAG 2.0 Formal definition Initial valuerowApplies toflex containersInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax row | row-reverse | column | column-reverse Examples Reversing flex container columns and rows HTML <h4>This is a Column-Reverse</h4> <
div id="content"> <
div class="box" style="background-color:red;">A</
div> <
div class="box" style="background-color:lightblue;">B</
div> <
div class="box" style="background-color:yellow;">C</
div> </
div> <h4>This is a Row-Reverse</h4> <
div id="content1"> <
div class="box1" style="background-color:red;">A</
div> <
div class="box1" style="background-color:lightblue;">B</
div> <
div class="box1" style...
...x" style="background-color:red;">A</
div> <
div class="box" style="background-color:lightblue;">B</
div> <
div class="box" style="background-color:yellow;">C</
div> </
div> <h4>This is a Row-Reverse</h4> <
div id="content1"> <
div class="box1" style="background-color:red;">A</
div> <
div class="box1" style="background-color:lightblue;">B</
div> <
div class="box1" style="background-color:yellow;">C</
div> </
div> CSS #content { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-direction: column-reverse; } .box { width: 50px; height: 50px; } #content1 { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-direction: row-reverse; } .box1 { width: 50px; height: 50px; } Result Specifications Specification ...
float - CSS: Cascading Style Sheets
ht, until they filled the containing box, after which they would wrap to the next line. A floated element is at least as tall as it's tallest nested floated children. We gave the parent width: 100% and floated it to ensure it is tall enough to encompass it's floated children, and to make sure it takes up the width of the parent so we don't have to clear it's adjacent sibling. HTML <section> <
div class="left">1</
div> <
div class="left">2</
div> <
div class="right">3</
div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi tristique sapien ac erat tincidunt, sit amet dignissim lectus vulputate. Donec id iaculis velit. Aliquam vel malesuada erat. Praesent non magna ac massa aliquet tincidunt vel in massa. Phasellus feugiat est vel leo finibus congue.</p...
... ipsum dolor sit amet, consectetur adipiscing elit. Morbi tristique sapien ac erat tincidunt, sit amet dignissim lectus vulputate. Donec id iaculis velit. Aliquam vel malesuada erat. Praesent non magna ac massa aliquet tincidunt vel in massa. Phasellus feugiat est vel leo finibus congue.</p> </section> CSS section { border: 1px solid blue; width: 100%; float: left; }
div { margin: 5px; width: 50px; height: 150px; } .left { float: left; background: pink; } .right { float: right; background: cyan; } Result Clearing floats Sometimes you may want to force an item to move below any floated elements. For instance, you may want paragraphs to remain adjacent to floats, but force headings to be on their own line. See clear for examples. Specification...
font-family - CSS: Cascading Style Sheets
families .serif { font-family: Times, Times New Roman, Georgia, serif; } .sansserif { font-family: Verdana, Arial, Helvetica, sans-serif; } .monospace { font-family: Lucida Console, Courier, monospace; } .cursive { font-family: cursive; } .fantasy { font-family: fantasy; } .emoji { font-family: emoji; } .math { font-family: math; } .fangsong { font-family: fangsong; } <
div class="serif"> This is an example of a serif font. </
div> <
div class="sansserif"> This is an example of a sans-serif font. </
div> <
div class="monospace"> This is an example of a monospace font. </
div> <
div class="cursive"> This is an example of a cursive font. </
div> <
div class="fantasy"> This is an example of a fantasy font. </
div> <
div class="math"> This is an example of a math...
...erif"> This is an example of a serif font. </
div> <
div class="sansserif"> This is an example of a sans-serif font. </
div> <
div class="monospace"> This is an example of a monospace font. </
div> <
div class="cursive"> This is an example of a cursive font. </
div> <
div class="fantasy"> This is an example of a fantasy font. </
div> <
div class="math"> This is an example of a math font. </
div> <
div class="emoji"> This is an example of an emoji font. </
div> <
div class="fangsong"> This is an example of a fangsong font. </
div> Specifications Specification Status Comment CSS Fonts Module Level 4The definition of 'generic font families' in that specification. Working Draft Adds new generic font families, specifically: system-ui, ui-serif, ui-san...
font-stretch - CSS: Cascading Style Sheets
lueas specifiedAnimation typea font stretch Formal syntax <font-stretch-absolute>where <font-stretch-absolute> = normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | <percentage> Examples Setting font stretch percentages Note that this example will only work in browsers that support <percentage> values. ...
...mi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | <percentage> Examples Setting font stretch percentages Note that this example will only work in browsers that support <percentage> values. ...
font-style - CSS: Cascading Style Sheets
ique, and the "ital" variation with a value of 1 is used to implement italic values. See font-variation-settings. For the example below to work, you'll need a browser that supports the CSS Fonts Level 4 syntax in which font-style: oblique can accept an <angle>. ...
...s the CSS Fonts Level 4 syntax in which font-style: oblique can accept an <angle>. ...
font-variant-alternates - CSS: Cascading Style Sheets
her the keyword normal or one or more of the other keywords and functions listed below, space-separated, in any order. Values normal This keyword deactivates alternate glyphs. historical-forms This keyword enables historical forms -- glyphs that were common in the past but not today. It corresponds to the OpenType value hist. stylistic() This function enables stylistic alternates for in
dividual characters. The parameter is a font-specific name mapped to a number. It corresponds to the OpenType value salt, like salt 2. styleset() This function enables stylistic alternatives for sets of characters. The parameter is a font-specific name mapped to a number. It corresponds to the OpenType value ssXY, like ss02. character-variant() This function enables specific stylistic alternative...
...lue salt, like salt 2. styleset() This function enables stylistic alternatives for sets of characters. The parameter is a font-specific name mapped to a number. It corresponds to the OpenType value ssXY, like ss02. character-variant() This function enables specific stylistic alternatives for characters. It is similar to styleset(), but doesn't create coherent glyphs for a set of characters; in
dividual characters will have independent and not necessarily coherent styles. The parameter is a font-specific name mapped to a number. It corresponds to the OpenType value cvXY, like cv02. swash() This function enables swash glyphs. The parameter is a font-specific name mapped to a number. It corresponds to the OpenType values swsh and cswh, like swsh 2 and cswh 2. ornaments() This function ena...
image-rendering - CSS: Cascading Style Sheets
typediscrete Formal syntax auto | crisp-edges | pixelated Examples Setting image scaling algorithms In practical use, the pixelated and crisp-edges rules can be combined to provide some fallback for each other. (Just prepend the actual rules with the fallback.) The Canvas API can provide a fallback solution for pixelated through manual image data manipulation or with imageSmoothingEnabled. ...
...xelated through manual image data manipulation or with imageSmoothingEnabled. ...
image() - CSS: Cascading Style Sheets
or the page -- the image will be used as-is. List items with dir="rtl" set on the <li> or inheriting the right-to-left directionality from an ancestor, such as documents set to Arabic or Hebrew, will have the bullet display on the right, horizontally flippled, as if transform: scalex(-1) had been set. The text will also be displayed left-to-right. Displaying a section of the background image <
div class="box">Hover over me. What cursor do you see?</
div> .box:hover { cursor: image("https://mdn.mozillademos.org/files/16411/sprite.png#xywh=32,64,16,16"); } When the user hovers over the box, the cursor will change to display the 16x16 px section of the sprite image, starting at x=32 and y=64. Providing fallback images .help::before { content: image("try.webp", "try.svg", "try.gif");...
...f not, the SVG example will be shown. If SVG is not supported, the GIF version will display. Putting color on top of a background image .quarterlogo {height: 200px; width: 200px; border: 1px solid;} .quarterlogo { background-image: image(rgba(0, 0, 0, 0.25)), url("https://mdn.mozillademos.org/files/12053/firefox.png"); background-size: 25%; background-repeat: no-repeat; } <
div class="quarterlogo">If supported, a quarter of this
div has a darkened logo</
div> The above will put a semi-transparent black mask over the Firefox logo background image. Had we used the background-color property instead, the color would have appeared behind the logo image instead of on top of it. Additionally, the entire container would have had the same background color. Because we used image...
inset-block-end - CSS: Cascading Style Sheets
k-end property takes the same values as the left property. ...
...property. Formal definition Initial valueautoApplies topositioned elementsInheritednoPercentageslogical-height of containing blockComputed valuesame as box offsets: top, right, bottom, left properties except that directions are logicalAnimation typea length, percentage or calc(); Formal syntax <'top'> Examples Setting block end offset HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-rl; position: relative; inset-block-end: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'inset-block-end' in that specification. Editor's Dra...
inset-block-start - CSS: Cascading Style Sheets
art property takes the same values as the left property. ...
...operty. Formal definition Initial valueautoApplies topositioned elementsInheritednoPercentageslogical-height of containing blockComputed valuesame as box offsets: top, right, bottom, left properties except that directions are logicalAnimation typea length, percentage or calc(); Formal syntax <'top'> Examples Setting block start offset HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; position: relative; inset-block-start: 20px; background-color: #c8c800; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'inset-block-start' in that specification. Editor's Draft ...
inset-inline-end - CSS: Cascading Style Sheets
ne-end property takes the same values as the left property. ...
... property. Formal definition Initial valueautoApplies topositioned elementsInheritednoPercentageslogical-width of containing blockComputed valuesame as box offsets: top, right, bottom, left properties except that directions are logicalAnimation typea length, percentage or calc(); Formal syntax <'top'> Examples Setting inline end offset HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-rl; position: relative; inset-inline-end: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'inset-inline-end' in that specification. Editor's D...
inset-inline-start - CSS: Cascading Style Sheets
art property takes the same values as the left property. ...
...operty. Formal definition Initial valueautoApplies topositioned elementsInheritednoPercentageslogical-width of containing blockComputed valuesame as box offsets: top, right, bottom, left properties except that directions are logicalAnimation typea length, percentage or calc(); Formal syntax <'top'> Examples Setting inline start offset HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; position: relative; inset-inline-start: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'inset-inline-start' in that specification. Editor...
inset - CSS: Cascading Style Sheets
erty takes the same values as the left property. ...
... definition Initial valueautoApplies topositioned elementsInheritednoPercentageslogical-height of containing blockComputed valuesame as box offsets: top, right, bottom, left properties except that directions are logicalAnimation typea length, percentage or calc(); Formal syntax <'top'>{1,4} Examples Setting offsets for an element HTML <
div> <span class="exampleText">Example text</span> </
div> CSS
div { background-color: yellow; width: 150px; height: 120px; position: relative; } .exampleText { writing-mode: sideways-rl; position: absolute; inset: 20px 40px 30px 10px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'inset' in that specification...
justify-content - CSS: Cascading Style Sheets
osition>? ...
... space-evenly | stretch<overflow-position> = unsafe | safe<content-position> = center | start | end | flex-start | flex-end Examples Setting flex item distribution CSS #container { display: flex; justify-content: space-between; /* Can be changed in the live sample */ } #container >
div { width: 100px; height: 100px; background: linear-gradient(-45deg, #788cff, #b4c8ff); } HTML <
div id="container"> <
div></
div> <
div></
div> <
div></
div> </
div> <select id="justifyContent"> <option value="start">start</option> <option value="end">end</option> <option value="flex-start">flex-start</option> <option value="flex-end">flex-end</option> <option value="center">center</option> <option value="left">left</option> <option value="right">right</option> <option value="bas...
line-break - CSS: Cascading Style Sheets
d by the word-break property. The different wrapping opportunities must not be prioritized. Hyphenation is not applied. Formal definition Initial valueautoApplies toall elementsInheritedyesComputed valueas specifiedAnimation typediscrete Formal syntax auto | loose | normal | strict | anywhere Examples Setting text wrapping See whether the text is wrapped before "?", "?" and "?". ...
...??????????????????<br>?????????????????????</p> <p class="wrapbox loose">loose:<br>??????????????????<br>?????????????????????</p> <p class="wrapbox normal">normal:<br>??????????????????<br>?????????????????????</p> <p class="wrapbox strict">strict:<br>??????????????????<br>?????????????????????</p> <p class="wrapbox anywhere">anywhere:<br>??????????????????<br>?????????????????????</p> </
div> CSS .wrapbox { width: 10em; margin: 0.5em; white-space: normal; vertical-align: top; display: inline-block; } .auto { line-break: auto; } .loose { line-break: loose; } .normal { line-break: normal; } .strict { line-break: strict; } .anywhere { line-break: anywhere; } Result Specifications Specification Status Comment CSS Text Module Level 3The definition of '...
margin-block-end - CSS: Cascading Style Sheets
perty takes the same values as the margin-left property. ...
...operty. Formal definition Initial value0Applies tosame as marginInheritednoPercentagesdepends on layout modelComputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length Formal syntax <'margin-left'> Examples Setting block end margin HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-rl; margin-block-end: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'margin-block-end' in that specification. Editor's Draft Initial defini...
margin-block-start - CSS: Cascading Style Sheets
rty takes the same values as the margin-left property. ...
...erty. Formal definition Initial value0Applies tosame as marginInheritednoPercentagesdepends on layout modelComputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length Formal syntax <'margin-left'> Examples Setting block start margin HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; margin-block-start: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'margin-block-start' in that specification. Editor's Draft Initial de...
margin-inline-end - CSS: Cascading Style Sheets
erty takes the same values as the margin-left property. ...
...perty. Formal definition Initial value0Applies tosame as marginInheritednoPercentagesdepends on layout modelComputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length Formal syntax <'margin-left'> Examples Setting inline end margin HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; margin-inline-end: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'margin-inline-end' in that specification. Editor's Draft Initial defi...
margin-inline-start - CSS: Cascading Style Sheets
rty takes the same values as the margin-left property. ...
...erty. Formal definition Initial value0Applies tosame as marginInheritednoPercentagesdepends on layout modelComputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length Formal syntax <'margin-left'> Examples Setting inline start margin HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; margin-inline-start: 20px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'margin-inline-start' in that specification. Editor's Draft Initial ...
max-width - CSS: Cascading Style Sheets
d or the absolute length or noneAnimation typea length, percentage or calc(); Formal syntax auto | <length> | <percentage> | min-content | max-content | fit-content(<length-percentage>)where <length-percentage> = <length> | <percentage> Examples Setting max width in pixels In this example, the "child" will be either 150 pixels wide or the width of the "parent," whichever is smaller. ...
...ngth or noneAnimation typea length, percentage or calc(); Formal syntax auto | <length> | <percentage> | min-content | max-content | fit-content(<length-percentage>)where <length-percentage> = <length> | <percentage> Examples Setting max width in pixels In this example, the "child" will be either 150 pixels wide or the width of the "parent," whichever is smaller. HTML <
div id="parent"> <
div id="child"> Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis. </
div> </
div> CSS #parent { background: lightblue; width: 300px; } #child { background: gold; width: 100%; max-width: 150px; } Result Specifications Specification Status Comment CSS Box Sizing Module Level 4The definition of 'max-width' in that specification. Editor's...
offset-distance - CSS: Cascading Style Sheets
syntax <length-percentage>where <length-percentage> = <length> | <percentage> Examples Using offset-distance in an animation The motion aspect in CSS Motion Path typically comes from animating the offset-distance property. If you want to animate an element along its full path, you would define its offset-path and then set up an animation that takes the offset-distance from 0% to 100%. ...
...age>where <length-percentage> = <length> | <percentage> Examples Using offset-distance in an animation The motion aspect in CSS Motion Path typically comes from animating the offset-distance property. If you want to animate an element along its full path, you would define its offset-path and then set up an animation that takes the offset-distance from 0% to 100%. ...
offset-position - CSS: Cascading Style Sheets
osition Formal syntax auto | <position>where <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
... auto | <position>where <position> = [ [ left | center | right ] | [ top | center | bottom ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ]? ...
offset - CSS: Cascading Style Sheets
a positionoffset-path: as <angle>, <basic-shape> or <path()>offset-distance: a length, percentage or calc();offset-anchor: a positionoffset-rotate: as <angle>, <basic-shape> or <path()>Creates stacking contextyes Formal syntax [ <'offset-position'>? [ <'offset-path'> [ <'offset-distance'> | <'offset-rotate'> ]? ]? ]! ...
...s <angle>, <basic-shape> or <path()>offset-distance: a length, percentage or calc();offset-anchor: a positionoffset-rotate: as <angle>, <basic-shape> or <path()>Creates stacking contextyes Formal syntax [ <'offset-position'>? [ <'offset-path'> [ <'offset-distance'> | <'offset-rotate'> ]? ]? ]! ...
orphans - CSS: Cascading Style Sheets
page.) Syntax Values <integer> The minimum number of lines that can stay by themselves at the bottom of a fragment before a fragmentation break. The value must be positive. ...
...ifiedAnimation typediscrete Formal syntax <integer> Examples Setting a minimum orphan size of three lines HTML <
div> <p>This is the first paragraph containing some text.</p> <p>This is the second paragraph containing some more text than the first one. It is used to demonstrate how orphans work.</p> <p>This is the third paragraph. It has a little bit more text than the first one.</p> </
div> CSS
div { background-color: #8cffa0; height: 150px; columns: 3; orphans: 3; } p { background-color: #8ca0ff; } p:first-child { margin-top: 0; } Result Specifications Specification Status Comment CSS Fragmentation Module Level 3The definition of 'orphans' in that specification. Candidate Recommendation Extends orphans to apply to any type o...
overflow-x - CSS: Cascading Style Sheets
es toBlock-containers, flex containers, and grid containersInheritednoComputed valueas specified, except with visible/clip computing to auto/hidden respectively if one of overflow-x or overflow-y is neither visible nor clipAnimation typediscrete Formal syntax visible | hidden | clip | scroll | auto Examples HTML <ul> <li><code>overflow-x:hidden</code> -- hides the text outside the box <
div id="
div1"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-x:scroll</code> -- always adds a scrollbar <
div id="
div2"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-x:visible</code> -- displays the text outside the box if needed <
div id="
div3"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMO...
...ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-x:scroll</code> -- always adds a scrollbar <
div id="
div2"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-x:visible</code> -- displays the text outside the box if needed <
div id="
div3"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> <li><code>overflow-x:auto</code> -- on most browsers, equivalent to <code>scroll</code> <
div id="
div4"> ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ </
div> </li> </ul> CSS #
div1, #
div2, #
div3, #
div4 { border: 1px solid black; width: 250px; margin-bottom: 12px; } #
div1 { overflow-x: hidden;} #
div2 { overflow-x: scroll;} #
div3 { overflow-x: visible;} #di...
padding-block-end - CSS: Cascading Style Sheets
ion. It relates to padding-block-start, padding-inline-start, and padding-inline-end, which define the other paddings of the element. ...
...inline-start, and padding-inline-end, which define the other paddings of the element. Formal definition Initial value0Applies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueas <length>Animation typea length Formal syntax <'padding-left'> Examples Setting block end padding for vertical text HTML Content <
div> <p class="exampleText">Example text</p> </
div> CSS Content
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; padding-block-end: 20px; background-color: #C8C800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'padding-block-end' in that specification. Editor's Draft Init...
padding-block-start - CSS: Cascading Style Sheets
t-orientation. It relates to padding-block-end, padding-inline-start, and padding-inline-end, which define the other paddings of the element. ...
...padding-inline-start, and padding-inline-end, which define the other paddings of the element. Formal definition Initial value0Applies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueas <length>Animation typea length Formal syntax <'padding-left'> Examples Setting block start padding for vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; padding-block-start: 20px; background-color: #C8C800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'padding-block-start' in that specification. Editor's Draft Initial ...
padding-block - CSS: Cascading Style Sheets
ies: padding-block-end padding-block-start Syntax Values The padding-block property takes the same values as the padding-left property. ...
...Syntax Values The padding-block property takes the same values as the padding-left property. Formal definition Initial value0Applies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueas <length>Animation typediscrete Formal syntax <'padding-left'>{1,2} Examples Setting block padding for vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-rl; padding-block: 20px 40px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'padding-block' in that specification. Editor's Draft Initial definit...
padding-inline-end - CSS: Cascading Style Sheets
t-orientation. It relates to padding-block-start, padding-block-end, and padding-inline-start, which define the other paddings of the element. ...
..., padding-block-end, and padding-inline-start, which define the other paddings of the element. Formal definition Initial value0Applies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueas <length>Animation typea length Formal syntax <'padding-left'> Examples Setting inline end padding for vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; padding-inline-end: 20px; background-color: #C8C800; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'padding-inline-end' in that specification. Editor's Draft Initial definition...
padding-inline-start - CSS: Cascading Style Sheets
t-orientation. It relates to padding-block-start, padding-block-end, and padding-inline-end, which define the other paddings of the element. ...
..., padding-block-end, and padding-inline-end, which define the other paddings of the element. Formal definition Initial value0Applies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueas <length>Animation typea length Formal syntax <'padding-left'> Examples Setting inline start padding for vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; padding-inline-start: 20px; background-color: #C8C800; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'padding-inline-start' in that specification. Editor's Draft Initial defini...
padding-inline - CSS: Cascading Style Sheets
padding-bottom, or padding-right, and padding-left property depending on the values defined for writing-mode, direction, and text-orientation. ...
...t property depending on the values defined for writing-mode, direction, and text-orientation. Formal definition Initial value0Applies toall elementsInheritednoPercentageslogical-width of containing blockComputed valueas <length>Animation typediscrete Formal syntax <'padding-left'>{1,2} Examples Setting inline padding for vertical text HTML <
div> <p class="exampleText">Example text</p> </
div> CSS
div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-rl; padding-inline: 20px 40px; background-color: #c8c800; } Result Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'padding-inline' in that specification. Editor's Draft Initial defin...
page-break-after - CSS: Cascading Style Sheets
ent element. /* Keyword values */ page-break-after: auto; page-break-after: always; page-break-after: avoid; page-break-after: left; page-break-after: right; page-break-after: recto; page-break-after: verso; /* Global values */ page-break-after: inherit; page-break-after: initial; page-break-after: unset; This property applies to block elements that generate a box. It won't apply on an empty <
div> that won't generate a box. Syntax Values auto Initial value. Automatic page breaks (neither forced nor forbidden). always Always force page breaks after the element. avoid Avoid page breaks after the element. left Force page breaks after the element so that the next page is formatted as a left page. right Force page breaks after the element so that the next page is formatted as a ...
... Formal definition Initial valueautoApplies toblock-level elements in the normal flow of the root element. User agents may also apply it to other elements like table-row elements.InheritednoComputed valueas specifiedAnimation typediscrete Formal syntax auto | always | avoid | left | right | recto | verso Examples Setting a page break after footnotes /* move to a new page after footnotes */
div.footnotes { page-break-after: always; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'recto and verso' in that specification. Editor's Draft Adds the values recto and verso. CSS Paged Media Module Level 3The definition of 'page-break-after' in that specification. Working Draft Extends t...
page-break-before - CSS: Cascading Style Sheets
This property has been replaced by the break-before property. The page-break-before CSS property adjusts page breaks before the current element. This property applies to block elements that generate a box. It won't apply on an empty <
div> that won't generate a box. /* Keyword values */ page-break-before: auto; page-break-before: always; page-break-before: avoid; page-break-before: left; page-break-before: right; page-break-before: recto; page-break-before: verso; /* Global values */ page-break-before: inherit; page-break-before: initial; page-break-before: unset; Syntax Values auto Initial value. Automatic page breaks (neither forced nor forbidden). always Always force page breaks before the element. avoid Avoid page breaks before the element. left Force page breaks before ...
... page Formal definition Initial valueautoApplies toblock-level elements in the normal flow of the root element. User agents may also apply it to other elements like table-row elements.InheritednoComputed valueas specifiedAnimation typediscrete Formal syntax auto | always | avoid | left | right | recto | verso Examples Avoid a page break before the dic /* avoid page break before the
div */
div.note { page-break-before: avoid; } Specifications Specification Status Comment CSS Logical Properties and Values Level 1The definition of 'recto and verso' in that specification. Editor's Draft Adds the values recto and verso. CSS Paged Media Module Level 3The definition of 'page-break-before' in that specification. Working Draft Exte...
page-break-inside - CSS: Cascading Style Sheets
de break-inside auto auto avoid avoid Formal definition Initial valueautoApplies toblock-level elements in the normal flow of the root element. User agents may also apply it to other elements like table-row elements.InheritednoComputed valueas specifiedAnimation typediscrete Formal syntax auto | avoid Examples Avoiding page breaks inside elements HTML <
div class="page"> <p>This is the first paragraph.</p> <section class="list"> <span>A list</span> <ol> <li>one</li> <!-- <li>two</li> --> </ol> </section> <ul> <li>one</li> <!-- <li>two</li> --> </ul> <p>This is the second paragraph.</p> <p>This is the third paragraph, it contains more text.</p> <p>This is the fourth paragraph. It has a little bit more t...
...e first paragraph.</p> <section class="list"> <span>A list</span> <ol> <li>one</li> <!-- <li>two</li> --> </ol> </section> <ul> <li>one</li> <!-- <li>two</li> --> </ul> <p>This is the second paragraph.</p> <p>This is the third paragraph, it contains more text.</p> <p>This is the fourth paragraph. ...
quotes - CSS: Cascading Style Sheets
To be or not to be. That's the question!</q> CSS q { quotes: '"' '"' "'" "'"; } q::before { content: open-quote; } q::after { content: close-quote; } Result Auto quotes For most browsers, the default value of quotes is auto (Firefox 70+), or the browser otherwise had this default behavior (Chromiums, Safari, Edge), so this example works without it being explicitly being set. ...
...quotes: '"' '"' "'" "'"; } q::before { content: open-quote; } q::after { content: close-quote; } Result Auto quotes For most browsers, the default value of quotes is auto (Firefox 70+), or the browser otherwise had this default behavior (Chromiums, Safari, Edge), so this example works without it being explicitly being set. HTML <
div lang="fr"> <q>Ceci est une citation francaise.</q> <
div> <hr> <
div lang="ru"> <q>??? ??????? ??????</q> <
div> <hr> <
div lang="de"> <q>Dies ist ein deutsches Zitat</q> <
div> <hr> <
div lang="en"> <q>This is an English quote.</q> <
div> CSS /*q { quotes: auto; }*/ Result Specifications Specification Status Comment CSS Generated Content Module Level 3The definition of 'quotes' in that specification. Working...
row-gap (grid-row-gap) - CSS: Cascading Style Sheets
flex containers, grid containersInheritednoPercentagesrefer to corresponding dimension of the content areaComputed valueas specified, with <length>s made absolute, and normal computing to zero except on multi-column elementsAnimation typea length, percentage or calc(); Formal syntax normal | <length-percentage>where <length-percentage> = <length> | <percentage> Examples Flex layout HTML <
div id="flexbox"> <
div></
div> <
div></
div> <
div></
div> <
div></
div> <
div></
div> <
div></
div> </
div> CSS #flexbox { display: flex; flex-wrap: wrap; width: 300px; row-gap: 20px; } #flexbox >
div { border: 1px solid green; background-color: lime; flex: 1 1 auto; width: 100px; height: 50px; } Result Grid layout HTML <
div id="grid"> <
div></
div> <
div></
div> <
div>...
...d="flexbox"> <
div></
div> <
div></
div> <
div></
div> <
div></
div> <
div></
div> <
div></
div> </
div> CSS #flexbox { display: flex; flex-wrap: wrap; width: 300px; row-gap: 20px; } #flexbox >
div { border: 1px solid green; background-color: lime; flex: 1 1 auto; width: 100px; height: 50px; } Result Grid layout HTML <
div id="grid"> <
div></
div> <
div></
div> <
div></
div> </
div> CSS #grid { grid-row-gap: 20px; } #grid { display: grid; height: 200px; grid-template-columns: 200px; grid-template-rows: repeat(3, 1fr); row-gap: 20px; } #grid >
div { border: 1px solid green; background-color: lime; } Result Specifications Specification Status Comment CSS Box Alignment Module Level 3The definition of 'row-gap' in ...
scroll-snap-points-x - CSS: Cascading Style Sheets
Initial valuenoneApplies toscroll containersInheritednoPercentagesrelative to same axis of the padding-box of the scroll containerComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typediscrete Formal syntax none | repeat( <length-percentage> )where <length-percentage> = <length> | <percentage> Examples Setting horizontal scroll snap points HTML <
div id="container"> <
div>1</
div> <
div>2</
div> <
div>3</
div> </
div> CSS #container { width: 200px; overflow: auto; white-space: nowrap; scroll-snap-points-x: repeat(100%); scroll-snap-type: mandatory; font-size: 0; } #container >
div { width: 200px; height: 200px; display: inline-block; line-height: 200px; text-align: center; font-size: 100px; } #container >
div:nth-ch...
...
div> </
div> CSS #container { width: 200px; overflow: auto; white-space: nowrap; scroll-snap-points-x: repeat(100%); scroll-snap-type: mandatory; font-size: 0; } #container >
div { width: 200px; height: 200px; display: inline-block; line-height: 200px; text-align: center; font-size: 100px; } #container >
div:nth-child(even) { background-color: #87ea87; } #container >
div:nth-child(odd) { background-color: #87ccea; } Result Specifications Not part of any standard. ...
scrollbar-color - CSS: Cascading Style Sheets
e>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? ...
... <number> | <percentage><hue> = <number> | <angle> Examples Coloring overflow scrollbars CSS .scroller { width: 300px; height: 100px; overflow-y: scroll; scrollbar-color: rebeccapurple green; } HTML <
div class="scroller">Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens corn soko en
dive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</
div> Result Specifications Specification Status Comment CSS Scrollbars Level 1The definition of 'scrollbar-color' in that specification. Working Draft Initial definition. ...
shape-margin - CSS: Cascading Style Sheets
g block. ...
...finition Initial value0Applies tofloatsInheritednoPercentagesrefer to the width of the containing blockComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typea length, percentage or calc(); Formal syntax <length-percentage>where <length-percentage> = <length> | <percentage> Examples Adding a margin to a polygon HTML <section> <
div class="shape"></
div> We are not quite sure of any one thing in biology; our knowledge of geology is relatively very slight, and the economic laws of society are uncertain to every one except some in
dividual who attempts to set them forth; but before the world was fashioned the square on the hypotenuse was equal to the sum of the squares on the other two sides of a right triangle, and it will be so after this world i...
url() - CSS: Cascading Style Sheets
unctional notation, which alters the meaning of the URL string.This is not supported and not fully defined in the specification. ...
... alters the meaning of the URL string.This is not supported and not fully defined in the specification. ...
white-space - CSS: Cascading Style Sheets
ition Initial valuenormalApplies toall elementsInheritedyesComputed valueas specifiedAnimation typediscrete Formal syntax normal | pre | nowrap | pre-wrap | pre-line | break-spaces Examples Basic example code { white-space: pre; } Line breaks inside <pre> elements pre { word-wrap: break-word; /* IE 5.5-7 */ white-space: pre-wrap; /* Modern browsers */ } In action HTML <
div id="css-code" class="box"> p { white-space: <select> <option>normal</option> <option>nowrap</option> <option>pre</option> <option>pre-wrap</option> <option>pre-line</option> <option>break-spaces</option> </select> } </
div> <
div id="results" class="box"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dol...
...smod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ...
widows - CSS: Cascading Style Sheets
inued from a prior page.) Syntax Values <integer> The minimum number of lines that can stay by themselves at the top of a new fragment after a fragmentation break. The value must be positive. ...
...omputed valueas specifiedAnimation typediscrete Formal syntax <integer> Examples Controlling column widows HTML <
div> <p>This is the first paragraph containing some text.</p> <p>This is the second paragraph containing some more text than the first one. It is used to demonstrate how widows work.</p> <p>This is the third paragraph. It has a little bit more text than the first one.</p> </
div> CSS
div { background-color: #8cffa0; columns: 3; widows: 2; } p { background-color: #8ca0ff; } p:first-child { margin-top: 0; } Result Specifications Specification Status Comment CSS Fragmentation Module Level 3The definition of 'widows' in that specification. Candidate Recommendation Extends widows to apply to any type of fragment, includin...
z-index - CSS: Cascading Style Sheets
cal stacking context in which its stack level is 0. This means that the z-indexes of descendants are not compared to the z-indexes of elements outside this element. ...
... z-indexes of elements outside this element. ...
CSS: Cascading Style Sheets
eatures. This module provides a gentle beginning to your path towards CSS mastery with the basics of how it works, what the syntax looks like, and how you can start using it to add styling to HTML. CSS building blocks This module carries on where CSS first steps left off -- now you've gained familiarity with the language and its syntax, and got some basic experience with using it, its time to
dive a bit deeper. This module looks at the cascade and inheritance, all the selector types we have available, units, sizing, styling backgrounds and borders, debugging, and lots more. The aim here is to provide you with a toolkit for writing competent CSS and help you understand all the essential theory, before moving on to more specific disciplines like text styling and CSS layout. Styling tex...
...ng at applying custom fonts to your page, and styling lists and links. CSS layout At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place concerning the viewport, and one another. We have covered the necessary prerequisites so we can now
dive deep into CSS layout, looking at different display settings, modern layout tools like flexbox, CSS grid, and positioning, and some of the legacy techniques you might still want to know about. Use CSS to solve common problems This module provides links to sections of content explaining how to use CSS to solve common problems when creating a web page. Reference CSS reference: This exhaust...
Audio and video manipulation - Developer guides
/samples/6f/08625b424a.m4v"> </video> JavaScript var myVideo = document.getElementById('my-video'); myVideo.playbackRate = 2; Playable code <video id="my-video" controls="true" width="480" height="270"> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type="video/webm"> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type="video/mp4"> </video> <
div class="playable-buttons"> <input id="edit" type="button" value="Edit" /> <input id="reset" type="button" value="Reset" /> </
div> <textarea id="code" class="playable-code"> var myVideo = document.getElementById('my-video'); myVideo.playbackRate = 2;</textarea> var textarea = document.getElementById('code'); var reset = document.getElementById('reset'); var edit = document.getElementById('edi...
...; // Configure filter filter.type = "lowshelf"; filter.frequency.value = 1000; filter.gain.value = 25; Playable code <video id="my-video" controls="true" width="480" height="270" crossorigin="anonymous"> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type="video/webm"> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type="video/mp4"> </video> <
div class="playable-buttons"> <input id="edit" type="button" value="Edit" /> <input id="reset" type="button" value="Reset" /> </
div> <textarea id="code" class="playable-code"> filter.type = "lowshelf"; filter.frequency.value = 1000; filter.gain.value = 25;</textarea> var context = new AudioContext(), audioSource = context.createMediaElementSource(document.getElementById("my-video")), ...
HTML5 - Developer guides
This set is sometimes called HTML5 & friends and often shortened to just HTML5. ...
...antics: allowing you to describe more precisely what your content is. Connectivity: allowing you to communicate with the server in new and innovative ways. Offline and storage: allowing webpages to store data on the client-side locally and operate offline more efficiently. Multimedia: making video and audio first-class citizens in the Open Web. 2D/3D graphics and effects: allowing a much more
diverse range of presentation options. Performance and integration: providing greater speed optimization and better usage of computer hardware. Device access: allowing for the usage of various input and output devices. Styling: letting authors write more sophisticated themes. Semantics Sections and outlines in HTML5 A look at the new outlining and sectioning elements in HTML5: <section>, <...
A hybrid approach - Developer guides
rategies that make the best use of a variety of techniques given the circumstances. This brings us to our third approach, which aims to avoid some of the shortcomings the separate sites and responsive design approaches by combining them. This hybrid approach centers around breaking down mobile development into its three goals, and then applying the best techniques available to tackle each goal in
dividually. This article presents one potential combination of techniques as an example here, but different combinations will be appropriate under different circumstances. The most important concept to remember is that server-side and client-side techniques can be combined to fit your situation. The Good Responsive web design is great -- right now it is the best technique available for making layou...
... project or one that has an existing flexible layout, not as a retrofit. Similarly, because it uses user-agent detection, you will have to update your detection rules as time goes on. When it is right to choose this option Combining server-side and client-side techniques is something that is always worth considering; there are so many options that one must just weigh the pros and cons of each in
dividual technique employed. In many cases, the added complexity of the hybrid approach is not even necessary. For example, you may not even need to adjust your content based on what actual device a user is using -- just knowing whether a feature is present on their browser is often good enough. This is something you might be able to discern on the client-side using JavaScript feature detection from...
Writing forward-compatible websites - Developer guides
foo attributes with "window." When an event handler content attribute (onclick, onmouseover, and so forth) is used on HTML element, all name lookup in the attribute first happens on the element itself, then on the element's form if the element is a form control, then on the document, and then on the window (where the global variables you have defined are). For example, if you have this markup: <
div onclick="alert(ownerDocument)">Click me</
div> then clicking on the text alerts the ownerDocument of the
div. This happens even if there is a var ownerDocument declared in global scope. What this means is that any time you access a global variable in an event handler content attribute, including calling any function declared globally, you can end up with a name collision if a specification adds ...
...ame name as your function or variable, and a browser implements it. If that happens, then suddenly your function stops being called. This has happened multiple times to various sites already during the evolution of HTML5. To avoid this, fully qualify global variable access using "window.", like so: <script> function localName() { alert('Function localName has been called'); } </script> <
div onclick="window.localName()">Clicking me should show an alert<
div> Don't concatenate scripts you don't control The "use strict;" directive in ECMAScript, when used on the file level, applies to everything in the file. So appending a script that depends on non-strict-mode behavior to a strict-mode script will cause things to break. Ask the authors of any JavaScript libraries you use to also fo...
HTML attribute: accept - HTML: Hypertext Markup Language
takes as its value a string containing one or more of these unique file type specifiers, separated by commas. For example, a file picker that needs content that can be presented as an image, including both standard image formats and PDF files, might look like this: <input type="file" accept="image/*,.pdf"> Using file inputs A basic example <form method="post" enctype="multipart/form-data"> <
div> <label for="file">Choose file to upload</label> <input type="file" id="file" name="file" multiple> </
div> <
div> <button>Submit</button> </
div> </form>
div { margin-bottom: 10px; } This produces the following output: Note: You can find this example on GitHub too -- see the source code, and also see it running live. Regardless of the user's device or operating system, the f...
...ept any file with an image/* MIME type. (Many mobile devices also let the user take a picture with the camera when this is used.) accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" -- accept anything that smells like an MS Word document. Let's look at a more complete example: <form method="post" enctype="multipart/form-data"> <
div> <label for="profile_pic">Choose file to upload</label> <input type="file" id="profile_pic" name="profile_pic" accept=".jpg, .jpeg, .png"> </
div> <
div> <button>Submit</button> </
div> </form>
div { margin-bottom: 10px; } Specifications Specification Status HTML Living StandardThe definition of 'accept attribute' in that specification. ...
Block-level elements - HTML: Hypertext Markup Language
Elements The following is a complete list of all HTML "block-level" elements (although "block-level" is not technically defined for elements that are new in HTML5). <address> Contact information. <article> Article content. <aside> Aside content. <blockquote> Long ("block") quotation. <details> Disclosure widget. <dialog> Dialog box. <dd> Describes a term in a description list. <
div> Document
division. <dl> Description list. <dt> Description list term. <fieldset> Field set label. <figcaption> Figure caption. <figure> Groups media content with a caption (see <figcaption>). <footer> Section or page footer. <form> Input form. <h1>, <h2>, <h3>, <h4>, <h5>, <h6> Heading levels 1-6. <header> Section or page header. <hgroup> Groups header information. <hr> Ho...
...ision. <dl> Description list. <dt> Description list term. <fieldset> Field set label. <figcaption> Figure caption. <figure> Groups media content with a caption (see <figcaption>). <footer> Section or page footer. <form> Input form. <h1>, <h2>, <h3>, <h4>, <h5>, <h6> Heading levels 1-6. <header> Section or page header. <hgroup> Groups header information. <hr> Horizontal rule (
dividing line). <li> List item. <main> Contains the central content unique to this document. <nav> Contains navigation links. <ol> Ordered list. <p> Paragraph. <pre> Preformatted text. <section> Section of a web page. <table> Table. <ul> Unordered list. See also Inline elements display Block and Inline Layout in Normal Flow ...
Date and time formats used in HTML - HTML: Hypertext Markup Language
is. For the purposes of HTML dates, years are always at least four digits long; years prior to the year 1000 are padded with leading zeroes ("0"), so the year 72 is written as 0072. Years prior to the year 1 C.E. are not supported, so HTML doesn't support years 1 B.C.E. (1 B.C.) or earlier. A year is normally 365 days long, except during leap years. Leap years A leap year is any year which is
divisible by 400 or the year is
divisible by 4 but not by 100. Although the calendar year is normally 365 days long, it actually takes the planet Earth approximately 365.2422 days to complete a single orbit around the sun. Leap years help to adjust the calendar to keep it synchronized with the actual position of the planet in its orbit. Adding a day to the year every four years essentially makes the ...
...he planet Earth approximately 365.2422 days to complete a single orbit around the sun. Leap years help to adjust the calendar to keep it synchronized with the actual position of the planet in its orbit. Adding a day to the year every four years essentially makes the average year 365.25 days long, which is close to correct. The adjustments to the algorithm (taking a leap year when the year can be
divided by 400, and skipping leap years when the year is
divisible by 100) help to bring the average even closer to the correct number of days (365.2425 days). Scientists occasionally add leap seconds to the calendar (seriously) to handle the remaining three ten-thousandths of a day and to compensate for the gradual, naturally occurring slowing of Earth's rotation. While month 02, February, normally...
<center>: The Centered Text element (obsolete) - HTML: Hypertext Markup Language
The obsolete HTML Center Element (<center>) is a block-level element that displays its block-level or inline contents centered horizontally within its containing element. The container is usually, but isn't required to be, <body>. This tag has been deprecated in HTML 4 (and XHTML 1) in favor of the CSS text-align property, which can be applied to the <
div> element or to an in
dividual <p>. For centering blocks, use other CSS properties like margin-left and margin-right and set them to auto (or set margin to 0 auto). DOM interface This element implements the HTMLElement interface. Implementation note: up to Gecko 1.9.2 inclusive, Firefox implements the HTMLSpanElement interface for this element. Example 1 <center>This text will be centered. <p>So will this paragraph.</p></center> E...
...properties like margin-left and margin-right and set them to auto (or set margin to 0 auto). DOM interface This element implements the HTMLElement interface. Implementation note: up to Gecko 1.9.2 inclusive, Firefox implements the HTMLSpanElement interface for this element. Example 1 <center>This text will be centered. <p>So will this paragraph.</p></center> Example 2 (CSS alternative) <
div style="text-align:center">This text will be centered. <p>So will this paragraph.</p></
div> Example 3 (CSS alternative) <p style="text-align:center">This line will be centered.<br> And so will this line.</p> Note Applying text-align:center to a <
div> or <p> element centers the contents of those elements while leaving their overall dimensions unchanged. ...
<input type="button"> - HTML: Hypertext Markup Language
on't participate in constraint validation; they have no real value to be constrained. Examples The below example shows a very simple drawing app created using a <canvas> element and some simple CSS and JavaScript (we'll hide the CSS for brevity). The top two controls allow you to choose the color and size of the drawing pen. The button, when clicked, invokes a function that clears the canvas. ...
...CSS for brevity). The top two controls allow you to choose the color and size of the drawing pen. The button, when clicked, invokes a function that clears the canvas. ...
<input type="reset"> - HTML: Hypertext Markup Language
" but this will vary depending on the user agent): <input type="reset"> Using reset buttons <input type="reset"> buttons are used to reset forms. If you want to create a custom button and then customize the behaviour using JavaScript, you need to use <input type="button">, or better still, a <button> element. A simple reset button We'll begin by creating a simple reset button: <form> <
div> <label for="example">Type in some sample text</label> <input id="example" type="text"> </
div> <
div> <input type="reset" value="Reset the form"> </
div> </form> This renders like so: Try entering some text into the text field, and then pressing the reset button. Adding a reset keyboard shortcut To add a keyboard shortcut to a submit button -- just as you would with any <in...
...he reset button. Adding a reset keyboard shortcut To add a keyboard shortcut to a submit button -- just as you would with any <input> for which it makes sense -- you use the accesskey global attribute. In this example, r is specified as the access key (you'll need to press r plus the particular modifier keys for your browser/OS combination; see accesskey for a useful list of those). <form> <
div> <label for="example">Type in some sample text</label> <input id="example" type="text"> </
div> <
div> <input type="reset" value="Reset the form" accesskey="r"> </
div> </form> The problem with the above example is that there's no way for the user to know what the access key is! This is especially true since the modifiers are typically non-standard to avoid conflicts. When ...
<input type="submit"> - HTML: Hypertext Markup Language
a <button> element. If you choose to use <button> elements to create the buttons in your form, keep this in mind: if there's only one <button> inside the <form>, that button will be treated as the "submit" button. So you should be in the habit of expressly specifying which button is the submit button. A simple submit button We'll begin by creating a form with a simple submit button: <form> <
div> <label for="example">Let's submit some text</label> <input id="example" type="text" name="text"> </
div> <
div> <input type="submit" value="Send"> </
div> </form> This renders like so: Try entering some text into the text field, and then submitting the form. Upon submitting, the data name/value pair gets sent to the server. In this instance, the string will be text=usertext,...
..., s is specified as the access key (you'll need to press s plus the particular modifier keys for your browser/OS combination. In order to avoid conflicts with the user agent's own keyboard shortcuts, different modifier keys are used for access keys than for other shortcuts on the host computer. See accesskey for further details. Here's the previous example with the s access key added: <form> <
div> <label for="example">Let's submit some text</label> <input id="example" type="text" name="text"> </
div> <
div> <input type="submit" value="Send" accesskey="s"> </
div> </form> For example, in Firefox for Mac, pressing Control-Option-S triggers the Send button, while Chrome on Windows uses Alt+S. The problem with the above example is that the user will not know what the a...
<menuitem> - HTML: Hypertext Markup Language
adio. type This attribute indicates the kind of command, and can be one of three values. command: A regular command with an associated action. This is the missing value default. checkbox: Represents a command that can be toggled between two different states. radio: Represent one selection from a group of commands that can be toggled as radio buttons. Example HTML content <!-- A <
div> element with a context menu --> <
div contextmenu="popup-menu"> Right-click to see the adjusted context menu </
div> <menu type="context" id="popup-menu"> <menuitem type="checkbox" checked>Checkbox</menuitem> <hr> <menuitem type="command" label="This command does nothing" icon="https://developer.cdn.mozilla.net/static/img/favicon144.png"> Commands don't render their contents. </menu...
...favicon144.png"> Commands don't render their contents. </menuitem> <menuitem type="command" label="This command has javascript" onclick="alert('command clicked')"> Commands don't render their contents. </menuitem> <hr> <menuitem type="radio" radiogroup="group1">Radio Button 1</menuitem> <menuitem type="radio" radiogroup="group1">Radio Button 2</menuitem> </menu> CSS content
div { width: 300px; height: 80px; background-color: lightgreen; } Result Specifications Specification Status Comment HTML 5.2The definition of '<menuitem>' in that specification. Recommendation Snapshot of the HTML Living Standard, made obsolete. HTML 5.1The definition of '<menuitem>' in that specification. Recommendation Snapshot of the HT...
<section>: The Generic Section element - HTML: Hypertext Markup Language
nt Attributes This element only includes the global attributes. Usage notes Each <section> should be identified, typically by including a heading (<h1>-<h6> element) as a child of the <section> element. If it makes sense to separately syndicate the content of a <section> element, use an <article> element instead. ...
... child of the <section> element. If it makes sense to separately syndicate the content of a <section> element, use an <article> element instead. Do not use the <section> element as a generic container; this is what <
div> is for, especially when the sectioning is only for styling purposes. A rule of thumb is that a section should logically appear in the outline of a document. Example Before <
div> <h1>Heading</h1> <p>Bunch of awesome content</p> </
div> After <section> <h1>Heading</h1> <p>Bunch of awesome content</p> </section> Specifications Specification Status Comment HTML Living StandardThe definition of '<section>' in that specification. Living Standard HTML 5.1The definition of '<section>' in that specification. Recommendati...
<slot> - HTML: Hypertext Markup Language
In addition, you can find an explanation at Using templates and slots. Specifications Specification Status Comments HTML Living Standard...
...In addition, you can find an explanation at Using templates and slots. Specifications Specification Status Comments HTML Living StandardThe definition of '<slot>' in that specification. Living Standard DOMThe definition of 'S...
HTML elements reference - HTML: Hypertext Markup Language
ually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> element. <dd> The HTML <dd> element provides the description, definition, or value for the preceding term (<dt>) in a description list (<dl>). <
div> The HTML Content
Division element (<
div>) is the generic container for flow content. It has no effect on the content or layout until styled using CSS. <dl> The HTML <dl> element represents a description list. The element encloses a list of groups of terms (specified using the <dt> element) and descriptions (provided by <dd> elements). Common uses for this element are to implemen...
...m to treat the text it contains in isolation from its surrounding text. <bdo> The HTML Bidirectional Text Override element (<bdo>) overrides the current directionality of text, so that the text within is rendered in a different direction. <br> The HTML <br> element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the
division of lines is significant. <cite> The HTML Citation element (<cite>) is used to describe a reference to a cited creative work, and must include the title of that work. <code> The HTML <code> element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code. <data> The HTML <data> element links a g...
tabindex - HTML: Hypertext Markup Language
ir position in the document source. The maximum value for tabindex is 32767. If not specified, it takes the default value 0. Avoid using tabindex values greater than 0. Doing so makes it difficult for people who rely on assistive technology to navigate and operate page content. Instead, write the document with the elements in a logical sequence. ...
... Interactive components authored using non-interactive elements are not be listed in the accessibility tree. This prevents assistive technology from being able to navigate to and manipulate those components. ...
title - HTML: Hypertext Markup Language
, like <abbr title="This is a multiline title">example</abbr>.</p> Result Title attribute inheritance If an element has no title attribute, then it inherits it from its parent node, which in turn may inherit it from its parent, and so on. If this attribute is set to the empty string, it means its ancestors' titles are irrelevant and shouldn't be used in the tooltip for this element. ...
...nt has no title attribute, then it inherits it from its parent node, which in turn may inherit it from its parent, and so on. If this attribute is set to the empty string, it means its ancestors' titles are irrelevant and shouldn't be used in the tooltip for this element. ...
HTML documentation index - HTML: Hypertext Markup Language
tioning Root Element, Sections, Web The HTML <body> Element represents the content of an HTML document. There can be only one <body> element in a document. 74 <br>: The Line Break element Element, HTML, HTML text-level semantics, Reference, Web The HTML <br> element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the
division of lines is significant. 75 <button>: The Button element Element, Forms, HTML, HTML forms, Reference, Web The HTML <button> element represents a clickable button, used to submit forms or anywhere in a document for accessible, standard button functionality. 76 <canvas>: The Graphics Canvas element Canvas, Element, HTML, HTML scripting, HTML5, Reference, Web...
...interactive component, such as a dismissable alert, inspector, or subwindow. 92 <dir>: The Directory element (obsolete) Directory, Element, HTML, HTML Lists, Obsolete, Reference, Web, dir, lists The obsolete HTML Directory element (<dir>) is used as a container for a directory of files and/or folders, potentially with styles and icons applied by the user agent. 93 <
div>: The Content
Division element Content
Division, Element, HTML, HTML grouping content, HTML:Flow content, Layout, Reference, Web,
div The HTML Content
Division element (<
div>) is the generic container for flow content. It has no effect on the content or layout until styled using CSS. 94 <dl>: The Description List element Element, HTML, HTML grouping content, HTML:Flow con...
Evolution of HTTP - HTTP
A lot of interoperability problems were common. In November 1996, in order to solve these annoyances, an informational document describing the common practices has been published, RFC 1945. This is the definition of HTTP/1.0 and it is notable that, in the narrow sense of the term, it isn't an official standard. HTTP/1.1 - The standardized protocol In parallel to the somewhat chaotic use of the
diverse implementations of HTTP/1.0, and since 1995, well before the publication of HTTP/1.0 document the next year, proper standardization was in progress. The first standardized version of HTTP, HTTP/1.1 was published in early 1997, only a few months after HTTP/1.0. HTTP/1.1 clarified ambiguities and introduced numerous improvements: A connection can be reused, saving the time to reopen it nume...
...e authenticity of the messages exchanged between the server and client. SSL was put on the standards track and eventually became TLS, with versions 1.0, 1.1, 1.2, and 1.3 appearing successfully to close vulnerabilities. During the same time, the need for an encrypted transport layer raised: the Web left the relative trustiness of a mostly academic network, to a jungle where advertisers, random in
dividuals or criminals compete to get as much private information about people, try to impersonate them or even to replace data transmitted by altered ones. As the applications built over HTTP became more and more powerful, having access to more and more private information like address books, e-mail, or the geographic position of the user, the need to have TLS became ubiquitous even outside the e-co...
MIME types (IANA media types) - HTTP
the exception of parameter values, whose case may or may not have specific meaning. Types There are two classes of type: discrete and multipart. Discrete types are types which represent a single file or medium, such as a single text or music file, or a single video. A multipart type is one which represents a document that's comprised of multiple component parts, each of which may have its own in
dividual MIME type; or, a multipart type may encapsulate multiple files being sent together in one transaction. For example, multipart MIME types are used when attaching multiple files to an email. Discrete types The discrete types currently registered with the IANA are: applicationList at IANA Any kind of binary data that doesn't fall explicitly into one of the other types; either data that wi...
...rded message as part of its data, or to allow sending very large messages in chunks as if it were multiple messages. Examples include message/rfc822 (for forwarded or replied-to message quoting) and message/partial to allow breaking a large message into smaller ones automatically to be reassembled by the recipient. multipart List at IANA Data that is comprised of multiple components which may in
dividually have different MIME types. Examples include multipart/form-data (for data produced using the FormData API) and multipart/byteranges (defined in RFC 7233: 5.4.1 and used with HTTP's 206 "Partial Content" response returned when the fetched data is only part of the content, such as is delivered using the Range header). Important MIME types for Web developers application/octet-stream This ...
Feature Policy - HTTP
nt document or frame if its origin matches the allowed list of origins. For each policy-controlled feature, the browser maintains a list of origins for which the feature is enabled, known as an allowlist. If you do not specify a policy for a feature, then a default allowlist will be used. The default allowlist is specific to each feature. Writing a policy A policy is described using a set of in
dividual policy directives. A policy directive is a combination of a defined feature name, and an allowlist of origins that can use the feature. Specifying your policy Feature Policy provides two ways to specify policies to control features: The Feature-Policy HTTP header. The allow attribute on iframes. The primary difference between the HTTP header and the allow attribute is that the allow ...
... ...
An overview of HTTP - HTTP
ces, such as HTML documents. It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser. A complete document is reconstructed from the different sub-documents fetched, for instance text, layout description, images, videos, scripts, and more. Clients and servers communicate by exchanging in
dividual messages (as opposed to a stream of data). The messages sent by the client, usually a Web browser, are called requests and the messages sent by the server as an answer are called responses. Designed in the early 1990s, HTTP is an extensible protocol which has evolved over time. It is an application layer protocol that is sent over TCP, or over a TLS-encrypted TCP connection, though any reli...
.... HTTP can also be used to fetch parts of documents to update Web pages on demand. Components of HTTP-based systems HTTP is a client-server protocol: requests are sent by one entity, the user-agent (or a proxy on behalf of it). Most of the time the user-agent is a Web browser, but it can be anything, for example a robot that crawls the Web to populate and maintain a search engine index. Each in
dividual request is sent to a server, which handles it and provides an answer, called the response. Between the client and the server there are numerous entities, collectively called proxies, which perform different operations and act as gateways or caches, for example. In reality, there are more computers between a browser and the server handling the request: there are routers, modems, and more. ...
A typical HTTP session - HTTP
rver periodically via the XMLHTTPRequest, Fetch APIs, using the WebSockets API, or similar protocols. Sending a client request Once the connection is established, the user-agent can send the request (a user-agent is typically a web browser, but can be anything else, a crawler, for example). A client request consists of text directives, separated by CRLF (carriage return, followed by line feed),
divided into three blocks: The first line contains a request method followed by its parameters: the path of the document, i.e. an absolute URL without the protocol or domain name the HTTP protocol version Subsequent lines represent an HTTP header, giving the server information about what type of data is appropriate (e.g., what language, what MIME types), or other data altering its b...
...using GET should only retrieve data. The POST method sends data to a server so it may change its state. This is the method often used for HTML Forms. Structure of a server response After the connected agent has sent its request, the web server processes it, and ultimately returns a response. Similar to a client request, a server response is formed of text directives, separated by CRLF, though
divided into three blocks: The first line, the status line, consists of an acknowledgment of the HTTP version used, followed by a status request (and its brief meaning in human-readable text). Subsequent lines represent specific HTTP headers, giving the client information about the data sent (e.g. type, data size, compression algorithm used, hints about caching). Similarly to the block of HTTP he...
JavaScript data types and data structures - JavaScript
_SAFE_INTEGER. Beyond this range, integers in JavaScript are not safe anymore and will be a double-precision floating point approximation of the value. The number type has only one integer with two representations: 0 is represented as both -0 and +0. (0 is an alias for +0.) In the praxis, this has almost no impact. For example, +0 === -0 is true. However, you are able to notice this when you
divide by zero: > 42 / +0 Infinity > 42 / -0 -Infinity Although a number often represents only its value, JavaScript provides binary (bitwise) operators. Caution: Although bitwise operators can be used to represent several Boolean values within a single number using bit masking, this is usually considered a bad practice. JavaScript offers other means to represent a set of Booleans (like an array...
...next at index 1, and so on. The length of a String is the number of elements in it. Unlike some programming languages (such as C), JavaScript strings are immutable. This means that once a string is created, it is not possible to modify it. However, it is still possible to create another string based on an operation on the original string. For example: A substring of the original by picking in
dividual letters or using String.substr(). A concatenation of two strings using the concatenation operator (+) or String.concat(). Beware of "stringly-typing" your code! It can be tempting to use strings to represent complex data. Doing this comes with short-term benefits: It is easy to build complex strings with concatenation. Strings are easy to debug (what you see printed is always what is...
JavaScript modules - JavaScript
: index.html main.js modules/ canvas.js square.js Note: All of the examples in this guide have basically the same structure; the above should start getting pretty familiar. The modules directory's two modules are described below: canvas.js -- contains functions related to setting up the canvas: create() -- creates a canvas with a specified width and height inside a wrapper <
div> with a specified ID, which is itself appended inside a specified parent element. Returns an object containing the canvas's 2D context and the wrapper's ID. createReportList() -- creates an unordered list appended inside a specified wrapper element, which can be used to output report data into. Returns the list's ID. square.js -- contains: name -- a constant containing the string '...
... shapes/ circle.js square.js triangle.js In each of the submodules, the export is of the same form, e.g. export { Square }; Next up comes the aggregation part. Inside shapes.js, we include the following lines: export { Square } from './shapes/square.js'; export { Triangle } from './shapes/triangle.js'; export { Circle } from './shapes/circle.js'; These grab the exports from the in
dividual submodules and effectively make them available from the shapes.js module. Note: The exports referenced in shapes.js basically get redirected through the file and don't really exist there, so you won't be able to write any useful related code inside the same file. So now in the main.js file, we can get access to all three module classes by replacing import { Square } from './modules/squa...
Text formatting - JavaScript
s the number 4 eval(secondString); // Returns the string "2 + 2" A String object has one property, length, that indicates the number of UTF-16 code units in the string. For example, the following code assigns helloLength the value 13, because "Hello, World!" has 13 characters, each represented by one UTF-16 code unit. You can access each code unit using an array bracket style. ...
...s has no effect, because strings are immutable hello[0]; // This returns "H" Characters whose Unicode scalar values are greater than U+FFFF (such as some rare Chinese/Japanese/Korean/Vietnamese characters and some emoji) are stored in UTF-16 with two surrogate code units each. For example, a string containing the single character U+1F600 "Emoji grinning face" will have length 2. Accessing the in
dividual code units in such a string using brackets may have undesirable consequences such as the formation of strings with unmatched surrogate code units, in violation of the Unicode standard. (Examples should be added to this page after MDN bug 857438 is fixed.) See also String.fromCodePoint() or String.prototype.codePointAt(). A String object has a variety of methods: for example those that retur...
Memory Management - JavaScript
n f(a) { return a + 2; } // allocates a function (which is a callable object) // function expressions also allocate an object someElement.addEventListener('click', function() { someElement.style.backgroundColor = 'blue'; }, false); Allocation via function calls Some function calls result in object allocation. var d = new Date(); // allocates a Date object var e = document.createElement('
div'); // allocates a DOM element Some methods allocate new values or objects: var s = 'azerty'; var s2 = s.substr(0, 3); // s2 is a new string // Since strings are immutable values, // JavaScript may decide to not allocate memory, // but just store the [0, 3] range. var a = ['ouais ouais', 'nan nan']; var a2 = ['generation', 'nan nan']; var a3 = a.concat(a2); // new array with 4 elements being //...
...ge collection. Circular references are a common cause of memory leaks. function f() { var x = {}; var y = {}; x.a = y; // x references y y.a = x; // y references x return 'azerty'; } f(); Real-life example Internet Explorer 6 and 7 are known to have reference-counting garbage collectors for DOM objects. Cycles are a common mistake that can generate memory leaks: var
div; window.onload = function() {
div = document.getElementById('my
DivElement');
div.circularReference =
div;
div.lotsOfData = new Array(10000).join('*'); }; In the above example, the DOM element "my
DivElement" has a circular reference to itself in the "circularReference" property. If the property is not explicitly removed or nulled, a reference-counting garbage collector will always have at ...
Date - JavaScript
rly useful are the functions that output the date and time in Coordinated Universal Time (UTC), the global standard time defined by the World Time Standard. (This time is historically known as Greenwich Mean Time, as UTC lies along the meridian that includes London--and nearby Greenwich--in the United Kingdom.) The user's device provides the local time. In addition to methods to read and alter in
dividual components of the local date and time (such as getDay() and setHours()), there are also versions of the same methods that read and manipulate the date and time using UTC (such as getUTCDay() and setUTCHours()). Constructor Date() Creates a new Date object. Static methods Date.now() Returns the numeric value corresponding to the current time--the number of milliseconds elapsed sinc...
...turn = printElapsedTime(yourFunction) Note: In browsers that support the Web Performance API's high-resolution time feature, Performance.now() can provide more reliable and precise measurements of elapsed time than Date.now(). Get the number of seconds since the ECMAScript Epoch let seconds = Math.floor(Date.now() / 1000) In this case, it's important to return only an integer--so a simple
division won't do. It's also important to only return actually elapsed seconds. (That's why this code uses Math.floor(), and not Math.round().) Specifications Specification ECMAScript (ECMA-262)The definition of 'Date' in that specification. ...
Number.NEGATIVE_INFINITY - JavaScript
Number.NEGATIVE_INFINITY is the same as the negative value of the global object's Infinity property. This value behaves slightly differently than mathematical infinity: Any positive value, including POSITIVE_INFINITY, multiplied by NEGATIVE_INFINITY is NEGATIVE_INFINITY. Any negative value, including NEGATIVE_INFINITY, multiplied by NEGATIVE_INFINITY is POSITIVE_INFINITY. Any positive value
divided by NEGATIVE_INFINITY is negative zero. Any negative value
divided by NEGATIVE_INFINITY is positive zero. Zero multiplied by NEGATIVE_INFINITY is NaN. NaN multiplied by NEGATIVE_INFINITY is NaN. NEGATIVE_INFINITY,
divided by any negative value except NEGATIVE_INFINITY, is POSITIVE_INFINITY. NEGATIVE_INFINITY,
divided by any positive value except POSITIVE_INFINITY, is NEGATIVE_INFINITY. N...
... You might use the Number.NEGATIVE_INFINITY property to indicate an error condition that returns a finite number in case of success. Note, however, that isFinite would be more appropriate in such a case. ...
Number.POSITIVE_INFINITY - JavaScript
alue of Number.POSITIVE_INFINITY is the same as the value of the global object's Infinity property. This value behaves slightly differently than mathematical infinity: Any positive value, including POSITIVE_INFINITY, multiplied by POSITIVE_INFINITY is POSITIVE_INFINITY. Any negative value, including NEGATIVE_INFINITY, multiplied by POSITIVE_INFINITY is NEGATIVE_INFINITY. Any positive number
divided by POSITIVE_INFINITY is positive Zero. Any negative number
divided by POSITIVE_INFINITY is negative Zero. Zero multiplied by POSITIVE_INFINITY is NaN. NaN multiplied by POSITIVE_INFINITY is NaN. POSITIVE_INFINITY,
divided by any negative value except NEGATIVE_INFINITY, is NEGATIVE_INFINITY. POSITIVE_INFINITY,
divided by any positive value except POSITIVE_INFINITY, is POSITIVE_INFINITY. ...
... You might use the Number.POSITIVE_INFINITY property to indicate an error condition that returns a finite number in case of success. Note, however, that isFinite would be more appropriate in such a case. ...
String.prototype.charAt() - JavaScript
racters that are not in the Basic Multi-lingual Plane. ...
...r an incrementing variable automatically (if the character warrants it in being a surrogate pair). ...
String.prototype.split() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax str.split([separator[, limit]]) Parameters separator Optional The pattern describing where each split should occur. The separator can be a simple string or it can be a regular expression. ...
...rings, an empty array is returned. const myString = '' const splits = myString.split() console.log(splits) // ? [""] The following example defines a function that splits a string into an array of strings using separator. After splitting the string, the function logs messages indicating the original string (before the split), the separator used, the number of elements in the array, and the in
dividual array elements. function splitString(stringToSplit, separator) { const arrayOfStrings = stringToSplit.split(separator) console.log('The original string is: ', stringToSplit) console.log('The separator is: ', separator) console.log('The array has ', arrayOfStrings.length, ' elements: ', arrayOfStrings.join(' / ')) } const tempestString = 'Oh brave new world that has such people in ...
String - JavaScript
tives and string objects can be used interchangeably in most situations. See "String primitives and String objects" below. String literals can be specified using single or double quotes, which are treated identically, or using the backtick character `. This last form specifies a template literal: with this form you can interpolate expressions. ...
...identically, or using the backtick character `. This last form specifies a template literal: with this form you can interpolate expressions. Character access There are two ways to access an in
dividual character in a string. The first is the charAt() method: return 'cat'.charAt(1) // returns "a" The other way (introduced in ECMAScript 5) is to treat the string as an array-like object, where in
dividual characters correspond to a numerical index: return 'cat'[1] // returns "a" When using bracket notation for character access, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See Object.defineProperty() for more information.) Comparing strings In C, the strcmp() function is used for comparing stri...
Expressions and operators - JavaScript
plus operator converts its operand to Number type. - The unary negation operator converts its operand to Number type and then negates it. ~ Bitwise NOT operator. ! Logical NOT operator. Arithmetic operators Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. + Addition operator. - Subtraction operator. /
Division operator. * Multiplication operator. % Remainder operator. ** Exponentiation operator. Relational operators A comparison operator compares its operands and returns a Boolean value based on whether the comparison is true. in The in operator determines whether an object has a given property. instanceof The instanceof operator determines whether an object is an instance of anothe...
...value. && Logical AND. || Logical OR. Conditional (ternary) operator (condition ? ifTrue : ifFalse) The conditional operator returns one of two values based on the logical value of the condition. Assignment operators An assignment operator assigns a value to its left operand based on the value of its right operand. = Assignment operator. *= Multiplication assignment. /=
Division assignment. %= Remainder assignment. += Addition assignment. -= Subtraction assignment <<= Left shift assignment. >>= Right shift assignment. >>>= Unsigned right shift assignment. &= Bitwise AND assignment. ^= Bitwise XOR assignment. |= Bitwise OR assignment. &&= Logical AND assignment. ||= Logical OR assignment. ??= Logical nullish assignment. [a, b] = [1, 2] {a, b...
export - JavaScript
although they can only be read by the importing module the value updates whenever it is updated by the exporting module. Exported modules are in strict mode whether you declare them as such or not. The export statement cannot be used in embedded scripts. ...
....; nameN Identifier to be exported (so that it can be imported via import in another script). Description There are two different types of export, named and default. You can have multiple named exports per module but only one default export. Each type corresponds to one of the above syntax: Named exports: // export features declared earlier export { myFunction, myVariable }; // export in
dividual features (can export var, let, // const, function, class) export let myVariable = Math.sqrt(2); export function myFunction() { ... }; Default exports: // export feature declared earlier as default export { myFunction as default }; // export in
dividual features as default export default function () { ... } export default class { .. } Named exports are useful to export several values. Dur...
Web audio codec guide - Web media technologies
ation solutions. See Codecs used by WebRTC for details. For information about the fundamental concepts behind how digital audio works, see the article Digital audio concepts. Common codecs The list below denotes the codecs most commonly used on the web and which containers (file types) support them. If all you need to know is which codecs are even possible to use, this is for you. Of course, in
dividual browsers may or may not choose to support all of these codecs, and their support for which container types can use them may vary as well. In addition, browsers may choose to support additional codecs not included on this list. Codec name (short) Full codec name Container support AAC Advanced Audio Coding MP4, ADTS, 3GP ALAC Apple Lossless Audio ...
...es the range of audio frequencies that can be represented using the codec. Some codecs operate specifically by eliminating audio that falls outside a given frequency range. There is a correlation between the sample rate and the maxium sound frequency that can be represented by a waveform represented by a codec. At a theoretical level, the maximum frequency a codec can represent is the sample rate
divided by two; this frequency is called the Nyquist frequency. In reality, the maximum is slightly lower, but it's close. The audio frequency bandwidth comes into play especially vividly when a codec is designed or configured to represent human speech rather than a broad range of sounds. Human speech generally resides within the audio frequency range of 300 Hz to 18 kHz. However, the vast majority ...
Digital video concepts - Web media technologies
hen converting it to numeric form. There are several color models, and video codec makes use of one or more of these to represent their pixels during the encoding process as well as after decoding the video frames. RGB Most computer graphics models use the RGB color system, wherein some number of bits of data are used to represent each of the red, green, and blue components of the color of an in
dividual pixel, and an image is comprised of a two-dimensional array of these pixels. There are two primary methods used to represent RGB samples: using integer components and using floating-point components. When using integer components, RGB color uses 8 bits each of red, green, and blue, as well as potentially 8 bits of alpha (the amount of transparency). YUV Unlike RGB, the YUV (or Y'UV) color ...
...ur luma samples has two chroma samples applied to it, and the bottom row of luma has two samples applied to it as well. The eight pixels represented by this block, then, have four chroma samples shared among them. The final example demonstrates 4:4:4 subsampling. There are four luma samples in each row and four chroma samples in each row as well, so that every pixel represented by the block is in
dividually colored. What if the chroma subsampling model is 4:0:0? That says to use every pixel of luma data, but that each row has 0 chroma samples applied to it. The resulting image, then, is comprised solely of the luminance data--a greyscale image. YUV data representation Because the image is represented using more detail in greyscale than in color, the values of Y', U, and V are not typically...
Populating the page: how browsers work - Web Performance
rver receives the request, it will reply with relevant response headers and the contents of the HTML. <!doctype HTML> <html> <head> <meta charset="UTF-8"/> <title>My simple page</title> <link rel="stylesheet" src="styles.css"/> <script src="myscript.js"></script> </head> <body> <h1 class="heading">My Page</h1> <p>A paragraph with a <a href="https://example.com/about">link</a></p> <
div> <img src="myimage.jpg" alt="image description"/> </
div> <script src="anotherscript.js"></script> </body> </html> This response for this initial request contains the first byte of data received. Time to First Byte (TTFB) is the time between when the user made the request--say by clicking on a link--and the receipt of this first packet of HTML. The first chunk of content is usually 14kb o...
...first time the size and position of nodes are determined is called layout. Subsequent recalculations of node size and locations are called reflows. In our example, suppose the initial layout occurs before the image is returned. Since we didn't declare the size of our image, there will be a reflow once the image size is known. Paint The last step in the critical rendering path is painting the in
dividual nodes to the screen, the first occurence of which is called the first meaningful paint. In the painting or rasterization phase, the browser converts each box calculated in the layout phase to actual pixels on the screen. Painting involves drawing every visual part of an element to the screen, including text, colors, borders, shadows, and replaced elements like buttons and images. The browser...
Navigation and resource timings - Web Performance
e being timed is this document For the rest of this explanation, we use the following variable: let timing = performance.getEntriesByType('navigation')[0]; Protocol We can check the protocol used by querying: let protocol = timing.nextHopProtocol It returns the network protocol used to fetch the resource: in this case h2 for http/2. Compression To get the compression savings percentage, we
divide the transferSize by the decodedBodySize, and subtract that from 100%. We see a savings of over 74%. let compressionSavings = 1 - (timing.transferSize / timing.decodedBodySize) We could have used let compressionSavings = 1 - (timing.encodedBodySize / timing.decodedBodySize) but using transfersize includes the overhead bytes. For comparison, we can look at the network tab and see that we tr...
...y.startTime properties. The PerformanceNavigationTiming interface also provides information about what type of navigation you are measuring, returning navigate, reload, back_forward or prerender. Resource timing Whereas navigation timing is for measuring the performance of the main page, generally the HTML file via which all the other assets are requested, resource timing measures timing for in
dividual resources, the assets called in by the main page, and any assets that those resources request. Many of the measurements are similar: there is a DNS look up, TCP handshake and the secure connection start is done once per domain. The main thing to look at for each resource. See Also PerformanceNavigationTiming PerformanceResourceTiming, PerformanceMark PerformanceMeasure Performance...
Mobile first - Progressive web apps (PWAs)
There is very little going on here, and anyone with a basic understanding of CSS should be able to understand mo...
...<li><a href="#">Articles</a></li> <li><a href="#">Videos</a></li> <li><a href="#">Work</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav> <header> <a id="top" href="#bottom">Jump to menu</a> <h1>My article</h1> </header> <
div class="main"> <p>Lorem ipsum ... </p> <a id="bottom" href="#top">Back to top</a> </
div> </article> <button id="install-btn">Install</button> Default mobile CSS For the CSS, I first added some styles into our app.css stylesheet to provide a reasonable narrow-screen layout. There is very little going on here, and anyone with a basic understanding of CSS should be able to understand most of it by just looking at the source code in app.css. Particular bits of interest to point out ...
in - SVG: Scalable Vector Graphics
within the same filter element. If no value is provided, the output will only be available for re-use as the implicit input into the next filter primitive if that filter primitive provides no value for its in attribute. Workaround for BackgroundImage Instead of using in="BackgroundImage", we need to import one of the images to blend inside the filter itself, using an <feImage> element. HTML <
div style="width: 420px; height: 220px;"> <svg style="width:200px; height:200px; display: inline;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <filter id="backgroundMultiply"> <!-- This will not work. --> <feBlend in="BackgroundImage" in2="SourceGraphic" mode="multiply"/> </filter> </defs> <image xlink:href="https://developer.mozilla...
.../1999/xlink"> <defs> <filter id="imageMultiply"> <!-- This is a workaround. --> <feImage xlink:href="https://developer.mozilla.org/files/6457/mdn_logo_only_color.png" x="10%" y="10%" width="80%" height="80%"/> <feBlend in2="SourceGraphic" mode="multiply"/> </filter> </defs> <circle cx="50%" cy="40%" r="40%" fill="#c00" style="filter:url(#imageMultiply);"/> </svg> </
div> Result Specifications Specification Status Comment Filter Effects Module Level 1The definition of 'in' in that specification. Working Draft No change Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of 'in' in that specification. Recommendation Initial definition ...
textLength - SVG: Scalable Vector Graphics
width="2"/> <text id="hello" x="10" y="150" font-family="sans-serif" font-size="60" fill="green"> Hello world! </text> </svg> First, a <rect> element is used to create and stroke a rectangle to contain the text. Then <text> is used to create the text element itself, with an id of "hello". HTML The HTML is also simple, with only two displayed elements contained inside a grouping <
div>: <
div class="controls"> <input type="range" id="widthSlider" min="80" max="978"> <span id="widthDisplay"></span> </
div> The <input> element, of type "range", is used to create the slider control the user will manipulate to change the width of the text. A <span> element of ID "widthDisplay" is provided to display the current width value. JavaScript Finally, let's have a look at the JavaSc...
...s will be sent any time the slider's value changes, even if the user hasn't stopped moving it, so we can responsively adjust the text width. When an "input" event occurs, we call SVGLength.newValueSpecifiedUnits() to set the value of textLength to the slider's new value, using the SVGLength interface's SVG_LENGTHTYPE_PX unit type to indicate that the value represents pixels. Note that we have to
dive into textLength to get its baseVal property; textLength is stored as an SVGLength object, so we can't treat it like a plain number. After updating the text width, the contents of the widthDisplay box are updated with the new value as well, and we're finished. Result Here's what the example looks like. Try dragging the slider around to get a feel for what it does. Specifications S...
Example - SVG: Scalable Vector Graphics
s. First, each mote tries to move towards the cursor, and second each mote tries to move away from the average mote position. Combined, we get this very natural looking behavior. </p> <p> This is done completely in W3C Standards-XHTML, SVG and JavaScript-no flash or any vendor specific extensions. Currently, this will work in Mozilla Firefox version 1.5 and above. ...
... version 1.5 and above. </p> <
div> (C) 2006 <a id='emailme' href='#'>Nick Johnson</a> <script type='text/javascript'> <![CDATA[ // foil spam bots var email = '@riovia.net'; email ='nick' + email; document.getElementById('emailme').href = 'mailto:'+email; ]]> </script> This software is free for you to use in any way whatsoever, and comes with no warranty at all. </
div> <form action="" onsubmit="return false;"> <p> <label>Number of motes:</label> <input id='num_motes' value='5'/> <br/> <label>Max. Velocity:</label> <input id='max_velocity' value='15'/> <br/> <label>Attraction to cursor:</label> <input id='attract_cursor' value='6'/> <br/> <label>Repulsion from peers:</label> <input id='repel_peer' value='5'/> ...
How to turn off form autocompletion - Web security
fields, even if the browser's autocomplete feature is enabled. Note that the WCAG 2.1 Success Criterion 1.3.5: Identify Input Purpose does not require that autocomplete/autofill actually work - merely that form fields that relate to specific personal user information are programmatically identified. This means that the criterion can be passed (by adding the relevant autocomplete attributes to in
dividual form fields) even when autocompletion for the form itself has been turned off. Disabling autocompletion To disable autocompletion in forms, you can set the autocomplete attribute to "off": autocomplete="off" You can do this either for an entire form, or for specific input elements in a form: <form method="post" action="/form" autocomplete="off"> [...] </form> <form method="post" action...
...en when autocompletion for the form itself has been turned off. Disabling autocompletion To disable autocompletion in forms, you can set the autocomplete attribute to "off": autocomplete="off" You can do this either for an entire form, or for specific input elements in a form: <form method="post" action="/form" autocomplete="off"> [...] </form> <form method="post" action="/form"> [...] <
div> <label for="cc">Credit card:</label> <input type="text" id="cc" name="cc" autocomplete="off"> </
div> </form> Setting autocomplete="off" on fields has two effects: It tells the browser not to save data inputted by the user for later autocompletion on similar forms, though heuristics for complying vary by browser. It stops the browser from caching form data in the session history. W...
Index - XSLT: Extensible Stylesheet Language Transformations
t type, load the file in Mozilla and look at the page info. Or use a download tool, those usually tell the mime type. 3 Index Index, Reference, XSLT Found 54 pages: 4 PI Parameters XSLT No summary! 5 The XSLT/JavaScript Interface in Gecko XSLT No summary! 6 Advanced Example XSLT This advanced example sorts several
divs based on their content. The example allows sorting the content multiple times, alternating between ascending and descending order. The JavaScript loads the .xsl file only on the first sort and sets the xslloaded variable to true once it has finished loading the file. Using the XSLTProcessor.getParameter() method, the code can figure whether to sort in ascending or descending order. It defaults t...
...to sort XML data and then display it. The sorting would have to alternate between ascending and descending sorting. 13 Transforming XML with XSLT NeedsMigration, Transforming_XML_with_XSLT, XML, XSLT The separation of content and presentation is a key design feature of XML. The structure of an XML document is designed to reflect and clarify important relationships among the in
dividual aspects of the content itself, unhindered by a need to provide any indication about how this data should eventually be presented. This intelligent structuring is particularly important as more and more data transfers are automated and take place between highly heterogeneous machines linked by a network. 14 An Overview NeedsHelp, NeedsMarkupWork, Transforming_XML_with_XSLT, XML...
An Overview - XSLT: Extensible Stylesheet Language Transformations
ion of objects in the tree, their properties, and their relationships. The tree consists of a hierarchical framework of nodes. It can be made up of seven different types of nodes: the single root node, element nodes, text nodes, attribute nodes, comment nodes, processing instruction nodes, and namespace nodes. At the top of the tree is the root node. The root node does not correspond to any in
dividual part of the XML document: it represents the document as whole. Below the root node are its children, which can be elements, comments, processing instructions and so on. Some of those children may also have children. And this can continue for several levels. There are certain constraints on which type of nodes can occur where: for example, text nodes can have no children. The result of the ...
...The particulars of how this is to be accomplished are left up to the processor. Because the order of execution of the stylesheet cannot be guaranteed, XSLT does not support any functionality that produces side-effects. In this it is like Lisp or Scheme. Locations on the tree are specified using XPath, another W3C Recommendation. Transformations depend on the processor's being able to pinpoint in
dividual nodes on the tree. To facilitate this, the W3C decided to use a separate language, XPath, which also has uses outside the XSLT context. As its name implies, XPath defines a "path" the processor must take through the tree to arrive at the desired node. This path consists of XPath-specific expressions to be evaluated, expressions which may include a number of conditions to be matched, a way of...
Cross-domain Content Scripts - Archive of obsolete content
eight: 50, contentURL: data.url("panel.html"), contentScriptFile: data.url("panel-script.js") }); forecast_panel.on("show", function(){ forecast_panel.port.emit("show"); }); require("sdk/ui/button/action").ActionButton({ id: "get-forecast", label: "Get the forecast", icon: "./icon-16.png", onClick: function() { forecast_panel.show(); } }); The "panel.html" just includes a <
div> block for the forecast: <!DOCTYPE html> <!-- panel.html --> <html> <head></head> <body> <
div id="forecast_summary"></
div> </body> </html> The "panel-script.js" uses XMLHttpRequest to fetch the latest forecast: // panel-script.js var url = "http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/json/500?key=YOUR-API-KEY"; self.port.on("show", function () { var...
Classes and Inheritance - Archive of obsolete content
Each class defines one or more members, which are initialized to a given value when the class is instantiated. Data members are properties that allow each instance to have their own state, whereas member functions are properties that allow instances to have behavior. Inheritance allows classes to inherit state and behavior from an existing classes, known as the base class. Unlike languages like C++ and Java, JavaScript does not have native support for classical inheritance. Instead, it uses something called prototypal inheritance. ...
Contributor's Guide - Archive of obsolete content
Each class defines one or more members, which are initialized to a given value when the class is instantiated. Data members are properties that allow each instance to have their own state, whereas member functions are properties that allow instances to have behavior. Inheritance allows classes to inherit state and behavior from an existing classes, known as the base class. Unlike languages like C++ and Java, JavaScript does not have native support for classical inheritance. Instead, it uses something called prototypal inheritance. ...
Module structure of the SDK - Archive of obsolete content
g add-ons using the SDK is part of a CommonJS module, including: SDK modules: the JavaScript modules which the SDK provides, such as panel and page-mod. Local modules: each of the JavaScript files under your add-on's "lib" directory. External modules: reusable modules developed and maintained outside the SDK, but usable by SDK-based add-ons. SDK Modules The modules supplied by the SDK are
divided into two sorts: High-level modules like panel and page-mod provide relatively simple, stable APIs for the most common add-on development tasks. Low-level modules like heritage and namespace provide more powerful functionality, and are typically less stable and more complex. To use SDK modules, you can pass require() a complete path, starting with "sdk", to the module you want to use. Fo...
private-browsing - Archive of obsolete content
The user enters private browsing by opening a new private browser window. When they do this, any existing non-private windows are kept open, so the user will typically have both private and non-private windows open at the same time. ...
system - Archive of obsolete content
e("sdk/system"); console.log("architecture = " + system.architecture); compiler The type of compiler used to build the host application. For example: "msvc", "n32", "gcc2", "gcc3", "sunc", "ibmc" var system = require("sdk/system"); console.log("compiler = " + system.compiler); build An identifier for the specific build, derived from the build date. This is useful if you're trying to target in
dividual nightly builds. See nsIXULAppInfo's appBuildID. var system = require("sdk/system"); console.log("build = " + system.build); id The UUID for the host application. For example, "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" for Firefox. This has traditionally been in the form "{AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}" but for some applications it may be in the form "appname@vendor.tld". See nsIXUL...
tabs - Archive of obsolete content
onOpen(tab) { myOpenTabs.push(tab); }); // Listen for tab content loads. tabs.on('ready', function(tab) { console.log('tab is loaded', tab.title, tab.url); }); Access tabs The module itself can be used as a list of all opened tabs across all windows. ...
url - Archive of obsolete content
isValidURI(uri) Checks the validity of a URI. isValidURI("http://mozilla.org") would return true, whereas isValidURI("mozilla.org") would return false. Parameters uri : string The URI, as a string, to be tested. Returns boolean : A boolean indicating whether or not the URI is valid. getTLD(url) Returns the top-level domain for the given URL: that is, the highest-level domain under which in
dividual domains may be registered. Uses getPublicSuffix() internally. var urls = require("sdk/url"); console.log(urls.getTLD("http://www.bbc.co.uk/")); // "co.uk" console.log(urls.getTLD("https://developer.mozilla.org/")); // "org" Parameters url : string The URL, as a string. Returns string : The top-level domain for the URL. URL Methods toString() Returns a string representation...
/loader - Archive of obsolete content
o modules in addition to those passed via modules: chrome This pseudo module exposes everything that is typically available for JS contexts with system principals under the Components global. This alternative approach of providing capabilities via modules makes it possible to build module capability graphs by analyzing require statements. These graphs can be used to reason about modules without
diving into implementation details. @loader/options This pseudo module exposes all the options that were used to configure this loader. It enables you to create new loader instances identical to the current one: let { Loader } = require('toolkit/loader'); let options = require('@loader/options'); let loader = Loader(options); This module is useful in very specific cases. For example the SDK uses ...
places/history - Archive of obsolete content
stModified'. descending boolean A boolean specifying whether the results should be in descending order. By default, results are in ascending order. PlacesEmitter The PlacesEmitter is not exposed in the module, but returned from the search functions. The PlacesEmitter inherits from event/target, and emits data, error, and end. data events are emitted for every in
dividual search result found, whereas end events are emitted as an aggregate of an entire search, passing in an array of all results into the handler. Events data The data event is emitted for every item returned from a search. Arguments Object : This is an object representing a history entry. Contains url, time, accessCount and title of the entry. error The error event is emitted whenever a s...
ui/button/action - Archive of obsolete content
fic label" console.log(button.state(tabs[1]).label); // Reset the tab-specific state button.state(tab, null); // access the second tab's label -> "window-specific label" console.log(button.state(tabs[1]).label); } Finally, you can pass the button itself into state(). This is an alternative way to set or get the global state. ...
ui/button/toggle - Archive of obsolete content
bel" console.log(button.state(tabs[1]).label); // Reset the tab-specific state button.state(tab, null); // access the second tab's label -> "window-specific label" console.log(button.state(tabs[1]).label); } Finally, you can pass the button itself into state(). This is an alternative way to set or get the global state. ...
Release notes - Archive of obsolete content
release entered Aurora. Bugs fixed between Firefox 34 and Firefox 35. This will not include any uplifts made after this release entered Aurora. Firefox 34 Highlights New API: dev/panel enables you to extend the Firefox Developer Tools. jpm beta released. "./my-file" introduced everywhere as an alias for require("sdk/self").data.url("my-file") Added the ability to attach stylesheets to in
dividual tabs. Details GitHub commits made between Firefox 33 and Firefox 34. This will not include any uplifts made after this release entered Aurora. Bugs fixed between Firefox 33 and Firefox 34. This will not include any uplifts made after this release entered Aurora. Firefox 33 Highlights Added support for context menus in panels via a new option in the Panel constructor. Added tab.read...
Displaying annotations - Archive of obsolete content
ich we'll call annotation. Annotation panel HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Annotation</title> <style media="all" type="text/css"> body { font: 100% arial, helvetica, sans-serif; background-color: #F5F5F5; }
div { text-align:left; } </style> </head> <body> <
div id="annotation"> </
div> </body> </html> Save this in data/annotation as annotation.html. Annotation panel Content Script The annotation panel has a minimal content script that sets the text: self.on('message', function(message) { $('#annotation').text(message); }); Save this in data/annotation as annotation.js. Updating ma...
Creating Event Targets - Archive of obsolete content
To do this, we can inherit from the SDK's EventTarget class. EventTarget provides an implementation of the functions needed to add and remove event listeners: on(), once(), and removeListener(). In this example, we could define a class BookmarkManager that inherits from EventTarget and emits added and visited events. Open "bookmarks.js" and...
Extension Versioning, Update and Compatibility - Archive of obsolete content
r general headings p for paragraphs ul and ol for lists. Within lists use the usual li tag for each list item. Within h1, h2, h3, p and li tags you may use: b or strong for bolder text i or em for italicized text Formatting in Firefox 4 and later From Firefox 4 the restrictions are relaxed somewhat. The following tags are interpreted normally: h1, h2 and h3 for general headings p,
div, pre and blockquote for block formatting ul, ol, li, dl, dt and dd for lists b, i, em, strong, u, q, sub, sup and code for text formatting br and hr for line breaking The head, style and script tags and any of their contents are completely stripped. Other tags aren't included in the result but do have their contents displayed, so the following snippet: <span><q>Text</q></span> Would be re...
How to convert an overlay extension to restartless - Archive of obsolete content
yAddon/content/defaultprefs.js", {pref:setDefaultPref} ); That's it. Once you've got the machinery to load and save preferences without having to jump through the various pref type hoops the actual preferences API sends you through, loading the actual preferences file is one line. I'd generally still recommend using the type specific functions for each pref in
dividually, but to load the defaults just use the generic functions above and it's quite simple. The other generic functions are provided above in case you need them. Unfortunately, the built in APIs for dealing with preferences are missing this basic stuff, and its plain text handling doesn't work with Unicode properly. Step 4a: Another way to handle default preferences If you want to keep your pr...
Jetpack Processes - Archive of obsolete content
ew JavaScript sandbox and returns its global scope. This global scope does not contain privileged APIs, or any non-standard JavaScript objects for that matter, though new globals can be endowed by simply attaching them to the global scope as properties. evalInSandbox(aSandbox, aScript) Evaluates the given script contents in the given sandbox's global scope. At minimum, JavaScript 1.8.1 is used. In
dividual lines of the form //@line 1 "foo.js" can be used to specify filename and line number information for debugging purposes. gc() Synchronously performs garbage collection. Handles Messages that communicate between the browser and jetpack process may contain only serializable (JSON) data and handles. A handle can be used to provide context for messages. Either the browser or the jetpack impleme...
Chapter 6: Firefox extensions and XUL applications - Archive of obsolete content
"Expected -1, got 1". Somehow, using pop() got the order of the arguments mixed up. So let's update the _letfunc function as shown in Listing 6. If we run the test again, we should get a green bar, showing that it ran correctly. Benefits of testing Implementing the tests described here confirms that the methods work correctly, and builds confidence in your implementations. Multiplication and
division are implemented the same way, but what will you do if an invalid string is passed? What if you attempt to run with nothing in the stack--what result will you return then? Try to keep in mind real-world circumstances while you're working on this. Listing 4: test_calc.js (adding sample test case) '2 1 -': function() { var calc = new rpncalc.RpnCalc(); calc.init(); calc.push(2); calc.
Chapter 5: Let's build a Firefox extension - Archive of obsolete content
is unchanged from Phase 5 in the "Developing a Simple Extension" section, but take note of everything within the defaults folder. Conclusion We've looked at how to build extensions at an extremely basic level in this chapter, and there are a lot of other interesting features to explore in extensions and XUL. But I hope that having gotten your feet wet with extensions development, you'll want to
dive in now. Operations checks on revised source files In the interest of developing extensions efficiently, you want to minimize the number of steps between revising a source file and running an operations check on it. For each type of source file, there's a different procedure to follow. The following all assumes that you've disabled the XUL cache as discussed in the section "Setting up your deve...
Chapter 2: Technologies used in developing extensions - Archive of obsolete content
Draft This page is not complete. << PreviousNext >> This document was authored by Hiroshi Shimoda of Clear Code Inc. and was originally published in Japanese for the Firefox Developers Conference Summer 2007. Shimoda-san is a co-author of Firefox 3 Hacks (O'Reilly Japan, 2008). Before we
dive into a thorough explanation, we'll quickly introduce the technologies used to develop Firefox extensions. We will also look at the minimum knowledge you'll need to have in order to develop for Firefox. Technologies used to develop Firefox extensions Firefox and its extensions are both based on and developed with technologies widely used on the web. Its structure is similar to that of the dynamic HTML used on some web pages, or the HTML applications used on Windows. If you've had experience d...
Adding Events and Commands - Archive of obsolete content
stuff*/ }, false); Be careful when doing this! You should at least validate the URL of the page that is generating the custom event, so that you know that it's coming from the right place. You should also avoid this kind of events to trigger actions that could be destructive to the user's data, because a malicious site could try to trigger these events and cause damage. There's a reason for the
division between remote content and local chrome, so make sure you respect it. There's a section further ahead on Intercepting Page Loads which complements this section very well. This should give you a solid foundation to handle interaction between web content and XUL. Additional information on custom events and how they can be used to effect communication between web content and XUL can be found ...
Adding Toolbars and Toolbar Buttons - Archive of obsolete content
s a bit hacky, but it works well. As for the image files themselves, you may be wondering why it is that all icons are included in a single file instead of having one file for every icon. One reason is that it would be complicated to manage that many files, and it becomes more likely that changes made to some of the files lead to an inconsistent appearance that is not obvious by looking at the in
dividual files. It is easier to be able to edit all icons in one go. There is also a performance gain from using a single file. To get the region that corresponds to a specific state of an icon, the -moz-image-region CSS property is used. Here are some examples of how the CSS for a toolbarbutton would look like on the 3 major platforms. This assumes that you've set the class xs-hw-toolbarbutton to a...
Adding menus and submenus - Archive of obsolete content
&xulschoolhello.greet.custom.label;" oncommand="XULSchoolChrome.GreetingDialog.greetingCustom(event);" /> </menupopup> </menu> </menubar> </toolbox> This code displays a simple menu with options for 3 different types of greetings, a menuseparator, and finally an option to show a custom greeting. The separator is usually displayed as a horizontal line that creates a logical
division between different types of menuitem elements, keeping everything more organized. A menubar can hold one or more menu elements. Menus require a menupopup element as a container for its children, which are usually menuitem elements, but can also be menuseparator, or menu in order to have multiple nesting levels: <toolbox> <menubar id="xulschoolhello-menubar"> <menu id="xulschoolhello-gr...
Adding sidebars - Archive of obsolete content
, specially if that's the only case where you need dynamic text. The alternative is to use a deck with the two labels, and change the selected index depending on the purpose of the window. This way you can still use DTD, and the code remains simple. A stack is like a deck, except that all of its children are always on display, one of top of the other. It allows you to decompose complex UI into in
dividual layers, broadening the layout possibilities. One common use for a stack is to have an image background that stretches horizontally and vertically depending on the size of the foreground object: <stack> <hbox flex="1"> <image src="chrome://xulschoolhello/skin/stack-bg.png" flex="1" /> </hbox> <hbox> <!-- Some content here. --> </hbox> </stack> This workaround is necessar...
Appendix D: Loading Scripts - Archive of obsolete content
Each of these means has its own advantages and disadvantages, as well as its own quirks which may trap the unwary. Below is an overview of the more common means of loading scripts, along with some of their primary advantages, disadvantages, quirks, and use cases. ...
Appendix F: Monitoring DOM changes - Archive of obsolete content
gs to web content from stylesheets loaded via the stylesheet service. As it is currently possible to attach only a single binding to a given DOM node at once, it is important when using this method to detach your binding from a node once your constructor has run. This is most easily done by adding a :not clause to the CSS selector that attaches your binding. For instance, when using the selector
div:not([foo-binding-done]), you can detach your binding by running this.setAttribute("foo-binding-done", true) in your constructor. Monkey patching DOM methods When you are interested in changes to particular nodes, sometimes the best way is to wrap the DOM methods of those elements, as in the monkey patching section above. For instance, if you need to know about attribute changes to a particular ...
Handling Preferences - Archive of obsolete content
re saved to the prefs.js file. The list in about:config is not complete. Some Firefox preferences have no default value, so they are left out unless you add them manually. An extensive specification of Firefox preferences can be seen in this page. You don't need to know them by heart; if doing task X requires some preference, then it's better to look for an explanation on how to do X rather than
diving into the preferences list and see if you can find the preference you need. MDC articles and other guides are usually good at specifying the preferences you'll need to use. Adding preferences to an extension Extensions can read and write Firefox preferences and, most importantly, create and manage their own. The Preferences System provides a simple, unified storage facility for name / value m...
The Essentials of an Extension - Archive of obsolete content
ntioned earlier, the chrome is composed of 3 sections: content, locale and skin. The content is the most important section, holding user interface (XUL) and script (JS) files. The skin section has the files that define most of the look and feel of the UI (using CSS and images, just like web pages). Finally, the locale section holds all text used in the extension, in DTD and properties files. This
division allows other developers to create themes that replace skins, and translators to create localizations in different languages, all of this without having to change your extension or your code. This gives Firefox extensions a great deal of flexibility. Chrome files are accessed through the chrome protocol. This is what a chrome URI looks like: chrome://packagename/section/path/to/file So...
Signing an XPI - Archive of obsolete content
diate Code Signing CA certs into Firefox. Now you know it all works, you need to add a real software developer's certificate to the NSS certificate database, and use that to sign the XPI. There are several issuers of software developer certificates, with the three key differentials: availability, cost and identity verification. Many issuers will not provide a software developer certificate to in
dividuals (how ridiculous) so you may have to search hard to find one that will, and who also has a CA root Authority installed in Mozilla Firefox. Without the certificate-issuers CA root certificate Mozilla Firefox will not confirm the validity of your certificate to users who want to install your extension. Ideally you want a certificate that has a root CA installed in all major platforms (Microsof...
Signing an extension - Archive of obsolete content
tent area of Firefox. On the installation dialog, you can see your organization name along with the file name. References Signing a XPI - more detailed instructions including test procedures. Key Manager - a Firefox extention that has the ability to sign XPI files. Signing a Firefox extension with a Windows Authenticode SSL certificate / key - Note that some CAs do not allow (or support) to
divert an Authenticode certificate to Object Signing. Please check the terms of service. Signing an executable with Authenticode - for signing executable file (exe) ...
An Interview With Douglas Bowman of Wired News - Archive of obsolete content
completely alter the presentation of thousands of pages. As a very welcome side benefit, we also believe the accessibility of Wired News will dramatically improve without the clutter of nested layout tables. Are you setting up your columns with floats or positioning? In trying to eliminate that last table I was using to set the column structure of our pages, I took a close look at both floated
divs and positioned
divs. I went back and forth between each one for two weeks, and finally narrowed in on positioned
divs as the choice for Wired News. Why did you choose positioning over floats? Floats had a few disadvantages from my perspective. One was the required order of content within generic markup. For Wired News, the center (or main) column usually contains the most important content for...
XML data - Archive of obsolete content
by HTML. Example Data in an XML document uses <INFO> tags. You want the document's INFO elements to be displayed like HTML paragraphs. In the document's stylesheet, you specify how INFO elements are to be displayed: INFO { display: block; margin: 1em 0; } The most common values for the display property are: block Displayed like HTML's
DIV (for headings, paragraphs) inline Displayed like HTML's SPAN (for emphasis within text) Add your own style rules that specify the font, spacing and other details in the same way as for HTML. More details Other values of display display the element like a list item, or like a component of a table. For the full list of display types, see The display property in th...
CSS3 - Archive of obsolete content
ange in the future. Modules and the standardization process CSS Level 2 needed 9 years, from August 2002 to June 2011 to reach the Recommendation status. This was due to the fact that a few secondary features held back the whole specification. In order to accelerate the standardization of non-problematic features, the CSS Working Group of the W3C, in a decision referred as the Beijing doctrine,
divided CSS in smaller components called modules . Each of these modules is now an independent part of the language and moves towards standardization at its own pace. While some modules are already W3C Recommendations, other still are early Working Drafts. New modules are also added when new needs are identified. Formally, there is no CSS3 standard per se . Each module being standardized independe...
Creating a dynamic status bar extension - Archive of obsolete content
status bar panel itself. We then fetch the result returned by the web server into the variable output from the XMLHttpRequest.responseText property. The text we receive back from the server looks something like this: "GOOG",414.20,"5/1/2006","1:36pm",-3.74,417.85,419.44,412.19,4760215 We then parse the text. We use the split() string function to split the comma-separated value string into its in
dividual parts, with each field in a separate element in the array fieldArray. At index 0 is the ticker symbol itself, which we don't need since we know which stock we're looking at. The status bar panel's label is set to indicate the current value of the stock, which is stored in fieldArray, by setting the samplePanel.label property. We then set the tooltip for the status bar panel by assigning an a...
Installing plugins to Gecko embedding browsers on Windows - Archive of obsolete content
hare\\plugins0942" "Product"="CompuServe" "Version"="7.0" "DisplayName"="CompuServe 7.0" The Product, Version, and DisplayName string values are currently only written by CompuServe 7.0, and they are written alongside the GeckoVer string value. Original Document Information Last Updated Date: June 18, 2002 Copyright Information: Portions of this content are (C) 1998-2006 by in
dividual mozilla.org contributors; content available under a Creative Commons license ...
Using XML Data Islands in Mozilla - Archive of obsolete content
"http://example.mozilla.org/PurchaseOrderML", "price")[0].textContent; document.getElementById("output-box").textContent = "The purchase order contains " + lineItems.length + " line items. The price of the first line item is " + firstPrice + "."; } </script> </head> <body onload="runDemo()";> <object id="purchase-order" data="purchase_order.xml" type="text/xml" style="display: none;"></object> <
div id="output-box">Demo did not run</
div> </body> </html> ...
Autodial for Windows NT - Archive of obsolete content
is pref in the UI, but perhaps it should be there. Or pehaps we should assume Mozilla users can configure the autodial service and disable the helper by default, but Netscape users need a little more help, and enable it for them. Original Document Information Author(s): Benjamin Chuang Last Updated Date: October 2, 2002 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Bonsai - Archive of obsolete content
e. If you're updating our cvs tree you'll need to learn about Hacking with Bonsai. Bonsai Source Code The source code to the Bonsai tool itself is also available, check out the information available at the Bonsai project page. Original Document Information Author(s): Jamie Zawinski Last Updated Date: September 8, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Finding the file to modify - Archive of obsolete content
The structure layer identifies the widgets (menus, buttons, etc.) and their position in the UI relative to each other, the style layer defines how the widgets look (size, color, style, etc.) and their overall position (alignment), and the behavior layer specifies how the widgets behave and how users can use them to accomplish their goals. mention the localization layer (Note: These layers are not completely mutually exclusive. ...
Creating a Release Tag - Archive of obsolete content
/client.mk Check the build scripts back in to the mini-branch. cvs ci mozilla/client.mk Create the tag. find . -type d \! -name CVS | xargs -l -P10 cvs tag -l MOZILLA_0_9_4_1_RELEASE >& ../taglog Original Document Information Author(s): Dawn Endico Last Updated Date: November 1, 2005 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
In-Depth - Archive of obsolete content
way the items in this box are displayed. Normal in English web browsers items are displayed top to bottom and left to right. This will flip it around so items inside of this box will be displayed bottom to top and right to left. This is useful for, say, putting the navigation controls (back button) on the right hand side of the toolbar. Values: Normal, Reverse -moz-image-region This is useful for
dividing up an image into multiple smaller images. It uses a rect() object to determine the clipping region. Check out the section on Organizing Images for more information. Example: -moz-image-region: rect(168px 69px 189px 46px); -moz-opacity Makes boxes semi-transparent. It takes a decimal value, 0.00 is invisible and 1.00 is totally visible. How do I know what to Modify? Now that you've got every...
Developing New Mozilla Features - Archive of obsolete content
e that vigilance is necessary to make sure newcomers and their features don't get lost. If you're having a particularly bad experience or if you've got suggestions on how to improve our process, please let mozilla.org staff know. Original Document Information Author(s): Mitchell Baker Last Updated Date: October 30, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Editor Embedding Guide - Archive of obsolete content
ou have created an nsICommandParams you call the "Set" methods. SetBooleanValue SetLongValue SetDoubleValue SetStringValue SetCStringValue SetISupportsValue RemoveValue Each will take a name value pair. In the case of SetBooleanValue for example you use a boolean as the second parameter. commandParam->SetCStringValue("state_attribute","left"); Reading For reading you may go after in
dividual name/value pairs you know are there or you may iterate through all the name/value pairs and programatically pull off data. First GetNext (returns the next name in the name/value pair list) HasMoreElements GetValueType (numeric enum type see nsICommandParams for values) If the name/value pair is known or it was obtained using the methods described above, it is possible to call the fol...
Layout FAQ - Archive of obsolete content
You can work around it by removing display:table in the style rule with the "#main" selector or adding clear:both to it. Why does move movement disappear when I use mouse events to click and drag? Since the dragging action is involved, you might need to disable it. Try using event.preventDefault() What is the purpose of the NS_LossyConvertUCS2toASCII() ...
Style System Overview - Archive of obsolete content
tter, by searching the rule tree (only one rule this time) instead of rebuilding it. Lots of room for optimization here. (but beware DidSetStyleContext) The style system Style sheets & rules ? Rule tree ? Style context interface Original Document Information Author(s): David Baron Last Updated Date: June 6, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Code snippets - Archive of obsolete content
esource://services-sync/main.js"); Components.utils.import("resource://services-sync/record.js"); let recordType = Weave.Engines.get(collection)._recordObj; let coll = new Collection(Weave.Service.storageURL + collection, recordType); coll.full = true; coll.recordHandler = function(item) { item.collection = collection; item.decrypt(); console.log(item.cleartext); }; coll.get(); Print an in
dividual record let collection = "history"; let id = "GUID_GOES_HERE"; Components.utils.import("resource://services-sync/main.js"); Components.utils.import("resource://services-sync/record.js"); let recordType = Weave.Engines.get(collection)._recordObj; let coll = new Collection(Weave.Service.storageURL + collection, recordType); coll.full = true; coll.ids = [id]; coll.recordHandler = function(item...
Gecko Coding Help Wanted - Archive of obsolete content
to do. roc is willing to work closely with anyone with reasonable C++ experience to get them started on this. Just send him mail. Not up for coding yet? Join the Gecko BugAThon and help save Gecko engineers from imminent doom! Original Document Information Author(s): fantasai Last Updated Date: May 4, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Helper Apps (and a bit of Save As) - Archive of obsolete content
er support for mailcap syntax. Possible KDE integration. Possibly reflecting the OS settings in our helper app preferences (readonly? writable?). Have a way for users to override things in the "not overridable" built-in list. Original Document Information Author(s): Boris Zbarsky Last Updated Date: September 12, 2002 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Introducing the Audio API extension - Archive of obsolete content
nds The framebuffer contains an array of audio samples. It's important to note that the samples are not separated by channels; they are all delivered together. For example, for a two-channel signal: Channel1-Sample1 Channel2-Sample1 Channel1-Sample2 Channel2-Sample2 Channel1-Sample3 Channel2-Sample3. ...
Makefile.mozextension.2 - Archive of obsolete content
NOOP = $(SHELL) -c true NOECHO = @ RM_RF=rm -f CP=/bin/cp -i .PHONY: all all :: make_structure make_files $(NOECHO) $(NOOP) package:: make_xpi $(NOECHO) $(NOOP) #install :: make_xpi make_install # $(NOECHO) $(NOOP) clean :: make_clean $(NOECHO) $(NOOP) make_structure: @$(MKDIR) $(PROJECT) || { echo "creating directory failed; it probably exists. ...
Monitoring downloads - Archive of obsolete content
search result is fetched and inserted into the appropriate list cell. The interesting bits to take away from this: mozIStorageStatement has several data getter routines for fetching search results, including getString(), getDouble(), and getInt64(). These methods take as a parameter the zero-based index number of the column whose value you wish to retrieve. Note that the start time is being
divided by 1000 before we create a JavaScript Date object from it. That's to adjust the value from the granularity stored in the database to that expected by JavaScript. To right-justify the numeric columns, we set the appropriate cells' style attribute to text-align:right. Exercises for the reader There are some obvious things that could be done to improve this extension. If you're learning to u...
Mozilla Application Framework in Detail - Archive of obsolete content
org has accelerated Internet software development and increased the quality of the final product, delivering unmatched support for web standards. In addition, independent software developers and corporate Information Technology departments now have complete access to the modular source code and freedom to freely license the source, make changes and build customized versions to accommodate their in
dividual needs. Free: Gecko is free of charge. There is no charge for using the Gecko browser engine or Gecko Technologies, including distributing Gecko inside another product. Furthermore, when embedding Gecko, developers are free to choose what modules to include. There is no requirement for distribution of any other software. The Necko Network Library Mozilla's Network library (aka Necko) provid...
Mozilla Crypto FAQ - Archive of obsolete content
tion of cryptography in various countries around the world, including the U.S. See the EPIC bookstore for more recommendations of books discussing privacy in general and public policies related to privacy issues. Original Document Information Author(s): Frank Hecker Last Updated Date: September 10, 2000 (Version 2.11) Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
FAQ - Archive of obsolete content
sktop environment. It lets users start web applications from their desktop, start menu, and dock, and it opens those applications in their own window separate from a web browser and without the browser interface (back and forward buttons, location bar, etc.). Is Prism a Mozilla product? No, Prism is not a Mozilla product. It is one of the experiments being conducted by Mozilla Labs to bridge the
divide in the user experience between web applications and desktop apps. Prism is the codename for the project, and if the functionality provided by Prism becomes a product or is integrated into other products (like Firefox), then it won't necessarily continue to be called by this codename. Is Prism a platform? No, Prism is not a platform. Prism is built on top of the Mozilla platform and its Gecko ...
New Skin Notes - Archive of obsolete content
4:52, 25 Aug 2005 (PDT) The clear/boths aren't in the content, they're embedded style information in the .php files in the /includes directory. It's just sloppy coding. I cannot think of any reason for writers or editors to add "clear:both" brs to their document. Under what situations does this seem like something that should be embedded directly into the wiki content? --dria When using floated
divs - images and such. If you don't use it they overlap with headings, which is something we seldom want. See for example the venkman tutorials (although the clears are down the page) or MDC:Frequently Asked Questions. I'm not saying this can't be worked around, just that it would be better if the skin coped with that fine. --Nickolay 05:46, 25 Aug 2005 (PDT) Ok, I'll see what I can do. Thanks for ...
Standalone XPCOM - Archive of obsolete content
into standalone XPCOM like registry, xpconnect. Tweeking these options will cause reduction in memory requirements and size. Get xpcom/tests directory upto date and documented. Update this document for Mac. API freeze and documentation Original Document Information Author: Suresh Duddi Last Updated Date: 15 May 2000 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Table Cellmap - Archive of obsolete content
::GetDataAt outside nsCellMap.cpp The border collapse code relies on the cellmap. The collapsing of rows and columns uses the cellmap. and finally the line iterator methods which are used for arrow navigation through a table. Original Document Information Author(s): Bernd Mielke Last Updated Date: September 27, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Table Layout Regression Tests - Archive of obsolete content
me dump taking into account the printer pages. Please contact if you need help with running those tests. I would like to thank Chris Karnaze for his guidance and fantasai for her language support. Original Document Information Author(s): Bernd Mielke Other Contributors: Boris Zbarsky Last Updated Date: February 5, 2007 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Table Layout Strategy - Archive of obsolete content
oo</td><td>bar</td></tr> </tbody> </table> The algorithm tries to satisfy the requirements on a first come first serve base. The second table has <col width="40%"><col>. IE and Opera handle this pretty much the same as mozilla. Original Document Information Author(s): Bernd Mielke Last Updated Date: September 27, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
The life of an HTML HTTP request - Archive of obsolete content
g context to do the drawing on. The rendering context implementation is a native class (nsGtkRenderingContext on unix) that knows how to draw in a window. TODO: Views, ViewManager, EventStateManager? Diagram created with DIA. Original Document Information Author(s): Alexander Larsson Last Updated Date: October 8, 1999 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Venkman - Archive of obsolete content
w directives mentioned at Venkman FAQ section 5.4 and then you may report a bug on JavaScript Debugger component. Related Topics JavaScript, Web Development, Developing Mozilla Original Document Information Author(s): Robert Ginda Other contributors: Doctor Unclear Last Updated Date: July 13, 2007 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Binding Attachment and Detachment - Archive of obsolete content
Attachment using CSS Bindings can be attached to elements through CSS using the -moz-binding property. -moz-binding Value: none | [,]* <uri> | inherit Initial Value: none Applies to: all elements (not generated content or pseudo-elements) Inherited: no Percentages: N/A The value of the -moz-binding property is a set of URLs that identify specific bindings. An in
dividual URL in the set consists of the binding document's URL and the binding's document-unique identifier. In the following example, a binding is referenced that will be attached to all HTML checkbox elements. input[type="checkbox"] { -moz-binding: url("http://www.mozilla.org/xbl/htmlBindings.xml#checkbox"); } Bindings attached through CSS will only remain on the bound element as long as the element continues to...
Example Sticky Notes - Archive of obsolete content
="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { background-color: #FFFFFF; color: #000000; font: 1em Verdana, sans-serif; } h1 { font-size: 1.5em; } /* Binding: */ .sticker { -moz-binding: url(notes.xml#default); } </style> </head> <body> <h1><a href="http://developer.mozilla.org/en/docs/XBL:XBL_1.0_Reference">XBL</a> Demo : Sticky Notes</h1> <
div class="sticker"><p>ACME, Inc. fax - respond today.</p></
div> <
div class="sticker"><p>Don't forget the eggs!</p></
div> <
div class="sticker"><p>The new project - who's on charge?</p></
div> <
div class="sticker"><p>Learn more about XBL.</p></
div> <p style="clear: left"><a href="http://validator.w3.org/check?uri=referer"><img src="https://udn.realityripple.com/samples/e2/dd625ef1cd.png" ...
flex - Archive of obsolete content
hildren. Flexible elements grow and shrink to fit their given space. Elements with larger flex values will be made larger than elements with lower flex values, at the ratio determined by the two elements. The actual value is not relevant unless there are other flexible elements within the same container. Once the default sizes of elements in a box are calculated, the remaining space in the box is
divided among the flexible elements, according to their flex ratios. Specifying a flex value of 0 has the same effect as leaving the flex attribute out entirely. ...
seltype - Archive of obsolete content
<< XUL Reference home seltype Type: one of the values below Used to indicate whether multiple selection is allowed. single Only one row may be selected at a time. (Default in listbox and richlistbox.) multiple Multiple rows may be selected at once. (Default in tree.) For trees, you can also use the following values: cell In
dividual cells can be selected text Rows are selected; however, the selection highlight appears only over the text of the primary column. For richlistbox, this is new in Firefox 3.5. ...
spellcheck - Archive of obsolete content
ell checking is enabled by default for the text box; if false, spell checking is disabled by default. If not specified, this defaults to false The HTML The spellcheck attribute uses values of true or false (you cannot simply add the spellcheck attribute to a given element): <!-- spellcheck everything! --> <input type="text" spellcheck="true" /><br /> <textarea spellcheck="true"></textarea> <
div contenteditable="true" spellcheck="true">I am some content</
div> <!-- spellcheck nothing! --> <input type="text" spellcheck="false" /><br /> <textarea spellcheck="false"></textarea> <
div contenteditable="true" spellcheck="false">I am some content</
div> You can use spellcheck on INPUT, TEXTAREA, and contenteditable elements. Thespellcheck attribute works well paired with the autocomplete, autoc...
Working With Directories - Archive of obsolete content
5); This example checks if the directory exists and creates it if it does not. If the directory already exists, then no action is taken. In this case, the directory is the 'pictures' subdirectory within the 'myfiles' directory on the desktop. If either the 'myfiles' directory or the 'pictures' directory do not exist, they will be created. Thus, you do not have to create a series of directories in
dividually, the set will all be created if needed. Naturally, if the 'myfiles' directory already exists, it won't be recreated. Iterating over the Files in a Directory The directory object's directoryEntries (nsIFile.Attributes) attribute is used to get a list of the items in a directory. It returns an enumeration which can be iterated over. function getLatestFile() { var lastmod = 0; var homedir...
MenuItems - Archive of obsolete content
Checkbox menu items Sometimes, you will want to have an item on a menu that acts as a toggle. For instance, a menuitem that can be used to toggle a toolbar on and off. To indicate the current state of the toolbar, a checkbox would be displayed next to the menu item label. If the checkbox is on, the toolbar i...
Menus - Archive of obsolete content
ficult for the user to use, so you should avoid adding too many levels of submenus. Sharing Menus Between Windows If you wish to have several windows that share the same menu bar, a common technique is to place the menubar in an overlay and apply it to all of the windows. This allows the menu bar to be shared between each window without having to duplicate code. This technique may be used for in
dividual menus or for an entire menu bar. For example, to have a Tools menu that is shared between all windows, just create a menu in the overlay, and include it in each window with a single line: <menu id="menu-tools"/> The overlay should have a menu with the same id 'menu-tools' containing the complete definition of the menu. If you wish to have slight differences between each window, one possi...
Tooltips - Archive of obsolete content
label is then set as the value of the last child of the tooltip. In the earlier example, the last child of the tooltip is a label. The effect is that the value of the label within the tooltip will change based on the element that the mouse is moved over. Tooltips in Trees As the entire body of the tree is displayed using a single element, the tooltip and tooltiptext attributes do not apply to in
dividual rows or cells of a tree. However, the tree will automatically display tooltips for a cell when the value is cropped. For instance, if a cell has a long label and the column is shorter than the label's length, a tooltip will appear when the mouse is moved over the cell so that the user can see the entire value. ...
Building Hierarchical Trees - Archive of obsolete content
he tree. <rdf:Bag rdf:about="http://www.xulplanet.com/rdf/myneighbourhood"> <rdf:li> <rdf:Seq rdf:about="http://www.xulplanet.com/rdf/marion" dc:title="Marion Street"> The result is a two level tree with two columns. For an XML source, a container is a node in the XML document that has children. In this example, the two group elements are displayed at the first level. The in
dividual people are displayed at the next level of the tree as the builder recurses. In this example, we only need to use one rule. <tree datasources="people2.xml" ref="*" querytype="xml" rows="10" flags="dont-build-content"> <treecols> <treecol id="name" primary="true" label="Name" flex="1"/> </treecols> <template> <query expr="*"/> <action> <treechildren> <tre...
Filtering - Archive of obsolete content
The query statements will need to iterate over the arcs pointing into the type resource. Since we want the arcs pointing into the type, we need to determine the source or subject of a triple. Look at the resulting RDF triples above again if this is unclear. The starting node is 'http://www.daml.org/2001/09/countries/country-ont#Country'. We need to iterate over the 'type' predicate to find the in
dividual countries. A second triple is used to get the title for the country. <query> <content uri="?start"/> <triple subject="?country" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="?start"/> <triple subject="?country" predicate="http://purl.org/dc/elements/1.1/title" object="?countrytitle"/> </query> The action body will need to ...
Template Builder Interface - Archive of obsolete content
element applies both when an element is created when the window is loaded and when an element is inserted dynamically. Templates can only be used in XUL documents, however, there is no requirement that the templates generate XUL elements. They could also be used, for example, to generate HTML elements. This isn't a very common technique, however, here is an example of how this can be used: <html:
div id="photosList" datasources="template-guide-photos5.rdf" ref="http://www.xulplanet.com/rdf/myphotos" xmlns:html="http://www.w3.org/1999/xhtml"> <html:h1>My Photos</html:h1> <template> <html:p uri="rdf:*"><textnode value="rdf:http://purl.org/dc/elements/1.1/title"/></html:p> </template> </html:
div> This example generates three paragraphs. Some static content before th...
Adding Properties to XBL-defined Elements - Archive of obsolete content
are three types of items you can add. Fields are used to hold a simple value. Properties can also be used to hold a value but may have code execute when an attempt is made to retrieve or modify the value. Methods are functions which may be executed. All three are defined within an implementation element, which should be a child of the binding element. Within the implementation, you define in
dividual field, property, and method elements, one for each one that you want. The general syntax is as follows: <binding id="element-name"> <content> -- content goes here -- </content> <implementation> <field name="field-name-1"/> <field name="field-name-2"/> <field name="field-name-3"/> <property name="property-name-1"/> <property name="property-name-2"/> <propert...
Box Objects - Archive of obsolete content
<< PreviousNext >> This section describes the box object, which holds display and layout related information about a XUL box as well as some details about XUL layout. About Mozilla Layout Mozilla
divides things into two sets of trees, the content tree and the layout tree. The content tree stores the nodes as they are found in the source code. The layout tree holds a different tree of nodes for each in
dividual component that can be displayed. The layout tree holds the structure as the nodes are expected to be displayed There is not necessarily a one to one relationship between content and layout nodes. Some content nodes may have several layout objects, for example, each line of a paragraph has a separate layout object. Conversely, some content nodes have no layout objects at al...
Creating a Skin - Archive of obsolete content
Some of the rules conflict with those already in the global stylesheets. For example, rules are already defined for buttons and tabs and so on and we defined additional rules for them. When changing the global skin, you would need to merge the changes into the existing rules. For the best skinnability, it is best to declare appearance related style rules in the global directory rather than in in
dividual style files. This includes colors, fonts and general widget appearances. If you change the color of something in a local skin file (such as findfile.css), the dialog may look odd if the user changes their global skin. Don't expect the user to be using the default one. Our Find files example with this skin: Source View Stylesheet See also Mozilla CSS extensions CSS reference The nex...
Grids - Archive of obsolete content
first. Declaring a grid To declare a set of rows, use the rows tag, which should be a child element of grid. Inside that you should add row elements, which are used for each row. Inside the row element, you should place the content that you want inside that row. Similarly, the columns are declared with the columns element, which should be placed as a child element of the grid. Inside that go in
dividual column elements, one for each column you want in the grid. This should be easier to understand with an example. Example 1 : Source View <grid flex="1"> <columns> <column flex="2"/> <column flex="1"/> </columns> <rows> <row> <button label="Rabbit"/> <button label="Elephant"/> </row> <row> <button label="Koala"/> <button label="Gorilla"/...
Keyboard Shortcuts - Archive of obsolete content
VK_J VK_K VK_L VK_M VK_N VK_O VK_P VK_Q VK_R VK_S VK_T VK_U VK_V VK_W VK_X VK_Y VK_Z VK_NUMPAD0 VK_NUMPAD1 VK_NUMPAD2 VK_NUMPAD3 VK_NUMPAD4 VK_NUMPAD5 VK_NUMPAD6 VK_NUMPAD7 VK_NUMPAD8 VK_NUMPAD9 VK_MULTIPLY VK_ADD VK_SEPARATOR VK_SUBTRACT VK_DECIMAL VK_
DIVIDE VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8 VK_F9 VK_F10 VK_F11 VK_F12 VK_F13 VK_F14 VK_F15 VK_F16 VK_F17 VK_F18 VK_F19 VK_F20 VK_F21 VK_F22 VK_F23 VK_F24 VK_NUM_LOCK VK_SCROLL_LOCK VK_COMMA VK_PERIOD VK_SLASH VK_BACK_QUOTE VK_OPEN_BRACKET VK_BACK_...
List Controls - Archive of obsolete content
s purpose. It is made from a textbox with a button beside it. Its name was chosen because it pops up a menu with the choices in it. Three elements are needed to describe a drop-down box. The first is the menulist element, which creates the textbox with the button beside it. The second, menupopup, creates the popup window which appears when the button is clicked. The third, menuitem, creates the in
dividual choices. Its syntax is best described with the example below: Example 5 : Source View <menulist label="Bus"> <menupopup> <menuitem label="Car" /> <menuitem label="Taxi" /> <menuitem label="Bus" selected="true" /> <menuitem label="Train" /> </menupopup> </menulist> This menulist will contain four choices, one for each menuitem element. To show the choices, click the a...
Simple Menu Bars - Archive of obsolete content
h are explained briefly here and in detail afterwards: menubar The container for the row of menus. menu Despite the name, this is actually only the title of the menu on the menubar. This element can be placed on a menubar or can be placed separately. menupopup The popup box that appears when you click on the menu title. This box contains the list of menu commands. menuitem An in
dividual command on a menu. This would be placed in a menupopup. menuseparator A separator bar on a menu. This would be placed in a menupopup. You can customize the menus on the menubar to have whatever you want on them on all platforms except the Macintosh. This is because the Macintosh has its own special menu along the top of the screen controlled by the system. Although you can create cus...
Toolbars - Archive of obsolete content
s, which are described here. toolbox A box that contains toolbars. toolbar A single toolbar that contains toolbar items such as buttons. toolbarbutton A button on a toolbar, which has all the same features of a regular button but is usually drawn differently. The toolbar is the main element that creates the actual toolbar. Inside it are placed the in
dividual toolbar items, usually buttons, but they can be other elements. In the example above, only one toolbar was created. Multiple toolbars can be created just as easily by adding more toolbar elements after the first one. The toolbox is a container for toolbars. In some applications, you will have several toolbars along the top of the window. You can put them all inside a toolbox. You do not have...
Tree Box Objects - Archive of obsolete content
he number of rows in a page. In the scrolling example above, getPageLength() would return four. Note that in Firefox 1.0 and Mozilla 1.7 and earlier, the getPageLength() function is called getPageCount() instead. The name was changed to getPageLength() since it was confusing before since it doesn't return the number of pages, but the size of each page. You could determine the number of pages by
dividing the total number of rows by the page length. The ensureRowIsVisible() function will scroll to a row just as scrollToRow() does, but does not scroll if the row is already visible. Cell Coordinates Some of the most interesting functions of the tree box object are several functions which may be used to get the parts of the tree at specific coordinates and vice versa. The getCellAt() func...
Tree Selection - Archive of obsolete content
If you add the seltype attribute to the tree, set to the value single, the user may only select one row at a time. Otherwise, the user may select multiple rows, which will not necessarily be contiguous. The tree provides a number of functions which can be used to determine whether an item is selected. ...
Tree View Details - Archive of obsolete content
ildren. The 'init' function is called when the window is loaded to initialize the tree. It simply sets the custom view by retrieving the tree and setting its 'view' property. We will define 'treeView' next. function init() { document.getElementById("elementList").view = treeView; } The custom tree view will need to implement a number of methods, of which the important ones will be examined in
dividually. First we'll define two structures to hold the data for the tree, the first will hold a map between parents and the children they contain, and the second will hold an array of the visible items. Remember that a custom view must keep track of which items are visible itself. var treeView = { childData : { Solids: ["Silver", "Gold", "Lead"], Liquids: ["Mercury"], Gases: ["Heliu...
XUL element attributes - Archive of obsolete content
hildren. Flexible elements grow and shrink to fit their given space. Elements with larger flex values will be made larger than elements with lower flex values, at the ratio determined by the two elements. The actual value is not relevant unless there are other flexible elements within the same container. Once the default sizes of elements in a box are calculated, the remaining space in the box is
divided among the flexible elements, according to their flex ratios. Specifying a flex value of 0 has the same effect as leaving the flex attribute out entirely. height Type: string (representing an integer) The preferred height of the element in pixels. The actual displayed height may be different if the element or its contents have a minimum or maximum height. The CSS height property may a...
XUL accessibility guidelines - Archive of obsolete content
aware that no tool can replace human judgement for accessibility, and understanding the guidelines is vital. Learn More Accessibility Platform Features Mozilla Community Software Accessibility - Where Are We Today? Intro to accessibility, assistive technologies, and Mozilla resources. Introduction to Web Accessibility. Overview of web accessibility from WebAIM.
Dive Into Accessibility. Downloadable book on web accessibility with tips and character sketches. Assistive technology compatibility. List of popular assistive technologies and their respective compatibility levels with XUL. #accessibility. Accessibility channel for general discussion around Internet accessibility with logger. Useful at conferences. Apple Accessibility. Portal to Apple ac...
XUL controls - Archive of obsolete content
<image src="angry.png"/> </richlistitem> </richlistbox> Richlistbox Reference Related Elements: richlistitem <scale> A scale displays a bar with a thumb that may be slid across the bar to select between a range of values. <scale min="1" max="10"/> Scale Reference <splitter> Allows the user to adjust the
division of space between elements. <splitter collapse="before"> <grippy/> </splitter> Splitter Reference Related Elements: grippy <tab> Description goes here. <tab label="firefox"/> Tab Reference Related Elements: tabs tabbox tabpanels <textbox> A textbox which allows a single line of text to be ent...
columns - Archive of obsolete content
The columns element may be nested inside another columns element. Other elements placed inside a columns element occupy the full height of the grid and are placed in their corresponding positions between the columns. More information about columns is available in the XUL tutorial. Example See grid for an example. ...
listbox - Archive of obsolete content
ual number of rows in the element, use the getRowCount method. seltype Type: one of the values below Used to indicate whether multiple selection is allowed. single Only one row may be selected at a time. (Default in listbox and richlistbox.) multiple Multiple rows may be selected at once. (Default in tree.) For trees, you can also use the following values: cell In
dividual cells can be selected text Rows are selected; however, the selection highlight appears only over the text of the primary column. For richlistbox, this is new in Firefox 3.5. suppressonselect Type: boolean If this attribute is not specified, a select event is fired whenever an item is selected, either by the user or by calling one of the select methods. If set to true, the ...
richlistbox - Archive of obsolete content
information is available in the Preferences System article. seltype Type: one of the values below Used to indicate whether multiple selection is allowed. single Only one row may be selected at a time. (Default in listbox and richlistbox.) multiple Multiple rows may be selected at once. (Default in tree.) For trees, you can also use the following values: cell In
dividual cells can be selected text Rows are selected; however, the selection highlight appears only over the text of the primary column. For richlistbox, this is new in Firefox 3.5. suppressonselect Type: boolean If this attribute is not specified, a select event is fired whenever an item is selected, either by the user or by calling one of the select methods. If set to true, the...
richlistitem - Archive of obsolete content
Attributes disabled, searchlabel, selected, tabindex, value Properties accessible, control, disabled, label, selected, tabIndex, value Examples (example needed) Attributes disabled Type: boolean Indicates whether the element is disabled or not. If this attribute is set, the element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire. In the case of form elements, it will not be submitted. ...
rows - Archive of obsolete content
Each child of a rows element should be a row element. The rows element may be nested inside another rows element. The children of these nested rows are counted as normal rows as if they were part of the parent. However, nesting rows elements allows groups of rows to have a separate appearance such as a different border, or separate scrolling may be defined for these rows. ...
<statusbarpanel> - Archive of obsolete content
This is a special type of button which is drawn differently. Unlike normal buttons, a statusbarpanel can only have a label or an image but not both. This element is often used with a short label or icon to indicate status, for instance whether the user is online or whether there are new messages. ...
textbox - Archive of obsolete content
ell checking is enabled by default for the text box; if false, spell checking is disabled by default. If not specified, this defaults to false The HTML The spellcheck attribute uses values of true or false (you cannot simply add the spellcheck attribute to a given element): <!-- spellcheck everything! --> <input type="text" spellcheck="true" /><br /> <textarea spellcheck="true"></textarea> <
div contenteditable="true" spellcheck="true">I am some content</
div> <!-- spellcheck nothing! --> <input type="text" spellcheck="false" /><br /> <textarea spellcheck="false"></textarea> <
div contenteditable="true" spellcheck="false">I am some content</
div> You can use spellcheck on INPUT, TEXTAREA, and contenteditable elements. Thespellcheck attribute works well paired with the autocomplete, autoc...
tree - Archive of obsolete content
ual number of rows in the element, use the getRowCount method. seltype Type: one of the values below Used to indicate whether multiple selection is allowed. single Only one row may be selected at a time. (Default in listbox and richlistbox.) multiple Multiple rows may be selected at once. (Default in tree.) For trees, you can also use the following values: cell In
dividual cells can be selected text Rows are selected; however, the selection highlight appears only over the text of the primary column. For richlistbox, this is new in Firefox 3.5. statedatasource Type: URI Chrome XUL may specify an RDF datasource to use to store tree state information. This is used to hold which tree items are open and which items are collapsed. This information...
treecell - Archive of obsolete content
nce home [ Examples | Attributes | Properties | Methods | Related ] A single cell in a tree. This element should be placed inside a treerow. You can set the text for the cell using the label attribute. More information is available in the XUL tutorial. Attributes editable, label, mode, properties, ref, src, value Attributes editable Type: boolean Allows the contents of in
dividual cells in the column to be changed, especially useful when <treecol type="checkbox">. Also useful for disabling editing of in
dividual treecells. When the user double-clicks an editable cell, a text field appears in which the user can edit the contents of the cell. The tree and treecol must also be marked as editable in order for this to work. The tree must be a content tree for this to wo...
treecol - Archive of obsolete content
gged. This attribute is set automatically; you shouldn't adjust it yourself. editable Type: boolean Allows the contents of cells in the column to be changed, especially useful when type="checkbox". When the user double-clicks an editable cell, a text field appears in which the user can edit the contents of the cell. The tree must also be marked as editable in order for this to work. In
dividual treecell elements in the column may be marked editable="false" in order to disable editing. fixed Type: boolean If true, the size of the column in the tree cannot be adjusted by the user. Any splitter to either side will resize those columns while keeping the fixed column at a constant size. If false or not specified, the user can adjust the size of the column, typically by dragging ...
wizard - Archive of obsolete content
property returns the number of pages that the user has navigated through so far, meaning that the user would press the Back button this many times to go back to the beginning. This property is different than pageIndex, because pages are not necessarily navigated in order. title Type: string The title that appears at the top of the wizard. This is overridden by the label attribute on the in
dividual pages. wizardPages Type: DOM NodeList of wizardpage elements This property holds the list of wizardpage elements in the wizard. Methods Inherited Methods addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBound...
Mozprofile - Archive of obsolete content
n mozprofile from the command line enter: mozprofile --help for a list of options. API Usage To use mozprofile as an API you can import mozprofile.profile and/or the AddonManager. mozprofile.profile features a generic Profile class. In addition, subclasses FirefoxProfile and ThundebirdProfile are available with preset preferences for those applications. Installing Addons Addons may be installed in
dividually or from a manifest. Example: from mozprofile import FirefoxProfile # create new profile to pass to mozmill/mozrunner profile = FirefoxProfile(addons=["adblock.xpi"]) Setting Preferences Preferences can be set in several ways: using the API: You can pass preferences in to the Profile class's constructor: obj = FirefoxProfile(preferences=[("accessibility.typeaheadfind.flashBar", 0)]) us...
Extentsions FAQ - Archive of obsolete content
bserverService notification is sent out. The problem is, while your extension is still active, user can cancel uninstallation, and when it is physically uninstalled, your code can't run. Right. And if you uninstall Firefox, the profile data is left behind. It would be nice to give the option of clearing extension's data, but it should be implemented at application level, not by each extension in
dividually. It might be an option to stick with it and perform stuff when it comes to application shutdown. The Sanitize stuff does this (clean stuff on exit). http://lxr.mozilla.org/mozilla1.8/so...ents/nsBrowser... Firefox will clean all those preferences which are still "default", that is not changed by the user or the application/extension. To provide those default preferences to your exte...
2006-11-03 - Archive of obsolete content
BRANCH) off of the trunk. Discussions HTML5 @ W3C Discussion of the official announcement from W3C on the development of HTML5 and how MathML should be included in it. Firefox Table Captions Discussion on how IE displays captions depending on the size of the content while FF uses a default setting. Captions in FF also exceed the table length and become hidden if it's surrounded by a bounding
div element. A test case is pending. Perf Question (reflow branch) A look into bug #352367 and the mention of possibly reducing the number of times nsFrame::IntrinsicWidthOffsets is called for each cell within a table. Meetings None this week. ...
NPN_RequestRead - Archive of obsolete content
These requests result in subsequent calls to NPP_WriteReady() and NPP_Write(). For multiple requests, the function creates a linked list of NPByteRange structures, each of which represents a separate request. If the plug-in requests multiple ranges (either through a list of NPByteRange objects in a single call to NPN_RequestRead(), or multiple calls to NPN_RequestRead()), the browser can write in
dividual ranges in any order, and with any number of NPP_WriteReady() and NPP_Write() calls. The plug-in must allocate NPByteRange objects, which the browser copies if necessary. The plug-in can free these as soon as the call returns. Seekable streams are created by calling NPP_NewStream() with NP_SEEK as the stype mode. The plug-in can call NPN_RequestRead() on streams that were not initially in N...
The First Install Problem - Archive of obsolete content
Example: [HKEY_LOCAL_MACHINE\Software\MozillaPlugins\@mycompany.com/MyApplication,version=5.01] ProductName=MyApplication Player 5 "Version" -- This is the versioning scheme of the above Product. Example: [HKEY_LOCAL_MACHINE\Software\MozillaPlugins\@mycompany.com/MyApplication,version=5.01] Version=5.01 MimeTypes -- This is a subkey and contains in
dividual mimetypes as further subkeys. HKEY_LOCAL_MACHINE\Software\MozillaPlugins\@mycompany.com/MyApplication,version=5.01/MimeTypes/someMimeTypeSubkey/ The MimeTypes subkey contains further subkeys based on an application's actual mimetypes. Examples: [HKEY_LOCAL_MACHINE\Software\MozillaPlugins\@mycompany.com/MyApplication,version=5.01\MimeTypes\ap...
Using Firebug and jQuery (Screencast) - Archive of obsolete content
so. You can use the ability to quickly analyze and inspect a page that Firebug and jQuery affords you, using the results to build a Greasemonkey script, instead of a simple bookmarklet. I only really intended this to be a quick introduction to the subject, so please feel free to explore it more! More Tips: Here are some more jQuery selectors that you can use on a Digg Post: $("li.c-bury >
div").remove(); - Remove all buried comments, but none of the direct replies. $("
div.c-body").show(); - Show all comments, even ones that've been buried. ...
Developing cross-browser and cross-platform pages - Archive of obsolete content
e a basic, simple object support detection example. function hideElement(id_attribute_value) { if (document.getElementById && document.getElementById(id_attribute_value) && document.getElementById(id_attribute_value).style ) { document.getElementById(id_attribute_value).style.visibility = "hidden"; }; } // example: // <button type="button" onclick="hideElement('d1');">hide
div</button> // <
div id="d1">Some text</
div> These repeated calls to document.getElementById are not the most efficient way to check for the existence of particular objects or features in the browser's DOM implementation, but they serve to illustrate clearly how object support detection works. The top-level if clause looks to see if there is support for a method called getElementById on the documen...
Summary of Changes - Archive of obsolete content
r align="center" CSS1 text-align: center; for in-line elements like text or image deprecated CENTER or align="center" CSS1 margin-left: auto; margin-right: auto; for block-level elements deprecated bgcolor CSS1 background-color: ; non-standard EMBED HTML 4.01 OBJECT deprecated APPLET HTML 4.01 OBJECT non-standard MARQUEE HTML 4.01
DIV plus scripting non-standard BGSOUND HTML 4.01 OBJECT Proprietary or Deprecated Feature W3C Feature or Recommended Replacement IE5+ id_attribute_value document.all.id_attribute_value document.all[id_attribute_value] DOM level 2: document.getElementById(id_attribute_value) IE5+ FormName.InputName.value DOM level 1: document.forms[...
Using the W3C DOM - Archive of obsolete content
need to use MSIE-specific attributes and methods. Accessing Elements with the W3C DOM The basic method for referencing elements in an HTML page is document.getElementById(). All modern browsers support it. The method returns a reference to the uniquely identified element, which can then be used to script the element. For example, the following short sample dynamically sets the left margin of a <
div> element with an id of "inset" to half an inch: // in the HTML: <
div id="inset">Sample Text</
div> document.getElementById("inset").style.marginLeft = ".5in"; Note: Internet Explorer 5 through 7 have a flawed implementation of getElementById(), which returns the first element with a matching NAME or ID (Id versus name when using getElementById, MSDN: getElementById Method). IE-specifi...
-ms-content-zoom-snap-points - Archive of obsolete content
iscrete Syntax Values snapInterval( <percentage>, <percentage> ) Specifies where the snap-points will be placed. The first percentage specifies where the first snap-point will be placed. The second percentage specifies the distance between subsequent snap-points, both zoomed in and zoomed out from the initial snap-point. snapList( <percentage># ) Specifies the position of in
dividual snap-points as a comma-separated list of percentages, each of which represents a zoom factor. If any value specified is less than that specified by the -ms-content-zoom-limit-min property, the value of -ms-content-zoom-limit-min is used. If any value specified is greater than that specified by the -ms-content-zoom-limit-max property, the value of -ms-content-zoom-limit-max is used. ...
-ms-scroll-snap-points-x - Archive of obsolete content
ength-percentage>, <length-percentage> ) Specifies a starting snap-point followed by the interval between all snap-points. The first value specifies where the first snap-point will be placed. The second value specifies the distance between subsequent snap-points both to the left and the right of the initial snap-point. snapList( <length-percentage># ) Specifies the position of in
dividual snap-points as a comma-separated list of values, each of which represents a zoom factor. If any value is less than -ms-scroll-limit-x-min , then -ms-scroll-limit-x-min is used. If any value is greater than -ms-scroll-limit-x-max, then -ms-scroll-limit-x-max is used. Formal syntax snapInterval( <length-percentage>, <length-percentage> ) | snapList( <length-percentage># )where ...
-ms-scroll-snap-points-y - Archive of obsolete content
pInterval( <length-percentage>, <length-percentage> ) Specifies a starting snap-point followed by the interval between all snap-points. The first value specifies where the first snap-point will be placed. The second value specifies the distance between subsequent snap-points both above and below the initial snap-point. snapList( <length-percentage># ) Specifies the position of in
dividual snap-points as a comma-separated list of values, each of which represents a zoom factor. If any value is less than -ms-scroll-limit-y-min , then -ms-scroll-limit-y-min is used. If any value is greater than -ms-scroll-limit-y-max, then -ms-scroll-limit-y-max is used. Formal syntax snapInterval( <length-percentage>, <length-percentage> ) | snapList( <length-percentage># )where ...
RDF in Mozilla FAQ - Archive of obsolete content
ged. How do I merge two or more datasources to view them as one? Use nsIRDFCompositeDataSource. This interface is derived from nsIRDFDataSource. An implementation of this interface will typically combine the statements from several datasources together as a collective. Because the nsIRDFCompositeDataSource interface is derived from nsIRDFDataSource, it can be queried and modified just like an in
dividual data source. How do I access "built-in" datasources? A built-in datasource is a locally-installed component that implements nsIRDFDataSource. For example, the bookmarks service. First, check here to make sure you will be allowed to access a built-in datasource. There are several security restrictions on accessing built-in datasources from "untrusted" XUL and JS. Since a built-in datasourc...
The Business Benefits of Web Standards - Archive of obsolete content
Caught between a rock and a hard place, web designers face a formidable challenge. Yet they are finding an unsuspected ally in the battle: Web Standards. This article discusses how adhering to web standards, and leaving behind proprietary markup and technologies, can contribute to a company's business goals. ...
Index - Game development
inner, Canvas, Games, JavaScript, Tutorial, scoring, winning Destroying the bricks is really cool, but to be even more awesome the game could award points for every brick a user hits, and keep count of the total score. 70 2D maze game with device orientation Canvas, Device Orientation API, Game Development, HTML5, Phaser, Vibration API I hope this tutorial will help you
dive into 2D game development and inspire you to create awesome games on your own. You can play the demo game Cyber Orb and check out its source code on GitHub. 71 Touch Event Horizon NeedsContent, NeedsExample This tutorial shows how to use Touch Events to create a game on a <canvas>. This is a multi-player game relying on the Tap and Drag gestures. 72 Visual JS GE ...
Introduction to game development for the Web - Game development
Let's look at how the Web can help you. The reach of the Web is enormous; it's everywhere. Games built with HTML5 work on smartphones, tablets, PCs and Smart TVs. Marketing and discoverability are improved. You're not limited to promoting your app on someone else's app store. I...
Game distribution - Game development
evices so that's something you will have to focus on if you truly want to succeed. Mobile devices are where HTML5 technology can truly shine and show its advantages. There's no Flash, and HTML5 is fully multiplatform. Trying to compete with desktop games directly is very difficult. You can put your HTML5 games into the same arena (see Native desktop, later on) and you should because it's good to
diversify the platforms you support, but you have to remember that developers creating desktop games have years of experience, great tools and stable distribution channels. Many HTML5 games will target different market segments than native desktop games, e.g. simple time killer games to be played while on the move rather than huge immersive experiences. Such games are often designed to be played with...
Game monetization - Game development
s the examples it should be ok. Check out Tuts+ Game Development or similar websites for writing opportunities. Merchandise You can sell t-shirts, stickers or other gadgets -- some devs make more money from the merchandise than from the games themselves, but it only works on very popular and recognizable games like Angry Birds. Still, it could be another small stream of passive income. The more
diversified your earnings are, the better your business stability. Donations When all else fails you can try putting a donate button on your game's page and asking for support from the community. Sometimes it works, but only if the player knows you and feels that it will help you in your situation. That's why carefully managing your community is so important. It worked with the js13kGames competiti...
Explaining basic 3D theory - Game development
d can be a triangle, point or line. A Fragment: A 3D projection of a pixel, which has all the same attributes as a pixel. A Pixel: A point on the screen arranged in the 2D grid, which holds an RGBA color. Vertex and fragment processing are programmable -- you can write your own shaders that manipulate the output. Vertex processing Vertex processing is about combining the information about in
dividual vertices into primitives and setting their coordinates in the 3D space for the viewer to see. It's like taking a photo of the given scenery you have prepared -- you have to place the objects first, configure the camera, and then take the shot. There are four stages to this processing: the first one involves arranging the objects in the world, and is called model transformation. Then there...
Building up a basic demo with Babylon.js - Game development
It is then positioned to the right of the cube, rotated a bit so its 3D shape can be seen, and given a yellow material. Here's how the scene should look right now: This works, but it is a bit boring. In a game something is usually happening -- we can see animations and such -- so let's try to breathe a little life into those shapes by animating them. Animati...
3D games on the Web - Game development
e modern web using current, powerful hardware. Explaining the basic 3D theory The basics of 3D theory centers around shapes represented in a 3D space, with a coordinate system being used to calculate their positions. See our Explaining basic 3D theory article for all the information you need. Advanced concepts You can do a lot more with WebGL. There are some advanced concepts which you should
dive into and learn more about -- like shaders, collision detection, or the latest hot topic: virtual reality on the web. Shaders It's worth mentioning shaders, which are a separate story on their own. Shaders use GLSL, a special OpenGL shading language, with syntax similar to C, that is executed directly by the graphics pipeline. They can be split into vertex shaders and fragment shaders (or pixel...
Unconventional controls - Game development
there's also a gallery of working examples you can look at. To get the Leap Motion working on your computer you have to first install it by following the steps at leapmotion.com/setup. When everything is installed and the controller is connected to your computer we can proceed with implementing support in our little demo. First, we add a <script> tag with the url pointing at this file, and add <
div id="output"></
div> just before the closing </body> tag for outputting diagnostic information. We will need a few helper variables for our code to work -- one for the purpose of calculating the degrees from radians, two for holding the horizontal and vertical amount of degrees our hand is leaning above the controller, one for the threshold of that lean, and one for the state of our hand's grab st...
Implementing controls using the Gamepad API - Game development
int, or else you'll lose energy. The game encapsulates two totally different types of "change" -- good food vs. bad food, and mobile vs. desktop. Demo The full version of the Hungry Fridge game was built first, and then to showcase the Gamepad API in action and show the JavaScript source code, a simple demo was created. It's part of the Gamepad API Content Kit available on GitHub where you can
dive deep into the code and study exactly how it works. The code explained below is from the full version of the Hungry Fridge game, but it's almost identical to the one from the demo -- the only difference is that the full version uses the turbo variable to decide whether or not the game will be launched using Super Turbo mode. It works independently, so it could be turned on even if the gamepad is...
Efficient animation for web games - Game development
itise framerate during player movement and combat, but may prioritise image quality or physics detail when compromise to framerate and input response would be less noticeable. Measure performance There are some popular animation-related libraries and UI toolkits with animation functions that still do things like using setTimeout to drive their animations, drive all their animations completely in
dividually, or other similar things that aren't conducive to maintaining a high frame-rate. One of the goals for the Puzzowl game is for it to be a solid 60fps on reasonable hardware (for the record, it's almost there on Galaxy Nexus-class hardware) while still being playable on low-end devices (such as a Firefox OS Geeksphone Keon). It would have been good to use as much third party software as poss...
Animations and tweens - Game development
le.png', 20, 20); Instead of loading a single image of the ball we can load the whole spritesheet -- a collection of different images. We will show the sprites sequentially to create the illusion of animation. The spritesheet() method's two extra paremeters determine the width and height of each single frame in the given spritesheet file, indicating to the program how to chop it up to get the in
dividual frames. Loading the animation Next up, go into your create() function, find the line that loads the ball sprite, and below it put the call to animations.add() seen below: ball = game.add.sprite(50, 250, 'ball'); ball.animations.add('wobble', [0,1,0,2,0,1,0,2,0], 24); To add an animation to the object we use the animations.add() method, which contains the following parameters The name...
2D maze game with device orientation - Game development
to go through obstacles. There's also room for the traps which will slow the ball down or make it more difficult to reach the hole. You can create more levels of increasing difficulty. You can even implement achievements, leaderboards and medals for different actions in the game. There are endless possibilities -- they only depend on your imagination. Summary I hope this tutorial will help you
dive into 2D game development and inspire you to create awesome games on your own. You can play the demo game Cyber Orb and check out its source code on GitHub. HTML5 gives us raw tools, the frameworks built on top of it are getting faster and better, so now is a great time get into web game development. In this tutorial we used Phaser, but there are a number of other frameworks worth considering to...
Cross Axis - MDN Web Docs Glossary: Definitions of Web-related terms
The cross axis in flexbox runs perpendicular to the main axis, therefore if your flex-direction is either row or row-reverse then the cross axis runs down the columns. If your main axis is column or column-reverse then the cross axis runs along the rows. Alignment of items on the cross axis is achieved with the align-items property on the flex container or align-self property on in
dividual items. In the case of a multi-line flex container, with additional space on the cross axis, you can use align-content to control the spacing of the rows. Learn more Property reference align-content align-items align-self flex-wrap flex-direction flex Further reading CSS Flexbox Guide: Basic Concepts of Flexbox CSS Flexbox Guide: Aligning items in a flex container CSS Flexbox...
Speed index - MDN Web Docs Glossary: Definitions of Web-related terms
re visibly populated. It is the average time at which visible parts of the page are displayed. Expressed in milliseconds, and dependent on the size of the viewport, the lower the score, the better. The calculation calculates what percent of the page is visually complete at every 100ms interval until the page is visually complete. The overall score, the above the fold metric, is a sum of the in
dividual 10 times per second intervals of the percent of the screen that is not-visually complete. ...
Transport Layer Security (TLS) - MDN Web Docs Glossary: Definitions of Web-related terms
and client communicate using TLS, it ensures that no third party can eavesdrop or tamper with any message. All modern browsers support the TLS protocol, requiring the server to provide a valid digital certificate confirming its identity in order to establish a secure connection. It is possible for both the client and server to mutually authenticate each other, if both parties provide their own in
dividual digital certificates. Note: TLS 1.0 and 1.1 support will be removed from all major browsers in early 2020; you'll need to make sure your web server supports TLS 1.2 or 1.3 going forward. From version 74 onwards, Firefox will return a Secure Connection Failed error when connecting to servers using the older TLS versions (bug 1606734). ...
Thread - MDN Web Docs Glossary: Definitions of Web-related terms
between one another. This is done using technologies such as web workers, which can be used to spin off a sub-program which runs concurrently with the main thread in a thread of its own. This allows slow, complex, or long-running tasks to be executed independently of the main thread, preserving the overall performance of the site or app--as well as that of the browser overall. This also allows in
dividuals to take advantage of modern multi-core processors. A special type of worker, called a service worker, can be created which can be left behind by a site--with the user's permission--to run even when the user isn't currently using that site. This is used to create sites capable of notifying the user when things happen while they're not actively engaged with a site. Such as notifying a user t...
Vendor Prefix - MDN Web Docs Glossary: Definitions of Web-related terms
ransition: all 4s ease; -ms-transition: all 4s ease; -o-transition: all 4s ease; transition: all 4s ease; API prefixes Historically, vendors have also used prefixes for experimental APIs. If an entire interface is experimental, then the interface's name is prefixed (but not the properties or methods within). If an experimental property or method is added to a standardized interface, then the in
dividual method or property is prefixed. Interface prefixes Prefixes for interface names are upper-cased: WebKit (Chrome, Safari, newer versions of Opera, almost all iOS browsers (including Firefox for iOS); basically, any WebKit based browser) Moz (Firefox) O (Older, pre-WebKit, versions of Opera) MS (Internet Explorer and Microsoft Edge) Property and method prefixes The prefixes for prop...
VoIP - MDN Web Docs Glossary: Definitions of Web-related terms
logy is because of cost. VoIP allows you to make a call directly from a computer, a special VoIP phone, or a traditional phone connected to a special adapter. A high speed internet connection is required for VoIP. Usually, telephone calls over the Internet do not incur further charges beyond what the user is paying for Internet access, much in the same way that the user doesn't pay for sending in
dividual emails over the Internet. Learn more General knowledge VoIP on Wikipedia ...
WebKit - MDN Web Docs Glossary: Definitions of Web-related terms
WebKit is a framework that displays properly-formatted webpages based on their markup. Apple Safari depends on WebKit, and so do many mobile browsers (since WebKit is highly portable and customizable). WebKit began life as a fork of KDE's KHTML and KJS libraries, but many in
dividuals and companies have since contributed (including KDE, Apple, Google, and Nokia). WebKit is an Apple trademark, and the framework is distributed under a BSD-form license. However, two important components fall under the LGPL: the WebCore rendering library and the JavaScriptCore engine. Learn more General knowledge WebKit on Wikipedia Technical reference WebKit CSS extensions ...
Web standards - MDN Web Docs Glossary: Definitions of Web-related terms
s (STD), which among other things govern set-up and use of URIs, HTTP, and MIME W3C: specifications for markup language (e.g., HTML), style definitions (i.e., CSS), DOM, accessibility IANA (Internet Assigned Numbers Authority): name and number registries Ecma Intl.: scripting standards, most prominently for JavaScript ISO (International Organization for Standardization): standards governing a
diverse array of aspects, including character encodings, website management, and user-interface design Learn more General knowledge Web standards on Wikipedia ...
Modularity - MDN Web Docs Glossary: Definitions of Web-related terms
The term Modularity refers to the degree to which a system's components may be separated and recombined, it is also
division of a software package into logical units. The advantage of a modular system is that one can reason the parts independently Learn more Modularity on Wikipedia ...
Assessment: Accessibility troubleshooting - Learn web development
the current color contrast (text/background), report the results of the test, and then fix it by changing the assigned colors? Semantic HTML The content is still not very accessible -- report on what happens when you try to navigate it using a screenreader. Can you update the article text to make it easier for screenreader users to navigate? The navigation menu part of the site (wrapped in <
div class="nav"></
div>) could be made more accessible by putting it in a proper HTML5 semantic element. Which one should it be updated to? Make the update. Note: You'll need to update the CSS rule selectors that style the tags to their proper equivalents for the semantic headings. Once you add paragraph elements, you'll notice the styling looking better. The images The images are currently ina...
Accessible multimedia - Learn web development
led main.js and save it in the same directory. First of all, let's look at the HTML for the video player, in the HTML: <section class="player"> <video controls> <source src="rabbit320.mp4" type="video/mp4"> <source src="rabbit320.webm" type="video/webm"> <p>Your browser doesn't support HTML5 video. Here is a <a href="rabbit320.mp4">link to the video</a> instead.</p> </video> <
div class="controls"> <button class="playpause">Play</button> <button class="stop">Stop</button> <button class="rwd">Rwd</button> <button class="fwd">Fwd</button> <
div class="time">00:00</
div> </
div> </section> JavaScript basic setup We've inserted some simple control buttons below our video. These controls of course won't do anything by default; to add functionality, we will ...
Cascade and inheritance - Learn web development
has only been an approximate example for ease of understanding. In actuality, each selector type has its own level of specificity that cannot be overwritten by selectors with a lower specificity level. For example, a million class selectors combined would not be able to overwrite the rules of one id selector. A more accurate way to evaluate specificity would be to score the specificity levels in
dividually starting from highest and moving on to lowest when necessary. Only when there is a tie between selector scores within a specificity level do you need to evaluate the next level down; otherwise, you can disregard the lower specificity level selectors since they can never overwrite the higher specificity levels. !important There is a special piece of CSS that you can use to overrule all o...
Handling different text directions - Learn web development
roperty on .box to vertical-rl, you will see how the physical properties stay tied to their physical direction, whereas the logical properties switch with the writing mode. You can also see that the <h2> has a black border-bottom. Can you work out how to make that bottom border always go below the text in both writing modes? There are a huge number of properties when you consider all of the in
dividual border longhands, and you can see all of the mapped properties on the MDN page for Logical Properties and Values. Logical values We have so far looked at logical property names. There are also some properties that take physical values of top, right, bottom, and left. These values also have mappings, to logical values -- block-start, inline-end, block-end, and inline-start. For example, yo...
Images, media, and form elements - Learn web development
nd that they behave slightly differently to other elements. For example, in a flex or grid layout elements are stretched by default to fill the entire area. Images will not stretch, and instead will be aligned to the start of the grid area or flex container. You can see this happening in the example below where we have a two column, two row grid container, which has four items in it. All of the <
div> elements have a background color and stretch to fill the row and column. The image, however, does not stretch. If you are following these lessons in order then you may not have looked at layout yet. Just keep in mind that replaced elements, when they become part of a grid or flex layout, have different default behaviors, essentially to avoid them being stretched strangely by the layout. To f...
Attribute selectors - Learn web development
in square brackets). [attr=value] a[href="https://example.com"] Matches elements with an attr attribute whose value is exactly value -- the string inside the quotes. [attr~=value] p[class~="special"] Matches elements with an attr attribute whose value is exactly value, or contains value in its (space separated) list of values. [attr|=value]
div[lang|="zh"] Matches elements with an attr attribute whose value is exactly value or begins with value immediately followed by a hyphen. In the example below you can see these selectors being used. By using li[class] we can match any selector with a class attribute. This matches all of the list items except the first one. li[class="a"] matches a selector with a class of a, but not a ...
Combinators - Learn web development
when the element is adjacent. General sibling combinator If you want to select siblings of an element even if they are not directly adjacent, then you can use the general sibling combinator (~). To select all <img> elements that come anywhere after <p> elements, we'd do this: p ~ img In the example below we are selecting all <p> elements that come after the <h1>, and even though there is a <
div> in the document as well, the <p> that comes after it is selected. Using combinators You can combine any of the selectors that we discovered in previous lessons with combinators in order to pick out part of your document. For example if we want to select list items with a class of "a", which are direct children of a <ul>, I could use the following. ul > li[class="a"] { } Take care however...
CSS selectors - Learn web development
Selectors specification; like any other part of CSS they need to have support in browsers for them to work. The majority of selectors that you will come across are defined in the Level 3 Selectors specification, which is a mature specification, therefore you will find excellent browser support for these selectors. Selector lists If you have more than one thing which uses the same CSS then the in
dividual selectors can be combined into a selector list so that the rule is applied to all of the in
dividual selectors. For example, if I have the same CSS for an h1 and also a class of .special, I could write this as two separate rules. h1 { color: blue; } .special { color: blue; } I could also combine these into a selector list, by adding a comma between them. h1, .special { color: blue;...
CSS values and units - Learn web development
width of the viewport. If you change the width of your browser window, the size of the box should change, however this example is embedded into the page using an <iframe>, so this won't work. To see this in action you'll have to try the example after opening it in its own browser tab. The third box uses em units. These are relative to the font size. I've set a font size of 1em on the containing <
div>, which has a class of .wrapper. Change this value to 1.5em and you will see that the font size of all the elements increases, but only the last item will get wider, as the width is relative to that font size. After following the instructions above, try playing with the values in other ways, to see what you get. ems and rems em and rem are the two relative lengths you are likely to encounter...
CSS building blocks - Learn web development
This module looks at the cascade and inheritance, all the selector types we have available, units, sizing, styling backgrounds and borders, debugging, and lots more. The aim here is to provide you with a toolkit for writing competent CSS and help you understand all the essential theory, before moving on to more specific disciplines like text styling and CSS layout. ...
Test your skills: Flexbox - Learn web development
er what content is in each item. Try updating the live code below to recreate the finished example: Additional questions: Can you now make the first item twice the size of the other items? For assessment or further work purposes, download the starting point for this task to work in your own editor or in an online editor. Flex Layout Three There are two elements in the HTML below, a
div with a class of .parent which contains another
div with a class of .child. Use Flexbox to center the child inside the parent. Try updating the live code below to recreate the finished example: For assessment or further work purposes, download the starting point for this task to work in your own editor or in an online editor. Flex Layout Four In this final task arrange these items into r...
Positioning - Learn web development
ligula ipsum, tristique sit amet orci vel, viverra egestas ligula. Curabitur vehicula tellus neque, ac ornare ex malesuada et. In vitae convallis lacus. Aliquam erat volutpat. Suspendisse ac imperdiet turpis. Aenean finibus sollicitudin eros pharetra congue. Duis ornare egestas augue ut luctus. Proin blandit quam nec lacus varius commodo et a urna. Ut id ornare felis, eget fermentum sapien.</p> <
div class="positioned">Sticky</
div> <p>Nam vulputate diam nec tempor bibendum. Donec luctus augue eget malesuada ultrices. Phasellus turpis est, posuere sit amet dapibus ut, facilisis sed est. Nam id risus quis ante semper consectetur eget aliquam lorem. Vivamus tristique elit dolor, sed pretium metus suscipit vel. Mauris ultricies lectus sed lobortis finibus. Vivamus eu urna eget velit cursus viver...
What is CSS? - Learn web development
we have the color property, which can take various color values. We also have the font-size property. This property can take various size units as a value. A CSS stylesheet will contain many such rules, written one after the other. h1 { color: red; font-size: 5em; } p { color: black; } You will find that you quickly learn some values, whereas others you will need to look up. The in
dividual property pages on MDN give you a quick way to look up properties and their values when you forget, or want to know what else you can use as a value. Note: You can find links to all the CSS property pages (along with other CSS features) listed on the MDN CSS reference. Alternatively, you should get used to searching for "mdn css-feature-name" in your favourite search engine whenever you nee...
Using CSS generated content - Learn web development
nt as its value. HTML A text where I need to <span class="ref">something</span> CSS .ref::before { font-weight: bold; color: navy; content: "Reference "; } Output The character set of a stylesheet is UTF-8 by default, but it can also be specified in the link, in the stylesheet itself, or in other ways. For details, see 4.4 CSS style sheet representation in the CSS Specification. In
dividual characters can also be specified by an escape mechanism that uses backslash as the escape character. For example, "\265B" is the chess symbol for a black queen ?. For details, see Referring to characters not represented in a character encoding and Characters and case in the CSS Specification. Image content To add an image before or after an element, you can specify the URL of an image file...
What text editors are available? - Learn web development
t find out which OS you're using, and then check if a given editor supports your OS. Most editors specify on their website whether they support Windows or Mac, though some editors only support certain versions (say, only Windows 7 or later and not Vista). If you're running Ubuntu, your best bet is to search within the Ubuntu Software Center. In general, of course, the Linux/UNIX world is a pretty
diverse place where different distros work with different, incompatible packaging systems. That means, if you've set your heart on an obscure text editor, you may have to compile it from source yourself (not for the faint-hearted). What kind of technologies do I want to manipulate? Generally speaking, any text editor can open any text file. That works great for writing notes to yourself, but when y...
What do common web layouts contain? - Learn web development
space. These are rules of thumb you can draw on. There are complex designs and exceptions, of course. In other articles we'll discuss how to design responsive sites (sites that change depending on the screen size) and sites whose layouts vary between pages. For now, it's best to keep your layout consistent throughout your site. Active learning There is no active learning available yet. Deeper
dive Let's study some more concrete examples taken from well-known websites. One-column layout Invision application. A typical one-column layout providing all the information linearly on one page. Quite straightforward. Just remember, many people will still browse your site from desktops, so make your content usable/readable there as well. Two-column layout. Abduzeedo, a simple blog l...
How does the Internet work? - Learn web development
evolved over time, but the way it works hasn't changed that much: Internet is a way to connect computers all together and ensure that, whatever happens, they find a way to stay connected. Active Learning How the internet Works in 5 minutes: A 5 minute video to understand the very basics of Internet by Aaron Titus. How does the Internet work? Detailed well visualized 8 minute video. Deeper
dive A simple network When two computers need to communicate, you have to link them, either physically (usually with an Ethernet cable) or wirelessly (for example with WiFi or Bluetooth systems). All modern computers can sustain any of those connections. Note: For the rest of this article, we will only talk about physical cables, but wireless networks work the same. Such a network is not limi...
How much does it cost to do something on the Web? - Learn web development
Brackets, Bluefish, TextWrangler, Eclipse, Netbeans, and Visual Studio Code. Some, like Sublime Text, you can test as long as you like, but you're encouraged to pay. Some, like PhpStorm, can cost between a few dozen and 200 dollars, depending on the plan you purchase. Some of them, like Microsoft Visual Studio, can cost hundreds, or thousands of dollars; though Visual Studio Express is free for in
dividual developers or open source projects. Often, for-pay editors will have a trial version. To start, we suggest trying out several editors, to get a sense of which works best for you. If you're only writing simple HTML, CSS, and Javascript, go with a simple editor. Price does not reliably reflect a text editor's quality or usefulness. You have to try it for yourself and decide if it meets your ...
What is the difference between webpage, website, web server, and search engine? - Learn web development
he website) will have books on heat, sound, thermodynamics, statics, etc. (the webpages). Webpages can each be found at a unique location (URL). The search index is like the search engine. Each book has its own unique location in the library (two books cannot be kept at the same place) which is specified by the catalog number. Active learning There is no active learning available yet. Deeper
dive So, let's dig deeper into how those four terms are related and why they are sometimes confused with each other. Web page A web page is a simple document displayable by a browser. Such documents are written in the HTML language (which we look into in more detail in other articles). A web page can embed a variety of different types of resources such as: style information -- controlling a pag...
How do I start to design my website? - Learn web development
should answer before anything else: What exactly do I want to accomplish? How will a website help me reach my goals? What needs to be done, and in what order, to reach my goals? All of this is called project ideation and is a necessary first step to reach your goal, whether you are a beginner or an experienced developer. Active Learning There is no active learning available yet. Deeper
dive A project never starts with the technical side. Musicians will never make any music unless they first have an idea of what they want to play--and the same is true for painters, writers, and web developers. Technique comes second. Technique is obviously critical. Musicians must master their instrument. But good musicians can never produce good music without an idea. Therefore, before jumping in...
What are hyperlinks? - Learn web development
Links stand out from the surrounding text by being underlined and in blue text. Tap or click a link to activate it, or if you use a keyboard, press Tab until the link is in focus and hit Enter or Spacebar. Links are the breakthrough that made the Web so useful and successful. In the rest of this article, we discuss the various types of links and their importance to modern Web design. Deeper
dive As we said, a link is a text string tied to a URL, and we use links to allow easy jumping from one document to another. That said, there are some nuances worth considering: Types of links Internal link A link between two webpages, where both webpages belong to the same website, is called an internal link. Without internal links, there's no such thing as a website (unless, of course, it's a...
What is a URL? - Learn web development
image, etc. In practice, there are some exceptions, the most common being a URL pointing to a resource that no longer exists or that has moved. As the resource represented by the URL and the URL itself are handled by the Web server, it is up to the owner of the web server to carefully manage that resource and its associated URL. Active Learning There is no active learning available yet. Deeper
dive Basics: anatomy of a URL Here are some examples of URLs: https://developer.mozilla.org https://developer.mozilla.org/docs/Learn/ https://developer.mozilla.org/search?q=URL Any of those URLs can be typed into your browser's address bar to tell it to load the associated page (resource). A URL is composed of different parts, some mandatory and others optional. Let's see the most important part...
What is a Domain Name? - Learn web development
Pv4 address (e.g. 173.194.121.32) or an IPv6 address (e.g., 2027:0da8:8b73:0000:0000:8a2e:0370:1337). Computers can handle such addresses easily, but people have a hard time finding out who's running the server or what service the website offers. IP addresses are hard to remember and might change over time. To solve all those problems we use human-readable addresses called domain names. Deeper
dive Structure of domain names A domain name has a simple structure made of several parts (it might be one part only, two, three...), separated by dots and read from right to left: Each of those parts provides specific information about the whole domain name. TLD (Top-Level Domain). TLDs tell users the general purpose of the service behind the domain name. The most generic TLDs (.com, .org, ...
What is a web server? - Learn web development
n server might fill an HTML template with content from a database. Sites like MDN or Wikipedia have thousands of webpages. Typically, these kinds of sites are composed of only a few HTML templates and a giant database, rather than thousands of static HTML documents. This setup makes it easier to maintain and deliver the content. Active learning There is no active learning available yet. Deeper
dive To review: to fetch a webpage, your browser sends a request to the web server, which searches for the requested file in its own storage space. Upon finding the file, the server reads it, processes it as-needed, and sends it to the browser. Let's look at those steps in more detail. Hosting files First, a web server has to store the website's files, namely all HTML documents and their related a...
Basic native form controls - Learn web development
othing is sent, not even their name. If they are checked but have no value, the name is sent with a value of on. Note: You can find the examples from this section on GitHub as checkable-items.html (see it live also). For maximum usability/accessibility, you are advised to surround each list of related items in a <fieldset>, with a <legend> providing an overall description of the list. Each in
dividual pair of <label>/<input> elements should be contained in its own list item (or similar). The associated <label> is generally placed immediately after the radio button or checkbox, with the instructions for the group of radio button or checkboxes generally being the content of the <legend>. See the examples linked above for structural examples. Check box A check box is created using the <inp...
Example - Learn web development
abel> <input type="date" id="date" name="expiration"> </p> </section> <section> <p> <button type="submit">Validate the payment</button> </p> </section> </form> CSS Content h1 { margin-top: 0; } ul { margin: 0; padding: 0; list-style: none; } form { margin: 0 auto; width: 400px; padding: 1em; border: 1px solid #CCC; border-radius: 1em; }
div+
div { margin-top: 1em; } label span { display: inline-block; width: 120px; text-align: right; } input, textarea { font: 1em sans-serif; width: 250px; box-sizing: border-box; border: 1px solid #999; } input[type=checkbox], input[type=radio] { width: auto; border: none; } input:focus, textarea:focus { border-color: #000; } textarea { vertical-ali...
Other form controls - Learn web development
in on a questionnaire. The content inside the <progress> element is a fallback for browsers that don't support the element and for screen readers to vocalize it. Meter A meter bar represents a fixed value in a range delimited by max and min values. This value is visually rendered as a bar, and to know how this bar looks, we compare the value to some other set values: The low and high values
divide the range in three parts: The lower part of the range is between the min and low values, inclusive. The medium part of the range is between the low and high values, exclusive. The higher part of the range is between the high and max values, inclusive. The optimum value defines the optimum value for the <meter> element. In conjuction with the low and high value, it defines whi...
Test your skills: Advanced styling - Learn web development
w can you remove this? There is a major problem with just getting rid of the blue focus outline. What is it? Can you add some kind of styling back in so that users can tell when the search box is being hovered or focused? Another thing that commonly denotes a search box is a magnifying glass icon. We've made one available in the same directory as our HTML files -- see search-24px.png -- plus a <
div> element after the search input to help you attach it, should you need it. Can you figure out a sensible way to attach it, and can you use some CSS to get it to sit to the right of the search box, and be lined up vertically as well? Try updating the live code below to recreate the finished example: Download the starting point for this task to work in your own editor or in an online editor. ...
Web forms — Working with user data - Learn web development
ook in more detail at the elements used to provide structure and meaning to the different parts of a form. The different form controls Basic native form controls We start off this section by looking at the functionality of the the original HTML <input> types in detail, looking at what options are available to collect different types of data. The HTML5 input types Here we continue our deep
dive into the <input> element, looking at the additional input types provided when HTML5 was released, and the various UI controls and data collection enhancements they provide. Additionally, we look at the <output> element. Other form controls Next we take a look at all the non-<input> form controls and associated tools, such as <select>, <textarea>, <meter>, and <progress>. Form styling guides ...
HTML basics - Learn web development
img> element that we already have in our HTML page: <img src="images/firefox-icon.png" alt="My test image"> This contains two attributes, but there is no closing </img> tag and no inner content. This is because an image element doesn't wrap content to affect it. Its purpose is to embed an image in the HTML page in the place it appears. Anatomy of an HTML document That wraps up the basics of in
dividual HTML elements, but they aren't handy on their own. Now we'll look at how in
dividual elements are combined to form an entire HTML page. Let's revisit the code we put into our index.html example (which we first met in the Dealing with files article): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>My test page</title> </head> <body> <img src="images/firefox-icon.
The web and web standards - Learn web development
ayout on mobile phone browsers. Try adjusting the width of your browser window now, and see what happens. Performance means getting web sites to load as quickly as possible, but also making them intuitive and easy to use so that users don't get frustrated and go somewhere else. Accessibility means making your websites usable by as many different kinds of people as possible (related concepts are
diversity and inclusion, and inclusive design). This includes people with visual impairments, hearing impairments, cognitive disabilities, or physical disabilities. It also goes beyond people with disabilities -- how about young or old people, people from different cultures, people using mobile devices, or people with unreliable or slow network connections? Internationalization means making websites...
Tips for authoring fast-loading HTML pages - Learn web development
ayouts utilizing floats, positioning, flexbox, or grids should be used instead. Tables are still considered valid markup but should be used for displaying tabular data. To help the browser render your page quicker, you should avoid nesting your tables. Rather than deeply nesting tables as in: <table> <table> <table> ... </table> </table> </table> use non-nested tables or
divs as in <table>...</table> <table>...</table> <table>...</table> See also: CSS Flexible Box Layout and CSS Grid Layout specifications. Minify and compress SVG assets SVG produced by most drawing applications often contains unnecessary metadata which can be removed. Configure your servers, apply gzip compression for SVG assets. Minify and compress your images Large images cause your page to ...
Use HTML to solve common problems - Learn web development
The following links point to solutions to common everyday problems you'll need to solve with HTML. Basic structure The most basic application of HTML is document structure. If you're new to HTML you should start with this. How to create a basic HTML document How to
divide a webpage into logical sections How to set up a proper structure of headings and paragraphs Basic text-level semantics HTML specializes in providing semantic information for a document, so HTML answers many questions you might have about how to get your message across best in your document. How to create a list of items with HTML How to stress or emphasize content How to indicate that text is important How to display computer code with HTML How to annotate images and graphics How to mark abbreviations an...
Introduction to HTML - Learn web development
r elements in HTML for formatting text that we didn't get to in the HTML text fundamentals article. The elements here are less well-known, but still useful to know about. In this article, you'll learn about marking up quotations, description lists, computer code and other related text, subscript and superscript, contact information, and more. Document and website structure As well as defining in
dividual parts of your page (such as "a paragraph" or "an image"), HTML is also used to define areas of your website (such as "the header," "the navigation menu," or "the main content column.") This article looks into how to plan a basic website structure and how to write the HTML to represent this structure. Debugging HTML Writing HTML is fine, but what if something goes wrong, and you can't work ...
HTML table basics - Learn web development
s, the screenreaders' output will be confusing to their users. Tables produce tag soup: As mentioned above, table layouts generally involve more complex markup structures than proper layout techniques. This can result in the code being harder to write, maintain, and debug. Tables are not automatically responsive: When you use proper layout containers (such as <header>, <section>, <article>, or <
div>), their width defaults to 100% of their parent element. Tables on the other hand are sized according to their content by default, so extra measures are needed to get table layout styling to effectively work across a variety of devices. Active learning: Creating your first table We've talked table theory enough, so, let's
dive into a practical example and build up a simple table. First of a...
Introducing asynchronous JavaScript - Learn web development
sing the result of one into the next one as an input. This is much harder to do with callbacks, which often ends up with a messy "pyramid of doom" (also known as callback hell). Promise callbacks are always called in the strict order they are placed in the event queue. Error handling is much better -- all errors are handled by a single .catch() block at the end of the block, rather than being in
dividually handled in each level of the "pyramid". Promises avoid inversion of control, unlike old-style callbacks, which lose full control of how the function will be executed when passing a callback to a third-party library. The nature of asynchronous code Let's explore an example that further illustrates the nature of async code, showing what can happen when we are not fully aware of code exec...
Graceful asynchronous programming with Promises - Learn web development
ove have successfully fulfilled. To begin with, add a block with an empty executor inside the .then() call, like so: Promise.all([coffee, tea, description]).then(values => { }); You can see that it takes an array containing the promises as a parameter. The executor will only run when all three promises resolve; when that happens, it will be passed an array containing the results from the in
dividual promises (i.e. the decoded response bodies), kind of like [coffee-results, tea-results, description-results]. Finally, add the following inside the executor. Here we use some fairly simple sync code to store the results in separate variables (creating object URLs from the blobs), then display the images and text on the page. console.log(values); // Store each value returned from the...
Test your skills: Events - Learn web development
puts: x -- the x coordinate of the circle. y -- the y coordinate of the circle. size -- the radius of the circle. Try updating the live code below to recreate the finished example: Download the starting point for this task to work in your own editor or in an online editor. Events 3 In our final events-related task, you need to set an event listener on the <button>s' parent element (<
div class="button-bar"> ... </
div>), which when invoked by clicking any of the buttons will set the background of the button-bar to the color contained in the button's data-color attribute. We want you to solve this without looping through all the buttons and giving each one their own event listener. Try updating the live code below to recreate the finished example: Download the starting point ...
Fetching data from the server - Learn web development
This seemingly small detail has had a huge impact on the performance and behavior of sites, so in this article, we'll explain the concept and look at technologies that make it possible, such as XMLHttpRequest and the Fetch API. ...
Client-side web APIs - Learn web development
the Document Object Model (DOM), a set of APIs for controlling HTML and styling information that makes heavy use of the Document object. In this article, we'll look at how to use the DOM in detail, along with some other interesting APIs that can alter your environment in interesting ways. Fetching data from the server Another very common task in modern websites and applications is retrieving in
dividual data items from the server to update sections of a webpage without having to load an entirely new page. This seemingly small detail has had a huge impact on the performance and behavior of sites. In this article, we'll explain the concept, and look at technologies that make it possible, such as XMLHttpRequest and the Fetch API. Third party APIs The APIs we've covered so far are built into...
Storing the information you need — Variables - Learn web development
about them now, feel free to check out our let reference page). For a start, if you write a multiline JavaScript program that declares and initializes a variable, you can actually declare a variable with var after you initialize it and it will still work. For example: myName = 'Chris'; function logName() { console.log(myName); } logName(); var myName; Note: This won't work when typing in
dividual lines into a JavaScript console, just when running multiple lines of JavaScript in a web document. This works because of hoisting -- read var hoisting for more detail on the subject. Hoisting no longer works with let. If we changed var to let in the above example, it would fail with an error. This is a good thing -- declaring a variable after you initialize it results in confusing, harder...
Object building practice - Learn web development
Prerequisites: Basic computer literacy, a basic understanding of HTML and CSS, familiarity with JavaScript basics (see First steps and Building blocks) and OOJS basics (see Introduction to objects). ...
Introducing JavaScript objects - Learn web development
b page). You'll come across it quite often, so in this article, we give you all you need to work with JSON using JavaScript, including parsing the JSON so you can access data items within it and writing your own JSON. Object building practice In previous articles we looked at all the essential JavaScript object theory and syntax details, giving you a solid base to start from. In this article we
dive into a practical exercise, giving you some more practice in building custom JavaScript objects, which produce something fun and colorful -- some colored bouncing balls. Assessments Adding features to our bouncing balls demo In this assessment, you are expected to use the bouncing balls demo from the previous article as a starting point, and add some new and interesting features to it. ...
Aprender y obtener ayuda - Learn web development
l meetups to meet other like-minded people, especially ones that cater to beginners. meetup.com is a good place to find local physical meetups, and you could also try your local press/what's on sites. You could also try attending full-fledged web conferences. While these can be expensive, you could try volunteering at them, and many conferences offer reduced rate tickets, for example, student or
diversity tickets. See also Coursera: Learning to learn Freecodecamp Codecademy ...
Measuring performance - Learn web development
or example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways; such as loading a resource, like an image. The PerformanceObserver API can be used to observe performance measurement events and it can notify you of new performance entries as they are recorded in the browser's performance timeline. While this article does not
dive into using these APIs, it is useful to know they exist. You can also refer to the Navigation and timings article for further examples on using performance Web APIs. Tools and metrics There are a number of different tools available to help you improve performance. These can generally be classified into two categories: Tools that indicate or measure performance, such as PageSpeed Insights o...
Perceived performance - Learn web development
ssive and active waits time were objectively equal, users would estimate that the passive waiting period was longer than the active. If a load, render, or response time can not be objectively minimized any further, turning the wait into an active wait instead of a passive wait can make it feel faster. There are tips and tricks to follow. Some of these quick tips have full articles if you want to
dive deeper. Displaying content, or at least some part of the page with an indication that content is loading, as quickly as possible, is essential to improving perceived performance. For example, because page render is blocked by loading and parsing CSS and JavaScript, minimizing the amount of CSS and JS that needs to be loaded on initially will have a major impact on improving perceived performanc...
The "why" of web performance - Learn web development
ance refers to how quickly site content loads and renders in a web browser, and how well it responds to user interaction. Bad performing sites are slow to display and slow to respond to input. Bad performing sites increase site abandonment. At its worst, bad performance causes content to be completely inaccessible. A good goal for web performance is for users to not notice performance. While an in
dividual's perception of site performance performance is subjective, loading and rendering can be measured. Good performance may not be obvious to most site visitors, but most will immediately recognize a sluggish site. That is why we care. Why care about performance? Web performance--and its assocatiated best practices--are vital for your website visitors to have a good experience. In a sense, web...
Web performance - Learn web development
ted by actual page load time, idling, responsiveness to user interaction, and the smoothness of scrolling and other animations. In this article, we discuss the various loading metrics, animation, and responsiveness metrics, along with best practices to improve user perception, if not the actual timings. Measuring performance Now that you understand a few performance metrics, we take a deeper
dive into performance tools, metrics, and APIs and how we can make performance part of the web development workflow. Multimedia: images The lowest hanging fruit of web performance is often media optimization. Serving different media files based on each user agent's capability, size, and pixel density is possible. In this article we discuss the impact images have on performance, and the methods to r...
Getting started with Ember - Learn web development
ion development experience, minimizing the trivial differences between applications -- all while being a modern and light layer on top of native JavaScript. Ember also has immense backwards and forwards compatibility to help businesses stay up to date with the latest versions of Ember and latest community-driven conventions. What does it mean to be a component-service framework? Components are in
dividual bundles of behavior, style, and markup -- much like what other frontend frameworks provide, such as React, Vue, and Angular. The service side provides long-lived shared state, behavior, and an interface to integrating with other libraries or systems. For example, the Router (which will be mentioned later in this tutorial) is a service. Components and Services make up the majority of any Embe...
Deployment and next steps - Learn web development
Nevertheless, Svelte.js -- The Complete Guide by Academind is a very popular option with great ratings. The Svelte Handbook, by Flavio Copes, is also a useful reference for learning the main Svelte concepts. If you prefer to read books, there's Svelte and Sapper in Action by Mark Volkman, expected to be published in September 2020, but which you can already preview online for free. If you want
dive deeper and understand the inner working of Svelte's compiler you should check Tan Li Hau's Compile Svelte in your head blog posts. Here's Part 1, Part 2, and Part 3. Interacting with the community There are a number of different ways to get support and interact with the Svelte community: svelte.dev/chat: Svelte's Discord server. @sveltejs: The official Twitter account. @sveltesociety: Sv...
Focus management with Vue refs - Learn web development
een removed from the DOM activated() -- Only used in components wrapped in a special keep-alive tag. Runs after the component is activated. deactivated() -- only used in components wrapped in a special keep-alive tag. Runs after the component is deactivated. Note: The Vue Docs provide a nice diagram for visualizing when these hooks happen. This article from the Digital Ocean Community Blog
dives into the lifecycle methods more deeply. Now that we've gone over the lifecycle methods, let's use one to trigger focus when our ToDoItemEditForm component is mounted. In ToDoItemEditForm.vue, attach ref="labelInput" to the <input> element, like so: <input :id="id" ref="labelInput" type="text" autocomplete="off" v-model.lazy.trim="newName" /> Next, add a mounted() property just inside your ...
Styling Vue components with CSS - Learn web development
-top-color: transparent; opacity: 0; background: transparent; } .custom-checkbox > input[type="checkbox"]:checked + label::after { opacity: 1; } @media only screen and (min-width: 40rem) { label, input, .custom-checkbox { font-size: 19px; font-size: 1.9rem; line-height: 1.31579; } } Now we need to add some CSS classes to our template to connect the styles. To the root <
div>, add a custom-checkbox class. To the <input>, add a checkbox class. Last of all, to the <label> add a checkbox-label class. The updated template is below: The app should now have custom checkboxes. Your app should look something like the screenshot below. Summary Our work is done on the styling of our sample app. In the next article we'll return to adding some more functionlity to our app, ...
Introduction to cross browser testing - Learn web development
use.com, for some further useful details. Once you've agreed on these details, you can go ahead and start developing the site. Development Now on to the development of the site. You should split the different parts of the development into modules, for example you might split the different site areas up -- home page, product page, shopping cart, payment workflow, etc. You might then further sub
divide these -- implement common site header and footer, implement product page detail view, implement persistent shopping cart widget, etc. There are multiple general strategies to cross browser development, for example: Get all the functionality working as closely as possible in all target browsers. This may involve writing different code paths that reproduce functionality in different ways aim...
Strategies for carrying out testing - Learn web development
werful processors. Your main work machine can also be a place to install other tools for specific purposes, such as accessibility auditing tools, screen readers, and emulators/virtual machines. Some larger companies have device labs that stock a very large selection of different devices, enabling developers to hunt down bugs on very specific browser/device combinations. Smaller companies and in
dividuals are generally not able to afford such a sophisticated lab, so tend to make do with smaller labs, emulators, virtual machines, and commercial testing apps. We will cover each of the other options below. Note: Some efforts have been made to create publically accessible device labs -- see Open Device Labs. Note: We also need to consider accessibility -- there are a number of useful tools...
Setting up your own test automation environment - Learn web development
instance you created earlier, for example: driver.get('http://www.google.com'); Note: See the WebDriver class reference for details of the features in this section and the ones below it. You can use any URL to point to your resource, including a file:// URL to test a local document: driver.get('file:///Users/chrismills/git/learning-area/tools-testing/cross-browser-testing/accessibility/fake-
div-buttons.html'); or driver.get('http://localhost:8888/fake-
div-buttons.html'); But it is better to use a remote server location so the code is more flexible -- when you start using a remote server to run your tests (see later on), your code will break if you try to use local paths. Add this line to the bottom of quick_test.js now: driver.get('http://mdn.github.io/learning-area/tools-testing/...
Git and GitHub - Learn web development
hes in Git), work on a new feature in that version, and then get it merged in a controlled manner (in GitHub we use pull requests) with the master version when they are done with it. VCSes provide tools to meet the above needs. Git is an example of a VCS, and GitHub is a web site + infrastructure that provides a Git server plus a number of really useful tools for working with git repositories in
dividually or in teams, such as reporting issues with the code, reviewing tools, project management features such as assigning tasks and task statuses, and more. Note: Git is actually a distributed version control system, meaning that a complete copy of the repository containing the codebase is made on your computer (and everyone else's). You make changes to your own copy, and then push those chang...
Introducing a complete toolchain - Learn web development
already got it installed globally using the following command: prettier -v If installed, you'll get a version number returned like 2.0.2; if not, it'll return something along the lines of "command not found". If this is the case, install it using the following command: npm install prettier -g Now that Prettier is installed, running and tidying your code can be done on the command line on an in
dividual file basis from anywhere on your computer, for example: prettier --write ./src/index.html Note: In the command above, I use Prettier with the --write flag. Prettier understands this to mean "if there's problems in my code format, go ahead and fix them, then save my file". This is fine for our development process, but we can also use prettier without the flag and it will only check the fil...
Package management basics - Learn web development
ge could have pulled in date-fns. It's equally possible (and not ideal) that you have multiple versions of a package in your project (this has been seen many times over with the lodash package, as it's so useful). Although the package manager will do it's best to deduplicate packages you may want to investigate exactly which version is installed. More commands You can find out more about the in
dividual commands for npm and yarn online. Again, pnpm commands will have parity with npm, with a handful of additions. Making your own commands The package managers also support creating your own commands and executing them from the command line. For instance, we could create the following command: npm run dev # or yarn run dev This would run a custom script for starting our project in "developm...
Understanding client-side web development tools - Learn web development
g to become a front-end web developer? We have put together a course that includes all the essential information you need to work towards your goal. Get started Guides 1. Client-side tooling overview In this article we provide an overview of modern web tooling, what kinds of tools are available and where you'll meet them in the lifecycle of web app development, and how to find help with in
dividual tools. 2. Command line crash course In your development process you'll undoubtedly be required to run some command in the terminal (or on the "command line" -- these are effectively the same thing). This article provides an introduction to the terminal, the essential commands you'll need to enter into it, how to chain commands together, and how to add your own command line interface (CLI) ...
Accessibility Information for Core Gecko Developers
These widgets are often not even keyboard focusable, and assistive technologies do not understand these widgets. This document shows several interactive desktop-style widgets that are accessible by keyboards and assistive technologies, and outlines a plan being developed by IBM, Mozilla, and the WAI Protocols and Formats Working Group (PFWG) to address the issue of DHTML accessibility. ...
Accessibility/LiveRegionDevGuide
e slightly different in AT-SPI and IAccessible2. In AT-SPI, the object changed event are called object:children-changed events because the event is triggered on the parent of the object. The actual object that change can then be found in the event.any_data field. In IAccessible2, the EVENT_OBJECT_* events are triggered on the actual object that changed. The object changed events can be further sub
divided into object addition and removal events. In AT-SPI, this is accomplished by appending ":add" or ":remove" to the event string. In IAccessible2, there are two separate event types, namely EVENT_OBJECT_SHOW and EVENT_OBJECT_HIDE. Text Changed The text changed events are quite similar in AT-SPI and IAccessible2 with both having an insert and delete or removal events. The text changed event ty...
Links and Resources
p Environments Gnome Accessibility - Gnome Accessibility Project KDE Accessibility Project - an equally important toolkit on Linux Apple Accessibility - Moving forward with OS X. Other resources Trace Center - Trace Center of the University of Wisconsin (research on technology for persons with disabilities). Home of LARS (Linux Accessibility Resource Site) at University of Toronto.
Dive Into Accessibility - Another great, easy-to-understand resource on accessible website authoring. Color contrast analyzer by Juicy Studio: an excellent tool for checking if webpages use/have sufficient color contrast, sufficient brightness difference by comparing background and foreground (text) colors. This tool will measure accurately the degree of legibility of a webpage. ...
Mozilla's Section 508 Compliance
available is text content, text input caret location, and text attributes. Complete. Caret location and text attributes are exposed via MSAA (Windows) and ATK (Linux/UNIX) Incomplete. No development efforts have made made to utilize Cocoa or Carbon accessibility APIs. (g) Applications shall not override user selected contrast and color selections and other in
dividual display attributes. Complete. The default theme, Classic, uses the operating system's font and color contrast settings. When the Windows "high contrast theme" is used Classic, and thus the system look and feel, is automatically selected. Complete when run in the Gnome desktop. The default theme, Classic, uses Gnome's font and color contrast settings. Under Linux/UNIX it is th...
Software accessibility: Where are we today?
ost software doesn't rely exclusively on audio to relay feedback. If a person was unable to do one of the above-listed tasks, they found themselves unable to use many popular computer applications. Here are some of the groups of people that have problems doing some of those tasks: Print disabled: blind, deaf-blind, low vision, obstructed vision, dyslexic, cognitively disabled and illiterate in
dividuals. Physically disabled: users have amputations, paralysis, repetitive stress, cerebral palsy, muscular dystrophy, Parkinson's or other problems limiting mobility. Hearing impaired We must also consider the increasing numbers of aging baby boomers that are beginning to experience problems with their sight, vision or dexterity. When you add all these groups of people together, that's a lot...
Accessible Toolkit Checklist
r toolkit follow the guidelines for each platform. The Approaches There are two basic kinds of toolkits, which each provide different challenges when implementing accessibility: Native widget toolkits , like Eclipse and wxWidgets, already have some accessibility built-in. These toolkits wrap the widgets implemented by the OS with a consistent API for each platform. Since the in
dividual widgets predominately come from the operating system, they already implement standard keyboard commands and follow the operating system's visual theme. Also, assistive technologies already understand native widgets so it is only necessary to implement Microsoft Active Accessibility (MSAA) API support for custom controls. However, be aware that the wrapping layer will introduce accessibility ...
Theme concepts
For example, we could use this image combined with a complementary background color, to create this effect in the header See details about this theme in the themes example weta_fade. Obviously, you can still provide a single wide image if you prefer. Multiple image themes As an alternative to creating a single image theme, you have the option to use multiple images. These images can be in
dividually anchored to locations within the header, with the option to apply tiling to each image. Depending on the effect you want to create you may need to suppress the mandatory "theme_frame": image with an empty or transparent image. You would use an empty or transparent image if, for example, you wanted to tile a centrally justified image, such as to create this effect Here you specify th...
Chrome registration
ome providers, and select a preferred skin and locale. This is accomplished through xpinstall and the extension manager. In order to inform the chrome registry of the available chrome, a text manifest is used: this manifest is "chrome.manifest" in the root of an extension, or theme, or XULRunner application. The plaintext chrome manifests are in a simple line-based format. Each line is parsed in
dividually; if the line is parsable the chrome registry takes the action identified by that line, otherwise the chrome registry ignores that line (and prints a warning message in the runtime error console). locale packagename localename path/to/files skin packagename skinname path/to/files Note: The characters @ # ; : ? / are not allowed in the packagename. Firefox 2, Thunderbird 2, and SeaMonk...
Continuous Integration
er, Mozilla's continuous integration (CI) system picks up changes pushed to Hg. TaskCluster generate binary builds for Firefox and Firefox for Android across a variety of operating sytems. After the builds are completed, they are used to run a series of correctness and performance tests. The results of TaskCluster jobs (both builds and tests) are displayed in Treeherder. There is a group of in
dividuals who are constantly monitoring Treeherder, looking for broken builds and/or tests. These in
dividuals are known as sheriffs. The sheriffs' role is to "keep the tree green", or in other words, to keep the code in our respositories in a good state, to the extent that the state is reflected in the output shown on Treeherder. When sheriffs see a build or test has been broken, they are empowere...
Cookies Preferences in Mozilla
migrated when starting the application. (The old prefs are network.cookie.lifetime.enabled, network.cookie.lifetime.behavior, and network.cookie.warnAboutCookies.) true = prefs have been migrated false = migrate prefs on next startup Original Document Information Author(s): Mike Connor Last Updated Date: May 22, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Cookies in Mozilla
o Mike Connor. Creating a Cookie Log Steps to create and attach a cookie log in order to aid in triaging a bug in cookies. Cookies Preferences in Mozilla Documentation on what the preferences used by the cookies code actually do. Original Document Information Author(s): Mike Connor Last Updated Date: March 15, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Debugging Table Reflow
eflow process is implemented inside nsBlockFrame.cpp. It can be invoked by set GECKO_BLOCK_DEBUG_FLAGS=reflow The available options are: reflow really-noisy-reflow max-element-size space-manager verify-lines damage-repair lame-paint-metrics lame-reflow-metrics disable-resize-opt These options can be combined with a comma separated list Messages generated by the reflow switch: Block(
div)(1)@00BE5AC4: reflowing dirty lines computedWidth=9000 computedHeight=1500 this message is generated inside of nsresult nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) it first shows the Block ID and Address and then the computed width and Height from the HTMLReflowState. DEBUG_TABLE_STRATEGY Editor's Note: the following examples are not shown correctly due to the wiki's techni...
Makefiles - Best practices and suggestions
NOP unless sources or dependencies change or have been removed. Incorrect dependencies will contribute to wasted cycles and can contribute to circular dependencies. Directory dependencies Do not use directories as a dependency for generated targets, ever. Any activity within a directory will alter inodes forcing targets to always be stale. For ex, in
dividual unit tests would invalidate all prior test activity whenever a test touched a timestamp file in the directory to signal success. Parallel make: add an explicit timestamp dependency (.done) that make can synchronize threaded calls on to avoid a race condition. # Transient directory for storing timestamps TS=.ts ##################################################...
Updating NSPR or NSS in mozilla-central
The NSPR and NSS sources in mozilla-central are maintained by the NSPR and NSS teams and always taken from exports of HG tags. Do not check in in
dividual changes. If you check in an in
dividual change by mistake, your change will be lost when the NSPR and NSS teams push a new HG tag to mozilla-central. (Because some developers might not be aware that NSPR/NSS are separately maintained and released, the Mozilla HG server rejects accidental changes/forking, if the required keywords are missing in the commit comment.) If NSPR or NSS must be upgraded to a new static tag, follow this procedure: Before starting, make sure your local repository is updated to mozilla-central tip and that there are no local changes: $ hg status -mard Pull the new sources $ python client.py update_ns...
Gecko Logging
ust We're gradually adding more Rust code to Gecko, and Rust crates typically use a different approach to logging. Many Rust libraries use the log crate to log messages, which works together with env_logger at the application level to control what's actually printed via RUST_LOG. You can set an overall logging level, though it could be quite verbose: set RUST_LOG="debug" You can also target in
dividual modules by path: set RUST_LOG="style::style_resolver=debug" For Linux/MacOS users, you need to use export rather than set. If you're only interested in the content process you can use RUST_LOG_CHILD rather than RUST_LOG. The log crate lists the available log levels: Log Level Purpose Rust Logging Levels error Designates very serious errors. warn ...
Contributing to the Mozilla code base
to improve this process: making Mozilla more open, accessible, and easier to participate with. If you're having any trouble following this documentation, or hit a barrier you can't get around, please contact Mike Hoye at mhoye@mozilla.com. We're determined to solve hurdles for new contributors. What skills do I need? Mozilla is a large project and we are thrilled to have contributors with very
diverse skills Below is a table with our currently available projects to contribute to, along with the skills needs and links to their documentation. Project Skills Documentation/onboarding Firefox browser (core layers) C++ Firefox developers documentation Firefox (front-end) Javascript and/or HTML/CSS Firefox developers documentation DevTools ...
Frame script environment
If you use a capturing event listener on the ContentFrameMessageManager, you should verify that its event.target is set to the ContentFrameMessageManager global object in order to avoid handling unload events from content. Does not bubble. DOMWindowCreated Fires when a new content object is created. This can be used if a framescript needs to interact with in
dividual DOM windows instead of simply listening for events bubbling up from content. Another use is to interact with the content very early in the page load process, long before DOMContentLoaded event is fired. ...
Frame script environment
i.e. when a tab gets closed. If you use a capturing event listener on the ContentFrameMessageManager, you should verify that its event.target is set to the ContentFrameMessageManager global object to avoid handling unload events from content. DOMWindowCreated Fires when a new content object is created. This can be used if a framescript needs to interact with in
dividual DOM windows instead of simply listening for events bubbling up from content. Another use is to interact with the content very early in the page load process, long before DOMContentLoaded event is fired. ...
Embedding the editor
ill instantiate more than one low-level editor. We need a concept of an "editing session" - a single top-level document which is editable, and which may embody more than one editor. This interface will be called nsI????. High-level UI and emebedding code should deal with this editing session interface, without knowledge of the underlying editors. The editing session will forward commands to the in
dividual editors depending on focus, and mediate undo/redo between them. Alternative solution: Rather than having multiple editors in this scenario, we could have a single editor, which is capable of saving and restoring state such that it can be transferred between the various subdocuments being edited. That state would have to include the document, undo stack, and typing state. The implementation...
Getting from Content to Layout
sed on whatever is optimal for the changes in the content tree. "Frame construction items" are queued for each change. These items are then examined in relation to the location in the content tree that is being modified and either the relevant frames are created/destroyed or the logic moves up to the parent frame. To give a trivial example of when this might be necessary, consider: "<span>Foo <
div></
div> Bar</span>". Separate frames are created for the pre and post-
div parts of the <span>. If the <
div> is removed, the frame construction code merges those frames by examining the parent frame, destroying the two frames created for the <span>, and creating one unified frame for the text content. Examples of this type of code are in WipeContainingBlock. This code tries hard to avoid unnece...
How to add a build-time test
DEPTH should be a relative path pointing to <tt>mozilla/</tt>, e.g. if you're in <tt>netwerk/test</tt>, set DEPTH = ../.. MODULE should be defined to test_yourmodule or just yourmodule -- either will work fine. XPCSHELL_TESTS be a list of subdirectories of the current directory which contain xpcshell tests. You can of course just use the onetests_type directory here, but if you want to sub
divide your tests by functionality, separate directories is the way to go. Reference the test dir in a parent makefile (<tt>yourmoduledir/Makefile.in</tt>): ifdef ENABLE_TESTS DIRS += tests_type endif (Optional, but recommended) Add the new makefile to allmakefiles.sh (TODO: need more details about this) Reconfigure (e.g. with <tt>make -f client.mk configure</tt>) make/make check in <tt...
Implementing QueryInterface
.. else if ( aIID.Equals(NS_GET_IID(nsISupports)) ) // ... Thanks Special thanks to Heikki Toivonen, Chris Waterson, and John Bandhauer for valuable feedback that significantly improved the implementations presented here. Original Document Information Author(s): Scott Collins Last Updated Date: May 8, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
UpdateListener
Either onUpdateAvailable() or onNoUpdateAvailable(), depending on whether a newer version of the Addon was found. ...
SourceMap.jsm
ceMapConsumer(rawSourceMap) The only parameter is the raw source map (either as a string which can be JSON.parse'd, or an object). According to the spec, source maps have the following attributes: version: Which version of the source map spec this map is following. sources: An array of URLs to the original source files. names: An array of identifiers that can be referenced by in
dividual mappings. sourceRoot: Optional. The URL root from which all sources are relative. mappings: A string of base64 VLQs which contain the actual mappings. file: The generated filename this source map is associated with. SourceMapConsumer.prototype.originalPositionFor(generatedPosition) Returns the original source, line, and column information for the generated source's lin...
Sqlite.jsm
be made. If an exception is thrown by the onRow handler, the exception is logged and processing of subsequent rows occurs as if nothing happened. The promise is still resolved (not rejected). The return promise will be rejected with an Error instance if the statement did not finish execution fully. The Error may have an errors property. If defined, it will be an Array of objects describing in
dividual errors. Each object has the properties result and message. result is a numeric error code and message is a string description of the problem. If onRow is specified, the returned promise will be resolved with a boolean indicating whether the onRow handler was called. Else, the resolved value will be an array of mozIStorageRow. executeTransaction(func, type) This function is used to execute...
Index
r work onto the Aurora repository. 34 Web Localizability Internationalization, Localizability, Localization, Web Development Localizability (or l12y for short) is a characteristic found in an application or content that enables localization. The following list contains links to pages that highlight steps that can be taken to make web content localizable. The documentation is
divided into 4 parts: 35 Creating localizable web applications Internationalization, Localizability, Localization, Web Development An important step of developing a web application or creating web content is making sure that it can be localized. Listed below are good practices and recommendations that should be followed in order to make your content easily localizable. 36 ...
Localizing extension metadata on addons.mozilla.org
AMO supports localized metadata for each extension. This data describes the extension, and doesn't necessarily change with each revision (but it can). The localizable data fields of an extension are: Name Homepage Summary Description EULA Privacy Policy Version Notes Developer Comments When you submit a new extension to AMO, the process is
divided into several steps. In step 2, you'll be asked to provide the attributes listed above in the add-on's default locale (selected in step 1). The values you provide here are used as fallback values if someone requests a language that doesn't exist. Step 4 allows you to translate any of the above fields into any other language AMO supports. Remember, all fields are optional when localizing. Any field that is blank will just show up...
Localizing with Koala
ext commit (which is indicated by the letter "A" standing in front of each new file): C:\mozilla\l10n\locale\x-testing\3.6> hg status A browser\chrome\browser\search.properties A browser\chrome\browser\searchbar.dtd You now have to commit the new files to the repository. Right-click on the browser/chrome/browser folder in the sidebar and choose "commit folder". (You could also commit each file in
dividually if you felt like it.) Koala will ask you to type in a commit message. It is a good practice to be descriptive about the changes you made in this revision. A good way of doing that is to ask yourself a question: "If I was a new person to this project and new nothing about the work already done in this repository, would this message help me understand what changes were made in this revision...
Localizing with Mozilla Translator
the ''new'' point. Your Keep Original and Fuzzy flags will be honored for each string. There will be some exceptions. Files hanging directly from the Platform neutral platform can't be part of a partial glossary (because they are not components), and Platform neutral itself can't be selected either, since it is not a component, but a platform. For these few files, you will have to export them in
dividually and reimport them. If you are a ''not so good'' MT user, however, you can just create a new product (or several ones; see next recipe to know why), run File -> Update on them (you'll get a list of all the strings) and then run Edit -> Autotranslate. Most of the strings will be automatically filled, although if you do this you should review them, because for en-US strings with several poss...
Web Localizability
How to choose the right localization format. How to create localizable web applications. How to set up the infrastructure for localization. ...
Mozilla Framework Based on Templates (MFBT)
<stdint.h> standard header is not available on all platforms and so cannot be used directly. This header also provides a useful "hook" for embeddings that must customize the types underlying the fixed-size integer types.) Types.h includes StandardInteger.h and further provides size_t. CheckedInt.h implements checked integers. They behave like integers, but safely check for integer overflow and
divide-by-zero. Useful for input validation. FloatingPoint.h provides various operations for examining and working upon double-precision floating point values, and for producing various special floating point values. Core Types.h further provides macros to define imported and exported C symbols. Attributes.h implements various function and class attribute macros. The function macros control inlin...
Mozilla MathML Project
Various MathML Tests - These pages were imported from layout/mathml/tests/. Blog with comments that include MathML. Create MathML Documents Authoring MathML Editors Converters Stylesheets Original Document Information Author(s): Roger B. Sidje Other Contributors: Frederic Wang Last Updated Date: April 4, 2010 Copyright Information: Portions of this content are (C) 1999-2010 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Using the viewport meta tag to control layout on mobile browsers
tial-scale property controls the zoom level when the page is first loaded. The maximum-scale, minimum-scale, and user-scalable properties control how users are allowed to zoom the page in or out. Usage of user-scalable=no can cause accessibility issues to users with visual impairments such as low vision. A pixel is not a pixel In recent years, screen resolutions have risen to the size that in
dividual pixels are hard to distinguish with the human eye. For example, recent smartphones generally have a 5-inch screens with resolutions upwards of 1920--1080 pixels (~400 dpi). Because of this, many browsers can display their pages in a smaller physical size by translating multiple hardware pixels for each CSS "pixel". Initially this caused usability and readability problems on many touch-optimi...
Mozilla DOM Hacking Guide
echniques Scriptable Helper flags This chapter has not been written yet. If you want to help please contact me! Security features implementation This chapter has not been written yet. If you want to help please contact me! Original Document Information Author(s): Fabian Guisset Last Updated Date: September 27, 2007 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Mozilla Port Blocking
the user to decide if the blocking is really required. Some kind of way to manage the ports which are blocked. More Information nsIOService.cpp gbadPortList bug 83401 Vulnerability Note VU#476267 dougt@netscape.com Original Document Information Author(s): Doug Turner Last Updated Date: August 15, 2007 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Mozilla Development Tools
ng to use CVS. Doctor lets you edit pages in WYSIWYG mode if the pages contain the <?doctor enable_wysiwyg_mode ?> processing instruction. Access Doctor by clicking the "Edit this Page" link at the bottom of any mozilla.org web page. Original Document Information Author(s): Myk Melez Last Updated Date: November 8, 2005 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Mozilla Style System Documentation
ations Problems: Some of the HTML style information is implemented in the content node classes. It should be consolidated so that the style system code can be moved back within the layout DLL and nsIStyleContext can be de-COM-ified. Original Document Information Author(s): L. David Baron Last Updated Date: June 6, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
BloatView
am exit, and each time nsTraceRefcnt::DumpStatistics is called. This log contains data on leaks and bloat (a.k.a. usage). XPCOM_MEM_LEAK_LOG This is similar to XPCOM_MEM_BLOAT_LOG, but restricts the log to only show data on leaks. You can set these environment variables to any of the following values. 1 - log to stdout. 2 - log to stderr. filename - write log to a file. Reading in
dividual bloat logs Full BloatView output contains per-class statistics on allocations and refcounts, and provides gross numbers on the amount of memory being leaked broken down by class. Here's a sample of the BloatView output. == BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS, tab process 1862 |<----------------Class--------------->|<-----Bytes------>|<----Objects---->| | ...
Gecko Profiler FAQ
e "after" profile> minus <number of samples under this stack in the "before" profile>. That tree is then displayed in the usual way, with weights in decreasing order from top to bottom. Then the call stacks whose cost increased the most in the "after" profile will be at the top, and those are the ones you usually want to look at if you caused a regression. In this view, the timestamps of in
dividual samples / stacks will not be meaningful. profiler.firefox.com does not have a comparison view at the moment. I can help you add one, though. There is documentation for the Gecko profile format. Is it worth slowing down CPU to increase the profiler resolution? It depends on what you are trying to profile to some extent. Usually you shoul...
Leak-hunting strategies and tips
This document is old and some of the information is out-of-date. Use with caution. Strategy for finding leaks When trying to make a particular testcase not leak, I recommend focusing first on the largest object graphs (since these entrain many smaller objects), then on smaller reference-counted object graphs, and then on any remaining in
dividual objects or small object graphs that don't entrain other objects. Because (1) large graphs of leaked objects tend to include some objects pointed to by global variables that confuse GC-based leak detectors, which can make leaks look smaller (as in bug 99180) or hide them completely and (2) large graphs of leaked objects tend to hide smaller ones, it's much better to go after the large graphs of leaks first. A good general pattern for find...
Memory reporting
commonly bytes, but sometimes a unitless count or percentage); a description of what is measured. See the nsIMemoryReporter documentation and nsIMemoryReporter.idl for full details. Making Measurements nsIMemoryReporter provides the high-level interface for a memory reporter, but the heart of a memory reporter is the measurement of the "amount". Two Ways to Measure Memory reporters can be
divided into the two following kinds. Traversal-based reporters traverse one or more data structures and measure the size of all the allocated blocks in the data structure. Counter-based reporters maintain a counter that is incremented on each relevant allocation and decremented on each relevant deallocation. Traversal-based reporters are preferable, for the following reasons. They are less ...
Power profiling overview
r the first time. Basic physics concepts In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. In SI units, energy is measured in Joules, and power is measured in Watts, which is equivalent to Joules per second. Although power is an instantaneous concept, in practice measurements of it are determined in a non-instantaneous fashion, i.e. by
dividing an energy amount by a non-infinitesimal time period. Strictly speaking, such a computation gives the average power but this is often referred to as just the power when context makes it clear. In the context of computing, a fully-charged mobile device battery (as found in a laptop or smartphone) holds a certain amount of energy, and the speed at which that stored energy is depleted depends o...
Profiling with the Firefox Profiler
ou're interested in) must be profiled. For example, on B2G, when profiling the Homescreen app, you might start the profiler with: ./profile.sh start -p b2g -t Compositor && ./profile.sh start -p Homescreen Having gotten a profile this way, the layer tree for a composite can be seen by clicking on a composite in the "Frames" section of Cleopatra (you may need to a sub-range of samples to make in
dividual composites large enough to be clicked). This will activate the "LayerTree" tab: In this screenshot, Composite #143 has been selected. The layer tree structure can be seen in the left panel. It contains, for each layer, the type of the layer, and various metrics about the layer, such as the visible region and any transforms. In the right panel, a visualization of the layer tree (based enti...
about:memory
+--3.39 MB (12.66%) -- element-nodes | +--1.56 MB (05.84%) -- text-nodes | +--0.54 MB (02.03%) -- other | +--0.10 MB (00.36%) ++ (4 tiny) +---0.06 MB (00.21%) -- property-tables Some of the trees in this section measure things that do not cross-cut the measurements in the "explicit" tree, such as those in the "preference-service" example above. Finally, at the end of this section are in
dividual measurements, as the following example shows. 0.00 MB -- canvas-2d-pixels 5.38 MB -- gfx-surface-xlib 0.00 MB -- gfx-textures 0.00 MB -- gfx-tiles-waste 0 -- ghost-windows 109.22 MB -- heap-allocated 164 -- heap-chunks 1.00 MB -- heap-chunksize 114.51 MB -- heap-committed 164.00 MB -- heap-mapped 4.84% -- heap-overhead-ratio 1 -- h...
tools/power/rapl
.08 + 1.58) + 3.42 W #10 8.13 W = 4.40 ( 1.55 + 0.11 + 2.74) + 3.73 W Things to note include the following. All measurements are in Watts. The first line indicates the meaning of each column. The underscores in _pkg_, _gpu_ and _ram_ are present so that each column's name has five characters. The total power is the sum of the package power and the RAM power. The package estimate is
divided into three parts: cores, GPU, and "other". "Other" is computed as the package power minus the cores power and GPU power. If the processor does not support GPU or RAM estimates then " n/a " will be printed in the relevant column instead of a number, and it will contribute zero to the total. Once sampling is finished -- either because the user interrupted it, or because the requested number ...
Profile Manager
ion's name as an argument, for example: profilemanager-bin seamonkey Profiles and application versions Profile Manager manages two different lists: one of user profiles, and the other of application versions that can be used with the profiles. By default, this means it tracks a list of Firefox applications that are installed on your system, and a list of profiles for use by Firefox. An in
dividual profile can be linked to a specific installation of Firefox, so that version of Firefox will be launched when that profile is selected. For example, ProfileA might be linked with a copy of Firefox 3.6.10, while ProfileB might be linked with a copy of Firefox 3.5.3. When launched, Profile Manager will look in some default locations for installed versions of Firefox (or other application you...
L20n
s software localization. Users should be able to benefit from the entire expressive power of the natural language. L20n keeps simple things simple, and at the same time makes complex things possible. Through L20n, Mozilla is creating a new generation of technology that places more power in localizers' hands. L20n lets localizers reach higher levels of free linguistic expression by sharpening the
divide between localization and application logic. It allows to adapt your web application not only to languages and cultures, but also contextual data, user gender and screen dimensions. What L20n looks like Here is a simple, straightforward example showing an English string being provided: <brandName "Firefox"> <about "About {{ brandName }}"> Here is the same string being provided in Slovenia...
Midas
fontsize A number This command will set the fontsize for a selection or at the insertion point if there is no selection. The given number is such as would be used in the "size" attribute of the font tag. forecolor A color code This command will set the text color of the selection or at the insertion point. formatblock H1, H2, H3, H4, H5, H6, P,
DIV, ADDRESS, BLOCKQUOTE (more?) The selection surrounded by the given block element. heading H1, H2, H3, H4, H5, H6 Selected block will be formatted as the given type of heading. hilitecolor A color code This command will set the hilite color of the selection or at the insertion point. It only works with styleWithCSS enabled. increasefontsize This com...
Creating a Cookie Log
cookie-log.txt file to the bug where it was requested (by clicking on Create New Attachment). It should be in C:\temp on Windows, your home directory on Linux, or the Desktop on Mac OS X. Thanks for helping us make Firefox better! Original Document Information Author(s): Mike Connor Last Updated Date: December 4, 2004 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Interval Timing
trative action). The counters have no fixed epoch and have a finite period. To make use of these counters, the application must declare a point in time, the epoch, and an amount of time elapsed since that epoch, the interval. In almost all cases the epoch is defined as the value of the interval timer at the time it was sampled. ...
PR_Calloc
Allocates zeroed memory from the heap for a number of objects of a given size. Syntax #include <prmem.h> void *PR_Calloc ( PRUint32 nelem, PRUint32 elsize); Parameters nelem The number of elements of size elsize to be allocated. elsize The size of an in
dividual element. Returns An untyped pointer to the allocated memory, or if the allocation attempt fails, NULL. Call PR_GetError() to retrieve the error returned by the libc function malloc(). Description This function allocates memory on the heap for the specified number of objects of the specified size. All bytes in the allocated memory are cleared. ...
FIPS Mode - an explanation
ord to use his own private keys (if he has any) or to access his stored web-site passwords. The user is not required to enter the master password to visit ordinary https servers, nor to view certificates he has previously stored. In non-FIPS mode, NSS is willing and able to use popular non-FIPS approved cryptographic algorithms, such as RC4 and MD5, to communicate with older https servers. NSS
divides its operations up into two "devices" rather than just one. One device does all the operations that may be done without needing to authenticate, and the other device stores the user's certificates and private keys and performs operations that use those private keys. How do I put Firefox into FIPS Mode? Instructions for how to configure Firefox into FIPS mode may be found on support.mozilla.
HTTP delegation
SEC_HttpServer_FreeSessionFcn). Should the application be unable to keep a physical connection alive all the time, the application is expected to create new connections automatically. NSS may choose to repeatedly call a "network connection keep alive" function (SEC_HttpServer_KeepAliveSessionFcn) on the server session object, giving application code a chance to do whatever is required. For each in
dividual HTTP request, NSS will request the creation of a "http request object" (SEC_HttpRequest_CreateFcn). No full URI is provided as a parameter. Instead, the parameters are a server session object (that carries host and port information already) and the request path. In our example the path is "/cgi-bin/ocsp-responder". (When issueing GET requests, the "?query-string=data" portion should already ...
HTTP delegation
SEC_HttpServer_FreeSessionFcn). Should the application be unable to keep a physical connection alive all the time, the application is expected to create new connections automatically. NSS may choose to repeatedly call a "network connection keep alive" function (SEC_HttpServer_KeepAliveSessionFcn) on the server session object, giving application code a chance to do whatever is required. For each in
dividual HTTP request, NSS will request the creation of a "http request object" (SEC_HttpRequest_CreateFcn). No full URI is provided as a parameter. Instead, the parameters are a server session object (that carries host and port information already) and the request path. In our example the path is "/cgi-bin/ocsp-responder". (When issuing GET requests, the "?query-string=data" portion should already b...
NSS 3.19.2.4 release notes
No new functionality has been introduced in this release. Security Fixes in NSS 3.19.2.4 The following security fixes from NSS 3.21 have been backported to NSS 3.19.2.4: Bug 1185033 / CVE-2016-1979 - Use-after-free during processing of DER encoded keys in NSS Bug 1209546 / CVE-2016-1978 - Use-after-free in NSS during SSL connections in low memory Bug 1190248 / CVE-2016-1938 - Errors in mp_
div and mp_exptmod cryptographic functions in NSS Compatibility NSS 3.19.2.4 shared libraries are backward compatible with all older NSS 3.x shared libraries. A program linked with older NSS 3.x shared libraries will work with NSS 3.19.2.4 shared libraries without recompiling or relinking. Furthermore, applications that restrict the use of NSS APIs to the functions listed in NSS Public Functions w...
PKCS11 FAQ
of these functions, and NSS uses those versions under certain conditions. However, these are not the services NSS calls to get to other PKCS #11 modules, which show up separately under Cryptographic Modules. Our plugin provides several slots with different capabilities. For example, one does all the hashing/symmetric operations, while another does only asymmetric RSA operations. Can this kind of
division lead to problems? The only issue is dealing with keys. For example, if the RSA slot unwraps a key, NSS needs to move that key to a slot that can do the symmetric operations. NSS itself uses two tokens internally--one that provides generic cryptographic services without authentication, and one that provides operations based on the keys stored in the user's database and do need authentication...
NSS functions
Keywords: Deprecated - function should no longer be used. Updated - function has new arguments such as new flag or addition to structure. SSL functions The public functions listed here are used to configure sockets for communication via the SSL and TLS protocols. In addition to the functions listed here, applications that support SSL use some of the Certificate functions, Crypto functions, and Utility functions described below on this page. ...
NSS tools : pk12util
y) Ltd. ID Encryption algorithm: PKCS #12 V2 PBE With SHA-1 And 3KEY Triple DES-CBC Parameters: Salt: 45:2e:6a:a0:03:4d:7b:a1:63:3c:15:ea:67:37:62:1f Iteration Count: 1 (0x1) Certificate: Data: Version: 3 (0x2) Serial Number: 13 (0xd) Signature Algorithm: PKCS #1 SHA-1 With RSA Encryption Issuer: "E=personal-freemail@thawte.com,CN=Thawte Personal Freemail C A,OU=Certification Services
Division,O=Thawte Consulting,L=Cape T own,ST=Western Cape,C=ZA" Alternatively, the -r prints the certificates and then exports them into separate DER binary files. This allows the certificates to be fed to another application that supports .p12 files. Each certificate is written to a sequentially-number file, beginning with file0001.der and continuing through file000N.der, incrementing the numb...
sslerr.html
d." The remote system has received a certificate from the local system, and has determined that the certificate has expired. SSL_ERROR_SSL_DISABLED -12268 "Cannot connect: SSL is disabled." The local socket is configured in such a way that it cannot use any of the SSL cipher suites. Possible causes include: (a) both SSL2 and SSL3 are disabled, (b) All the in
dividual SSL cipher suites are disabled, or (c) the socket is configured to handshake as a server, but the certificate associated with that socket is inappropriate for the Key Exchange Algorithm selected. SSL_ERROR_FORTEZZA_PQG -12267 "Cannot connect: SSL peer is in another FORTEZZA domain." The local system and the remote system are in different FORTEZZA domains. They mu...
sslintro.html
an application to import a socket into SSL after the TCP connection on that socket has already been established. In this case, initial configuration takes place in the same way: pass the existing NSPR file descriptor to SSL_ImportFD and perform any additional configuration that has not already been determined by the model file descriptor. Configuration functions control the configuration of an in
dividual socket. PR_GetSocketOption. Retrieves the socket options currently set for a specified socket. Optional. PR_SetSocketOption. Sets the socket options for a specified socket., including making it blocking or nonblocking. Optional. SSL_OptionSet. Sets a single configuration parameter of a specified socket. This function must be called once for each parameter whose settings you want t...
NSS Tools certutil
the command without options, or with the -H option. Options and Arguments Options specify an action and are uppercase. Option arguments modify an action and are lowercase. Certificate Database Tool command options and their arguments are defined as follows: Options -N Create new certificate and key databases. -S Create an in
dividual certificate and add it to a certificate database. -R Create a certificate-request file that can be submitted to a Certificate Authority (CA) for processing into a finished certificate. Output defaults to standard out unless you use -ooutput-file argument. Use the -a argument to specify ASCII output. -C Create a new binary certificat...
NSS tools : pk12util
Alternatively, the -r prints the certificates and then exports them into separate DER binary files. This allows the certificates to be fed to another application that supports .p12 files. Each certificate is written to a sequentially-number file, beginning with file0001.der and continuing through file00...
Multithreading in Necko
this way, Necko takes advantage of the platforms specific routines for DNS lookups. The default implementation does not spawn a worker thread, and instead simply calls PR_GetIPNodeByName (essentially equivalent to gethostbyname). Original Document Information Author(s): Darin Fisher Last Updated Date: December 10, 2001 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Proxies in Necko
configuration is used and "<local>" is added to the "No proxy for:" text field field. To be written XXX missing paragraphs are about PAC, and more details about HTTP proxying, and maybe some more details about SOCKS proxies. Original Document Information Author(s): Christian Biesinger Last Updated Date: April 8, 2005 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
SpiderMonkey compartments
untrusted website such as "evil.com". Only a special object type can cross the compartment boundaries. We call these objects cross-compartment wrappers. SpiderMonkey tracks the creation of these cross-compartment wrappers and thus it knows at all times what objects from a compartment are kept alive by outside references (through cross-compartment wrappers). This allows the garbage collecting of in
dividual compartments, in addition to global collection. SpiderMonkey simply assumes that all objects referenced from outside the compartment are live, and then walks the object graph inside the compartment. Objects that are found to be disconnected from the graph are discarded. With this new per-compartment garbage collection we shortcut having to walk unrelated heap areas of a window or tab that tr...
GCIntegration - SpiderMonkey Redirect 1
s possible, avoid trace hooks. If objects are structured as described above, there should be no need for them. This should be obvious by now, but never ever allow a GC thing point to a GC thing in a different compartment unless it's a wrapper that's registered in the cross-compartment wrapper map. Now, on to the details... GC/CC interaction <To be done later.> Incremental GC Incremental GC
divides GC marking into time slices. In between these slices, non-GC code is allowed to run. Done naively, this technique can lead to reachable object not being marked. Consider the following example. {{ Svg{source: "http://people.mozilla.org/~wmccloskey/incremental1.svg", embedding: "iframe", height:"130"} }} Assume object B is already marked, as in the leftmost frame, while objects A and C have n...
Bytecode Descriptions
the top value from the other one, and push the result. The conversion can call .toString()/.valueOf() methods and can throw. On success, the result is always numeric. Format: JOF_IC Inc, Dec Stack: val => (val +/- 1) Add or subtract 1. val must already be a numeric value, such as the result of JSOp::ToNumeric. Implements: The ++ and -- operators, step 3 of each algorithm. Format: JOF_IC Mul,
Div, Mod Stack: lval, rval => (lval OP rval) The multiplicative operators (*, /, %). Pop two values, convert them to numeric values, do math, and push the result. The conversion can call .toString()/.valueOf() methods and can throw. On success, the result is always numeric. Format: JOF_IC Pow Stack: lval, rval => (lval ** rval) The exponentiation operator (**). Pop two values, convert them to num...
Garbage collection
t wrappers are used as roots for single- and multi-compartment GCs. Compartments are a fundamental cross-cutting concept in SpiderMonkey (see also Compartments), though anything related to memory is now more concerned with Zones, especially GC. Zone A zone is a collection of compartments. Zones mainly serve as boundaries for GCs: the garbage collector collects at the level of a zone, not an in
dividual compartment. Unlike compartments, zones have no special security properties. Some properties of zones are: Every compartment belongs to exactly one zone Every JS heap object belongs to exactly one zone. Objects from the same zone but different compartments can share an arena. Objects from different zones cannot be stored in the same arena. A zone remains alive as long as any JS heap ...
JSAPI Cookbook
ject. /* JSAPI */ bool found; assert(y.isObject()); JS::RootedObject yobj(cx, &y.toObject()); if (!JS_HasProperty(cx, yobj, "myprop", &found)) return false; if (found) { // then do something } Defining a constant property This is the first of three examples involving the built-in function Object.defineProperty(), which gives JavaScript code fine-grained control over the behavior of in
dividual properties of any object. You can use this function to create a constant property, one that can't be overwritten or deleted. Specify writable: false to make the property read-only and configurable: false to prevent it from being deleted or redefined. The flag enumerable: true causes this property to be seen by for-in loops. // JavaScript Object.defineProperty(obj, "prop", {value: 123, ...
JSAPI User Guide
ient-Side JavaScript Guide and the Server-Side JavaScript Guide. Embed the appropriate JS engine call(s) in your application to compile and execute the script. You have two choices: 1.) compile and execute a script with a single call to JS_EvaluateScript, JS_EvaluateUCScript or 2.) compile the script once with a call to JS_CompileScript or JS_CompileUCScript, and then execute it repeatedly with in
dividual calls to JS_ExecuteScript. The "UC" versions of these calls provide support for Unicode-encoded scripts. An object you create using a script only can be made available only during the lifetime of the script, or can be created to persist after the script completes execution. Ordinarily, once script execution is complete, its objects are destroyed. In many cases, this behavior is just what y...
JS::CallArgs
ed after rval() has been used! JS::HandleValue calleev() const Returns the function being called, as a value. Must not be called after rval() has been used! JS::HandleValue thisv() const Returns the this value passed to the function. This method must not be called when the function is being called as a constructor via new. The value may or may not be an object: it is the in
dividual function's responsibility to box the value if needed. JS::Value computeThis(JSContext *cx) const Returns the this value if this is an object, otherwise calls JS_ComputeThis and returns it. bool isConstructing() const Returns true if the function is called via new. MutableHandleValue rval() const Returns the currently-set return value. The initial cont...
JSFunctionSpec
onSpec defines the attributes for a single JS function to associate with an object. An application typically has an array of JSFunctionSpec to define all the functions for an object and calls JS_DefineFunctions or JS_InitClass to create the functions and assign them to an object. JSFunctionSpec can also be used to define an array element rather than a named property. Array elements are actually in
dividual properties. To define an array element, cast the element's index value to const char*, initialize the name field with it, and specify the JSPROP_INDEX attribute in flags. To define an array of JSPropertySpec, use JS_FS, JS_FN, JS_SYM_FN, JS_FNINFO, JS_SELF_HOSTED_FN, JS_SELF_HOSTED_SYM_FN, JS_SYM_FNSPEC, JS_FNSPEC, and JS_FS_END. See Also MXR ID Search for JSFunctionSpec JSPropertySpec J...
JSObjectOps.getProperty
orted API. Details of the API may change from one release to the next. This documentation should be considered SpiderMonkey internals documentation, not API documentation. See bug 408416 for details. JSObjectOps.getProperty, setProperty, and deleteProperty are high-level callbacks that implement object property accesses. Each of these callbacks is responsible for everything involved with an in
dividual property access operation, including: any locking necessary for thread safety; security checks; finding the property, including walking the prototype chain if needed; calling the lower-level JSClass hooks; calling getters or setters; and actually getting, setting, or deleting the property once it is found. Contrast JSClass.getProperty, JSClass.setProperty, and JSClass.delProperty, which are...
JSPropertyOp
the assignment as strict mode code. vp JS::MutableHandleValue In/out parameter. Points to a JS::Value variable. The meaning of this variable is different for each of the hooks; see below. Description JSPropertyOp and JSStrictPropertyOp callbacks are hooks that applications may install to be called at some point during property access. A JSPropertyOp may be installed on an in
dividual property as a getter or setter; or it may be installed on a JSClass to hook property gets, sets, or adds. These different cases are described in more detail in the sections below. If a JSPropertyOp or JSStrictPropertyOp does nothing and returns true, then property get, set, or add is unaffected. It proceeds as normal. Each of these callbacks may veto the ongoing property operation by optio...
JS_DefineFunctions
tion cx JSContext * The context in which to define functions. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext. obj JS::Handle<JSObject*> The object on which functions are to be defined. fs const JSFunctionSpec * A NULL-terminated array of function specifications. Each element of the array defines an in
dividual function. behavior PropertyDefinitionBehavior See below. Added in SpiderMonkey 38 enum PropertyDefinitionBehavior { DefineAllProperties, OnlyDefineLateProperties, DontDefineLateProperties }; Name Description DefineAllProperties Define all properties regardless of their flags. OnlyDefineLateProperties Define only properti...
JS_GetPositiveInfinityValue
ity. JS_GetNegativeInfinityValue returns the corresponding negative infinity. Infinities are typically used to represent numbers that are greater in magnitude than the greatest representable finite values. As a value in mathematical calculations, an infinite value behaves like infinity. For example, any nonzero value multiplied by infinity is infinity with the expected sign, and any finite value
divided by infinity is zero (again with the expected sign). To get a floating-point NaN, use JS_GetNaNValue. See Also MXR ID Search for JS_GetPositiveInfinityValue MXR ID Search for JS_GetNegativeInfinityValue JS_GetNaNValue bug 1184564 -- Changed jsval to JS::Value ...
JS_SetOptions
ptions); Name Type Description cx JSContext * A context on which to set options. options uint32 The new set of options. This is the logical OR of zero or more flags described below. Description JS_SetOptions sets the option flags of a given JS context cx. This function returns a uint32 value containing the previous values of the flags. ...
SpiderMonkey 31
types, such as JS::Value or JS::Value*, to JS::Handle and JS::MutableHandle template types that encapsulate access to the provided value/string/object or its location. The JS::Handle<JS::Value> and JS::MutableHandle<JS::Value> classes have been specialized to implement the same interface as JS::Value, for simplicity and to ease migration pain. Changes to introduce handles to the JSAPI are not in
dividually documented, because of the breadth of the changes involved. The following features in earlier versions of SpiderMonkey have been dropped. XXX list removed features here SpiderMonkey 31 is not binary-compatible with previous releases, nor is it source-code compatible. Many JSAPI types, functions, and callback signatures have changed, though most functions that have changed still have ...
SpiderMonkey 38
types, such as JS::Value or JS::Value*, to JS::Handle and JS::MutableHandle template types that encapsulate access to the provided value/string/object or its location. The JS::Handle<JS::Value> and JS::MutableHandle<JS::Value> classes have been specialized to implement the same interface as JS::Value, for simplicity and to ease migration pain. Changes to introduce handles to the JSAPI are not in
dividually documented, because of the breadth of the changes involved. The following features in earlier versions of SpiderMonkey have been dropped. XXX list removed features here SpiderMonkey 38 is not binary-compatible with previous releases, nor is it source-code compatible. Many JSAPI types, functions, and callback signatures have changed, though most functions that have changed still have ...
Shell global objects
ry allocations 8: (IncrementalRootsThenFinish) Incremental GC in two slices: 1) mark roots 2) finish collection 9: (IncrementalMarkAllThenFinish) Incremental GC in two slices: 1) mark all 2) new marking and finish 10: (IncrementalMultipleSlices) Incremental GC in multiple slices 11: (IncrementalMarkingValidator) Verify incremental marking 12: (ElementsBarrier) Always use the in
dividual element post-write barrier, regardless of elements size 13: (CheckHashTablesOnMinorGC) Check internal hashtables on minor GC 14: (Compact) Perform a shrinking collection every N allocations 15: (CheckHeapAfterGC) Walk the heap to check its integrity after every GC 16: (CheckNursery) Check nursery integrity on minor GC schedulegc([num | obj]) If num is given, schedule ...
Zest
be defined by the tools that integrate Zest. It is completely free, open source and can be included in any tool whether open or closed, free or commercial. Zest is still at a very early stage of development, but is has been made available so that anyone can play around with it. All constructive feedback is very welcome. Anyone can contribute to the onward development of Zest, and teams or in
dividuals who develop security tools are especially welcome to join and help shape Zest's future. Zest topics Usecases Reporting security vulnerabilities to developers Reporting security vulnerabilities to companies Defining active and passive scanner rules Deep integration with security tools Runtimes The runtime environments that support Zest Tools The tools that incl...
Handling Mozilla Security Bugs
about the bug by posting it to channels outside the context of the Mozilla project. By not doing so, and by instead choosing to report bugs through the standard Bugzilla processes, the bug reporter is doing a positive service to the Mozilla project; thus it makes sense that the bug reporter should be able to decide when the relevant Bugzilla data should be made public. However, we will ask all in
dividuals and organizations reporting security bugs through Bugzilla to follow the voluntary guidelines below: Before making a security bug world-readable, please provide a few days notice to the Mozilla security bug group by sending an email to the private security bug group mailing list. Please try not to keep bugs in the security-sensitive category for an unreasonably long amount of time. Ple...
Mork
n be used. The API that is presented is simple. You pass in a file to ParseFile, select the tables, and then pass in callback functions for the meta-row and row enumeration functions. GetTableIDs is provided for convenience's sake, and is mostly expected to be used only by the morkreader tests. All data stored internally will be destroyed when the MorkReader goes out of scope. More detail about in
dividual functions can be found by reading the documentation included in MorkReader.h. There is in the test directory a program called TestMorkReader. If you wish to just display a mork file, most of the code in this file can be copied to display it to you. ...
Places utilities for JavaScript
move folders or links. Return type Returns an object implementing nsITransaction that can perform the move/insert. getFolderContents() getFolderContents(aFolderId, aExcludeItems, aExpandQueries) Generates a nsINavHistoryResult for the contents of a folder. Parameters folderId The folder to open [optional] excludeItems True to hide all items (in
dividual bookmarks). This is used on the left places pane so you just get a folder hierarchy. [optional] expandQueries True to make query items expand as new containers. For managing,you want this to be false, for menus and such, you want this to be true. Return type Returns a nsINavHistoryResult containing the contents of the folder. The result.root is guaranteed to be open. Bookmark Dialog M...
XML Extras
ove exist in extensions/xmlextras/tests/. More exhaustive test suites need to be created, however. If you'd like to help out with QA, you can do one of the following: Sign up as the QA owner for any of the implemented components. The QA owner will manage the tests associated with their component, act as QA contact for related bugs and help with regression testing. Contribute a test suite or in
dividual tests that use the implemented components. File bugs for new test you have, and/or check them into extensions/xmlextras/tests/. File bugs against the implemented components. Bugs should be filed against the XML component in the Browser product. Documentation Probably the best way to learn how to use these technologies is through examples. There are some in extensions/xmlextras/tests/. If...
Accessing the Windows Registry Using XPCOM
sumes the existence of the readRegistryValue() function defined above. Removing Registry Keys and Values To remove child keys and values from the registry, you can use the removeChild() and removeValue() methods. removeChild() removes a child key and all of its values, but will fail if the key has any child keys of its own. In that case you must manually enumerate the children and remove them in
dividually. This example shows how to recursively delete a registry key and all of its children. Use with caution! function removeChildrenRecursive(wrk) { // we count backwards because we're removing them as we go for (var i = wrk.childCount - 1; i >= 0; i--) { var name = wrk.getChildName(i); var subkey = wrk.openChild(name, wrk.ACCESS_ALL); removeChildrenRecursive(subkey); sub...
Packaging WebLock
Gecko is necessarily brief. For more detailed information on packaging and installation of components into Gecko-based applications, see http://www.mozilla.org/projects/xpinstall. Component Installation Overview XPInstall is a set of JavaScript APIs for creating installation scripts. Using XPInstall, you can create web-based installations for Gecko-based applications, Mozilla extensions, or in
dividual components. The installation script for the WebLock component can also be used to register the component with the browser into which it is installed (see Registration Methods in XPCOM for more information on registration). The sample installation script shown below uses the Mozilla XPInstall technology to manipulate an installer and talk to Mozilla'schrome registry as high-level JavaScript ...
Preface
plications. Though the emphasis is on the practical steps you take to make your C++ code into a component that can be used in Gecko, we hope that these steps will also give us an occasion to discuss all of the tools, techniques, and technologies that make up XPCOM. Accordingly, the book is arranged so that you can follow along and create your own components or learn about different XPCOM topics in
dividually, as in a reference work. For example, the introduction includes a discussion of components and what they are, and the first chapter - in which you compile the basic code and register it with Mozilla - prompts a discussion of the relationship between components and modules, of XPCOM interfaces, and of the registration process in general. The top of each chapter provides a list of the major...
Setting up the Gecko SDK
meaningfully. The two top level header files are special. The file mozilla-config.h lists all of the defines used in the SDK. Including this header file in your project ensures that the component you create uses the same defines as the Gecko libraries themselves. Note that mozilla-config.h may be need to be included before other includes in your component's source code. Each module directory is
divided into three subdirectories: Module Subdirectories The bin directory contains static libraries, dynamic libraries, and in some cases tools that may be useful in development. The idl directory contains the public IDL files exported by the module. The includes directory contains C++ header files used by your component. XPCOM exports a number of binaries that should be mentioned at this point...
Using XPCOM Components
for use when the user or administrator clicks the weblock icon in the browser's user interface. Component Use in Mozilla So how are components obtained and used in Mozilla? You've seen some enticing snippets of JavaScript in earlier sections of this chapter, but we haven't explained how XPCOM makes components available in general. This section discusses practical component use in Mozilla. It's
divided into three subsections: one about actually finding all these binary components in Mozilla and two others corresponding to the two main ways that clients typically access XPCOM components: Finding Mozilla Components This book attempts to provide reference information for XPCOM components and their interfaces that are frozen as of the time of this writing. The Mozilla embedding project tracks...
Creating XPCOM components
plications. Though the emphasis is on the practical steps you take to make your C++ code into a component that can be used in Gecko, we hope that these steps will also give us an occasion to discuss all of the tools, techniques, and technologies that make up XPCOM. Accordingly, the book is arranged so that you can follow along and create your own components or learn about different XPCOM topics in
dividually, as in a reference work. For example, the introduction includes a discussion of components and what they are, and the first chapter - in which you compile the basic code and register it with Mozilla - prompts a discussion of the relationship between components and modules, of XPCOM interfaces, and of the registration process in general. Note: In general, you should try to avoid having to...
XPCShell Reference
-v command-line argument for more information. quit(exitCode) quit() exits the shell. You can specify arguments that will get translated to an exit code. quit(5) will exit XPCShell with a result code of 5. Original Document Information Author: David Bradley <dbradley@netscape.com> Last Updated Date: 17 March 2003 Copyright Information: Portions of this content are (C) 1998-2008 by in
dividual mozilla.org contributors; content available under a Creative Commons license. ...
mozIStorageConnection
NTEGER, bar STRING". Exceptions thrown NS_ERROR_FAILURE Table already exists or the requested table couldn't be created. executeAsync() Asynchronously executes an array of queries created with this connection, using any currently bound parameters. The statements are run wrapped in a transaction. Note: The statements may be reused immediately, and the statements do not need to be reset in
dividually. mozIStoragePendingStatement executeAsync( [array, size_is(aNumStatements)] in mozIStorageBaseStatement aStatements, in unsigned long aNumStatements, in mozIStorageStatementCallback aCallback Optional ); Parameters aStatements The array of statements to execute asynchronously. They will be executed sequentially, in the order in which they appear in the array. Prior to Gecko 2.
nsIAccessibleDocument
1.9 docType AString The doc type of the document, as specified in the document. Read only. DOMDocument nsIDOMDocument The nsIDOMDocument interface associated with this document. Read only. Note: Renamed from document in Gecko 2.0 isEditable boolean True if the document is live in an editor. False if the document is being displayed but not edited. If a <
div> is contentEditable, then it has its own document, with isEditable == true. Read only. Obsolete since Gecko 1.9 mimeType AString The mime type of the document. Read only. title AString The title of the document, as specified in the document. Read only. URL AString The URL of the document Read only. window nsIDOMWindow The nsIDOMWindow th...
nsIArray
Inherits from: nsISupports Last changed in Gecko 1.7 An indexed collection of elements. Provides basic functionality for retrieving elements at a specific position, searching for elements. Indexes are zero-based, such that the last element in the array is stored at the index length-1. For an array which can be modified, see nsIMutableArray. Neither interface makes any attempt to protect the in
dividual elements from modification. The convention is that the elements of the array should not be modified. Documentation within a specific interface should describe variations from this convention. It is also convention that if an interface provides access to an nsIArray, that the array should not be QueryInterfaced to an nsIMutableArray for modification. If the interface in question had intended ...
nsIBrowserHistory
Page( in nsIURI aURI ); Parameters aURI The page that is to be marked as currently open. removeAllPages() This method removes all the pages from the global history. void removeAllPages(); Parameters None. Remarks Visits are removed synchronously, but pages are expired asynchronously, off the main thread. Note: Removals are handled in a batch. Single removals are not subject to in
dividual notification; instead, nsINavHistoryObserver.onClearHistory() is called on the history observer. removePage() This method removes all visits for a page from the history. The page itself is only deleted when it is not bookmarked and when it is not a place: URI. This method is called by the UI when the user deletes a history entry. Note: If removing fewer than 10 pages, calling this repeate...
nsICookieManager
aName, in AUTF8String aPath, in boolean aBlocked, in jsval aOriginAttributes); void removeAll(); Attributes Attribute Type Description enumerator nsISimpleEnumerator Called to enumerate through each cookie in the cookie list. The objects enumerated over are of type nsICookie. Read only. Methods remove() This method is called to remove an in
dividual cookie from the cookie list, specified by host, name, and path. If the cookie cannot be found, no exception is thrown. Typically, the arguments to this method will be obtained directly from the desired nsICookie object. void remove( in AUTF8String aHost, in ACString aName, in AUTF8String aPath, in boolean aBlocked, in jsval aOriginAttributes ); Parameters aHost The host or d...
nsIDOMHTMLAudioElement
Array or as a numeric typed array. Return value The actual number of bytes written to the stream. Exceptions thrown NS_ERROR_DOM_INVALID_STATE_ERR The stream has not been initialized for writing by a call to mozSetup(). NS_ERROR_DOM_TYPE_MISMATCH_ERR The data isn't a valid data type (an array or typed array of numeric values). NS_ERROR_DOM_INDEX_SIZE_ERR The number of samples specified doesn't
divide evenly across the number of channels; you must provide exactly the same number of samples for all channels. ...
nsIDOMXULElement
. ref DOMString Gets/sets the value of the element's ref attribute. resource nsIRDFResource Read only. Returns the nsIRDFResource corresponding to the element's ref or id attribute, if any. statusText DOMString Gets/sets the value of the element's statustext attribute. style nsIDOMCSSStyleDeclaration Read only. Obsolete since Gecko 1.9 Returns an object that may be used to read or write in
dividual CSS style properties for the element. tooltip DOMString Gets/sets the value of the element's tooltip attribute. tooltipText DOMString Gets/sets the value of the element's tooltiptext attribute. top DOMString Gets/sets the value of the element's top attribute. width DOMString Gets/sets the value of the element's width attribute. Methods blur() Attempts to remove focus from the elem...
getFile
nsIFile getFile( in string aName, out boolean aPersistent ); Parameters aName [in] The symbolic name for a file or directory location. See Symbolic names below for a list of accepted values. ...
nsIDownloadManager
aDownload A download to pass to the manager window. Useful if, for example, you want the window to select a certain download. openProgressDialogFor() Obsolete since Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. Opens an in
dividual progress dialog displaying progress for the download. void openProgressDialogFor( in nsIDownload aDownload, in nsIDOMWindow aParent, in boolean aCancelDownloadOnClose ); Parameters aDownload The download object to display progress for, as returned by getDownload() or addDownload(). aParent The parent, or opener, of the front end. aCancelDownloadOnClose Whether closing the di...
nsIEffectiveTLDService
o Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1), this method worked if you passed host strings starting with a period ("."). That is no longer the case, since these are not valid host names. You should strip leading periods off host names before passing them to this method. getPublicSuffix() Returns the public suffix of a URI. A public suffix is the highest-level domain under which in
dividual domains may be registered; it may therefore contain one or more dots. For example, the public suffix for www.bbc.co.uk is co.uk. Likewise, the public suffix for developer.mozilla.org is org. ACString getPublicSuffix( in nsIURI aURI ); Parameters aURI The URI to be analyzed. Return value An ACString containing the public suffix. Exceptions thrown NS_ERROR_INVALID_ARG This exc...
nsIEventListenerInfo
stener is in the system event group. Read only. type AString The type of the event for which the listener was added. Read only. Methods getDebugObject() Returns the debugger object if the debug service is active. nsISupports getDebugObject(); Parameters None. Return value If jsdIDebuggerService is active and the listener is implemented in JS, this returns the listener as a js
dIValue. Otherwise null. This is the method you should use if you want to get access to the actual listener, but the debugger service must be already active, which significantly slows down script execution. Accordingly, this should probably only be used by real debuggers. This approach is necessary because event listeners added with addEventListener won't necessarily be nsIEventListeners; the DOM cod...
nsIFilePicker
sions. Application files for the user's platform will pass through the filter. filterAllowURLs 0x80 Allow URLs. filterAudio 0x100 Corresponds to the *.aac, *.aif, *.flac, *.iff, *.m4a, *.m4b, *.mid, *.midi, *.mp3, *.mpa, *.mpc, *.oga, *.ogg, *.ra, *.ram, *.snd, *.wav and *.wma filters for file extensions. filterVideo 0x200 Corresponds to the *.avi, *.
divx, *.flv, *.m4v, *.mkv, *.mov, *.mp4, *.mpeg, *.mpg, *.ogm, *.ogv, *.ogx, *.rm, *.rmvb, *.smil, *.webm, *.wmv and *.xvid filters for file extensions. Methods appendFilter() Appends a custom file extension filter to the dialog. The filter appended first will be used to display the nsIFilePicker dialog, the user may then select another from the list. void appendFilter( in AString title,...
nsIJetpack
erReceiver() for a particular message. void unregisterReceivers( in AString aMessageName ); Parameters aMessageName The name of the message to unregister all callbacks from. evalScript() This asynchronously sends code to the Jetpack process for evaluation. The code will be evaluated using at least JavaScript 1.8.1. When evaluated, the script's global scope will include all privileged APIs. In
dividual lines of the form //@line 1 "foo.js" can be used to specify filename and line number information for debugging purposes. void evalScript( in AString aScript ); Parameters aScript The full contents of the script to evaluate in the Jetpack process. createHandle() This creates an opaque handle that can transparently be exchanged between processes. nsIVariant createHandle(); Parameters Non...
nsIJumpListBuilder
fox 4 / Thunderbird 3.3 / SeaMonkey 2.1) Jump lists are built and then applied. Modifying an applied jump list is not permitted. Callers should begin the creation of a new jump list using initListBuild(), add sub lists using addListToBuild(), then commit the jump list using commitListBuild(). Lists are built in real-time during the sequence of build calls, make sure to check for errors on each in
dividual step. The default number of allowed items in a jump list is ten. Users can change the number through system preferences. User may also pin items to jump lists, which take up additional slots. Applications do not have control over the number of items allowed in jump lists; excess items added are dropped by the system. Item insertion priority is defined as first to last added. Users may remove...
Using nsILoginManager
o( hostname, formSubmitURL, httprealm, username, password, usernameField, passwordField ); Examples Creating a login for a web page var formLoginInfo = new nsLoginInfo( 'http://www.example.com', 'http://login.example.com', null, 'joe', 'SeCrEt123', 'uname', 'pword' ); This login would correspond to a HTML form such as: <form action="http://login.example.com/foo/authenticate.cgi"> <
div>Please log in.</
div> <label>Username:</label> <input type="text" name="uname"> <label>Password:</label> <input type="password" name="pword"> </form> Creating a site authentication login var authLoginInfo = new nsLoginInfo( 'http://www.example.com', null, 'ExampleCo Login', 'alice', 'SeCrEt321', "", "" ); This would correspond to a login on http://www.example.com when the server send...
nsIMarkupDocumentViewer
bidiOptions PRUint32 Use this attribute to access all the Bidi options in one operation. bidiSupport octet Whether to use platform bidi support or Mozilla's bidi support 1 - Use Mozilla's bidi support 2 - Use the platform bidi support 3 - Disable bidi support. bidiTextDirection octet Options for Bidi presentation. Use these attributes to access the in
dividual Bidi options. The default direction for the layout of bidirectional text. 1 - left to right 2 - right to left. bidiTextType octet The ordering of bidirectional text. This may be either "logical" or "visual". Logical text will be reordered for presentation using the Unicode Bidi Algorithm. Visual text will be displayed without reordering. 1 - the default order for the chars...
nsIMemoryReporter
urred since the application started up. For example, the number of times the user has opened a new tab. The amount returned must never decrease over the lifetime of the application. UNITS_PERCENTAGE 3 The amount contains a fraction that should be expressed as a percentage. Note: The amount field should be given a value 100 times the actual percentage; this number will be
divided by 100 when shown. This allows a fractional percentage to be shown even though amount is an integer. For example if the actual percentage is 12.34%, amount should be 1234. See also nsIMemoryReporterManager ...
nsINavHistoryObserver
d was removed in Gecko 2.0. Use onDeleteVisits() instead. Called when a history entry expires. This notification is sent to indicate that a specific visit has expired, and includes the time of that visit. When the last visit for a history entry expires, the history entry itself is deleted and the aWholeEntry parameter is true. If your code only cares about whole entries being deleted instead of in
dividual visits, you can simply act only when aWholeEntry is true. It's possible for a history entry to be deleted even though it has no visits if something is out of sync after a bookmark with no visits is deleted; this results in the entire history entry being freed). In such cases, aVisitTime is 0. void onPageExpired( in nsIURI aURI, in PRTime aVisitTime, in boolean aWholeEntry ); Parameter...
nsIPropertyElement
Inherits from: nsISupports Last changed in Gecko 1.0 Attributes Attribute Type Description key AUTF8String The key used to refer to this property. ...
nsISHistory
x of the last document that started to load that is not yet finished loading. When the document finishes loading the value -1 is returned. Read only. SHistoryEnumerator nsISimpleEnumerator Called to obtain a enumerator for all the documents stored in session history. The enumerator object thus returned by this method can be traversed using nsISimpleEnumerator. To access in
dividual history entries of the enumerator, perform the following steps: Call GetSHistoryEnumerator() to obtain handle the nsISimpleEnumerator object. Use nsISimpleEnumerator.GetNext() on the object returned by step #1 to obtain handle to the next object in the list. The object returned by this step is of type nsISupports. Perform a QueryInterface on the object returned by step #2...
Frequently Asked Questions
This section will help you if you're fixing a broken build, or have what you think is a quick obvious question, and you don't have time to read the Reference Manual. This FAQ usually just refers back directly to the appropriate answer, there. If you're looking here just to learn about nsCOMPtrs, you'll get a better introduction in the Getting Started Guide. The FAQ is
divided into sections to help you find what you're looking for faster. In most cases, the answer will just refer back into the reference manual, above. No need to explain things twice :-). Buildtime Errors The build just broke. It's not in your code, or it's not on your platform, but there's an nsCOMPtr on the line where the error is and you're suspicious. You're looking in the right place. comparing an nsCOMPtr to a...
Using nsCOMPtr
ess Compiler Annoyances Frequently Asked Questions Buildtime Errors Runtime Errors How do I... General Bibliography Original Document Information Author(s): Scott Collins Last Updated Date: December 11, 2001 Copyright Information: Copyright (C) 1999, 2000 by the Mozilla organization; use is subject to the MPL. Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Using nsIClassInfo
s calling QueryInterface unnecessary. It just happens. How do I make my C++ class implement nsIClassInfo? See nsIClassInfoImpl.h for instructions. How does nsIClassInfo work? That's also detailed in nsIClassInfoImpl.h. Original Document Information Authors: Mike Shaver, Justin Lebar Last Updated Date: July 25, 2011 Copyright Information: Portions of this content are (C) 1998-2011 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Using nsIDirectoryService
file, just construct it and call its Initialize method - it will register itself. Again, if you do this, do not initialize the profile service - it's either one or the other. Related Pages Code_snippets:File_I/O Original Document Information Authors: Conrad Carlen, Doug Turner Last Updated Date: September 26, 2000 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
Weak reference
, and avoid using it in cases where it might dangle. See also The source xpcom/base/nsIWeakReference.idl xpcom/glue/nsWeakReference.h xpcom/glue/nsWeakReference.cpp XPCOM ownership guidelines Using nsCOMPtr Original Document Information Author: Scott Collins Last Updated Date: September 23, 2000 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
MailNews fakeserver
omponents are specific to the protocol type and found under similar files in the same directory (e.g., smtpd.js). A daemon is information about the server that can be manipulated. An example of such a manipulation is adding a folder or adding messages. Daemons should usually persist for the entirety of the test. The handler is the glue between the server and the daemon. This area will be the most
diverse of all components, as edge cases with quirky servers being liberal with the specs will require different handlers. Writing a new fakeserver Since the number of protocols we use is very small, most people shouldn't have to write an entirely new daemon and handler setup by themselves. That said, someone writing a new test may have to take into account a new handler. A handler will contain the...
Mail event system
. For example, when a folder gets a new message, its total message count increases. The folder pane needs to know that this changed so that it can update the message count so the user can see it. Interfaces The key interfaces here are: nsIFolder.idl is an interface for storing a hierarchy of objects with properties. This interface is not (should not be) mail-related. nsIFolders each store in
dividual lists of folder listeners which are maintained with addListener() and removeListener(). When a notification is fired on a folder, all of the folder's folder listeners and the mail session itself is notified. nsIFolderListener.idl is an interface that an object can implement if it is interested in listening to changes on single folder or on all folders. If the object just needs to be notifie...
URLs - Plugins
nternet hosts for file download. gopher (Gopher protocol) Locates specified items on a Gopher server. Obsolete since Gecko 2.0 http (Hypertext Transfer Protocol) Locates resources on the Internet. javascript Executes JavaScript code that follows the URL. Netscape-specific. mailto (Electronic mail address) Locates the Internet mailing address of an in
dividual or service. nethelp Displays a NetHelp topic in a NetHelp window. Browser-specific. news (USENET news) Locates USENET news groups or in
dividual USENET articles. nntp (USENET news using nntp access) Locates USENET news groups or in
dividual USENET articles; alternate to news. prospero (Prospero Directory Service) Locates a resource on a Prospero ...
Accessibility Inspector - Firefox Developer Tools
-- this is done via the accessibility APIs available inside web browsers, which expose information on what roles the different elements on your page play (e.g., are they just text, or are they buttons, links, form elements, etc.?). Semantic DOM elements have roles assigned to them by default that hint at what their purpose is. Sometimes, however, you need to use some non-semantic markup (e.g., <
div>s) to build a complex custom control, and the control won't have a default role that reflects its purpose. In such a situation, you can use WAI-ARIA role attributes to provide your own roles. Roles and other information exposed by browser accessibility APIs are presented in a hierarchical structure called the accessibility tree. This is a bit like the DOM tree, except that it contains a more lim...
DOM Inspector FAQ - Firefox Developer Tools
nts from the DOM Inspector UI. You can, however, find any rule in its parent style sheet (e.g., to modify it) by using the Style Sheets viewer in the document pane, and locating it in the CSS Rules viewer in the object pane. Original Document Information Author(s): Christopher Aillon Last Updated Date: November 11, 2003 Copyright Information: Portions of this content are (C) 1998-2007 by in
dividual mozilla.org contributors; content available under a Creative Commons license | Details. ...
DOM Inspector internals - Firefox Developer Tools
utton allowing you to issue viewer-specific commands. Viewers are dynamically loaded; when the panel is made to switch from one viewer to another, the old viewer is destroyed, and the new viewer is loaded in its place. In this way, the panelset and panels function like a frameset and frames. This comparison turns out to be quite apt, since each panel actually contains an anonymous browser, and in
dividual viewers exist in separate documents loaded in the browser. This separation allows for viewers to be self-contained, with a viewer's XUL defined in its own document and loaded in its own scope, without fear of collisions in the XUL, CSS, or JS. Another convenient consequence of this is that if you use a properly set up development profile, then for the most part, the effects of development ch...
Introduction to DOM Inspector - Firefox Developer Tools
ental searching by way of the <F3> shortcut key. Updating the DOM Dynamically Another feature to mention in this introduction is the ability is the ability the DOM Inspector gives you to dynamically update information reflected in the DOM about web pages, user interface, and other elements. Note that when the DOM Inspector displays information about a particular node or subtree, it presents in
dividual nodes and their values (in the DOM, attributes are subnodes of elements, typically) in an active list. You can perform actions on the in
dividual items in this list from the context menu and the Edit menu, both of which contain menutimes that allow you edit the values of those attributes. This interactivity allows you to shrink and grow element size, change icons, and do other layout-tweak...
Debugging service workers - Firefox Developer Tools
the cache, and then fill it again. The Firefox DevTools' Storage tab has a Cache Storage section that lists all the different Caches you have stored under each different origin. Right/Ctrl clicking on one of the caches gives you two options: Delete All -- delete all caches under this origin. Delete "name of cache" -- delete only the highlighted cache. You can also click on one of the in
dividual items stored in the cache, then Right/Ctrl click on it to get options for deleting just that item, or every item in the cache. These options make it much easier to remove a cache if it is required for testing a code update. It is also worth knowing that if you are testing an app's offline capabilities, you'll be able to see whether requests are being retrieved from a service worker-initiat...
Browser Toolbox - Firefox Developer Tools
pages using the normal Debugger, just as if they were ordinary content pages. Targeting a document In the normal toolbox, there's a button in the toolbar enabling you to target specific iframes in the document. The same button appears in the browser toolbox where it lists all the top-level chrome and content windows as well as any iframes they contain. This enables you to inspect documents in in
dividual chrome windows and popups, as well as in content tabs. For example, here's what the frame selection popup lists when there are two browser windows open, one with one content tab, and one with two: Debugging popups It's hard to debug popups, because the browser hides them as soon as you click outside them. There is a way to disable this behavior. Click the toolbox menu and select Disab...
UI Tour - Firefox Developer Tools
oaded into the page, and enables you to select one to debug. At the top level sources are organized by origin, and under that they're organized by the directory structure from which they are served. You can search for a file using Ctrl + P (Cmd + P on a Mac). Web Extensions are listed in the Source List pane using the extension's name. There are several context menu options available for in
dividual files and folders or groups; typically viewed by right-clicking on the item. For files, the following context menu options are available: Copy source URI copies the full identifier of the file to the clipboard. Ignore source causes the debugger to skip the file when "stepping into" functions; this can be helpful for avoiding stepping into libraries used by your code. When a file is ig...
Aggregate view - Firefox Developer Tools
ed in a function at line 35 of "alloc.js", or in functions called by that function We can use the disclosure triangle to drill down the call tree, to find the exact place your code made those allocations. It's easier to explain this with reference to a simple example. For this we'll use the DOM allocation example. This page simply runs a script that creates a large number of DOM nodes (200 HTML
DivElement objects and 4000 HTMLSpanElement objects). Let's get an allocation trace: open the Memory tool check "Record call stacks" load https://mdn.github.io/performance-scenarios/dom-allocs/alloc.html take a snapshot select "View/Aggregate" select "Group by/Call Stack" You should see something like this: This is telling us that 93% of the total heap snapshot was allocated in functi...
Dominators view - Firefox Developer Tools
e keeping the given node from being garbage-collected. If you suspect that an object is being leaked, this will show you exactly which objects are holding a reference to it. To see the retaining paths for a node, you have to select the node in the Dominators Tree panel: Here, we've selected an object, and can see a single path back to a GC root. The Window GC root holds a reference to an HTML
DivElement object, and that holds a reference to an Object, and so on. If you look in the Dominators Tree panel, you can trace the same path there. If either of these references were removed, the items below them could be garbage-collected. Each connection in the graph is labeled with the variable name for the referenced object. Sometimes there's more than one retaining path back from a node: He...
Network request list - Firefox Developer Tools
mns command is available on the context menu to reset the columns to their initial configuration. You can also change the width of the columns to help make the information you are looking for easier to view. The mouse pointer changes to a resize icon when you move it over the border of a column. You can drag to manually set the size of column. Starting in Firefox 76 you can double-click a column
divider to resize the column to the left of it to fit its contents. The Reset Columns command on the context menu also resets the width of the columns to the default values. Clicking the column header label sorts the request list by that column. You can reset the sort to the default by selecting "Reset Sorting" from the context menu. Here is a list of all available columns: Status: The HTTP...
Network Monitor - Firefox Developer Tools
ests, the display looks like this: When it is actively monitoring activity, the Network Monitor records network requests any time the Toolbox is open, even if the Network Monitor itself is not selected. This means you can start debugging a page in, for example, the Web Console, then switch to the Network Monitor to see network activity without having to reload the page. ...
Edit fonts - Firefox Developer Tools
tor If the inspected element uses a variable font, the Fonts tab shows the axes that have been implemented for that particular font, providing control to alter the value of each one. This is very useful for quickly finding out what axes are available in a particular font -- they can vary quite dramatically as font designers can implement basically anything they like. You can adjust the axes in
dividually or, if the font designer has included defined instances, you can select one from the "Instance" drop-down list and view the updates live on your page. Here are a couple of examples of fonts with different axes defined: In the following example, you can see that the font "Cheee Variable" includes settings for Yeast and Gravity. These are custom axes defined by the font designer. The ...
Examine and edit the box model - Firefox Developer Tools
Viewing the box model With the Select Element button pressed, if you hover over an element in the page, the box model for the element is shown overlaid on the page: It's also shown overlaid if you hover over an element's markup in the HTML pane: If the element is inline and is split over multiple line boxes, the highlighter shows each in
dividual line box that together make up the element: The Box Model view When an element's selected, you can get a detailed look at the box model in the Box Model view: If you hover over a value, you'll see a tooltip telling you which rule the value comes from: If you hover over part of the box model in the Box Model view, the corresponding part of the page is highlighted: Editing the box model You can also edit the values in the Bo...
Work with animations - Firefox Developer Tools
nting Firefox Developer Edition. If you click the icon, it enlarges and changes to color, and the name of the browser appears. Click the icon again to reverse the effect. These animations are made using the Web Animations API. Let's use the animation inspector to see what's going on in this example. Right-click in the box and select "Inspect Element" Make sure the selected element is the <
div class="channel"> Switch over to the "Animations" tab Play the animation Let's take a closer look at the contents of the animation inspector here: It shows a synchronized timeline for every animation applied to the selected element or its children. The timeline starts at the start of the first animation, ends at the end of the last animation, and is labeled with markers every 250 millisec...
Waterfall - Firefox Developer Tools
So if you see a sign of a performance problem - a drop in the frame rate, for example - you can go to the Waterfall to see what the browser was doing at that point in the recording. Along the X-axis is time. ...
Shader Editor - Firefox Developer Tools
r" in the "Default Firefox Developer Tools" item. You'll now see "Shader Editor" appear in the toolbar. Click it and the Shader Editor opens. At first you'll just see a blank window with a button asking you to reload the page: To get started, load a page which creates a WebGL context and loads a program into it. The screenshots below are from the Unreal Engine demo. You'll now see a window
divided into three panes: a list of all the GLSL programs on the left, the vertex shader for the currently selected program in the middle, and the fragment shader for the currently selected program on the right: Managing programs The left hand pane lists all programs currently in use by a WebGL context. If you hover over an entry in the list, the geometry drawn by that program is highlighted in r...
Style Editor - Firefox Developer Tools
iated with a page create new stylesheets from scratch and apply them to the page import existing stylesheets and apply them to the page To open the Style Editor choose the "Style Editor" option from the "Web Developer" menu (which is a submenu in the "Tools" menu on the Mac). The Toolbox will appear at the bottom of the browser window, with the Style Editor activated: The Style Editor is
divided into three main sections: the style sheet pane on the left the editor on the right the media sidebar. The style sheet pane The style sheet pane, on the left, lists all the style sheets being used by the current document. You can quickly toggle the use of a given sheet on and off by clicking the eyeball icon to the left of the sheet's name. You can save any changes you've made to the s...
View Source - Firefox Developer Tools
ML Source If you context-click while the mouse is over some MathML, you'll see a context menu item labeled "View MathML Source": click it to see the MathML source. Limitations of View Source There are limitations to what View Source does for you that you need to be aware of. Error reporter != validator View Source only reports parsing errors, not HTML validity errors. For example, putting a <
div> element as a child of a <ul> element isn't a parse error, but it is not valid HTML. Therefore, this error will not be flagged in View Source. If you want to check that HTML is valid, you should use an HTML validator, such as the one offered by W3C. Not all parse errors are reported Even though all the reported errors are parse errors according to the HTML specification, not all parse errors ar...
AddressErrors.regionCode - Web APIs
d in the PaymentAddress object's regionCode property could not be validated, this property contains a DOMString offering a human-readable explanation of the validation error and offers suggestions for correcting it. If the regionCode value was validated successfully, this property is not included in the AddressErrors object. Usage notes The region code is derived from the ISO 3166-2 country sub
division name standard. Specifications Specification Status Comment Payment Request APIThe definition of 'AddressErrors.regionCode' in that specification. Candidate Recommendation Initial definition. ...
Animation.startTime - Web APIs
s value to make the animation start at a different time. Examples In the Running on Web Animations API example, the we can sync all new animated cats by giving them all the same startTime as the original running cat: var catRunning = document.getElementById ("withWAAPI").animate(keyframes, timing); /* A function that makes new cats. ...
AudioContext.createMediaElementSource() - Web APIs
o manipulate. Returns A MediaElementAudioSourceNode. Example This simple example creates a source from an <audio> element using createMediaElementSource(), then passes the audio through a GainNode before feeding it into the AudioDestinationNode for playback. When the mouse pointer is moved, the updatePage() function is invoked, which calculates the current gain as a ratio of mouse Y position
divided by overall window height. You can therefore increase and decrease the volume of the playing music by moving the mouse pointer up and down. Note: You can also view this example running live, or view the source. var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); var myAudio = document.querySelector('audio'); var pre = document.querySelector('pre'); var myScript = docum...
AudioTrack - Web APIs
uffer Read only The SourceBuffer that created the track. Returns null if the track was not created by a SourceBuffer or the SourceBuffer has been removed from the MediaSource.sourceBuffers attribute of its parent media source. Usage notes To get an AudioTrack for a given media element, use the element's audioTracks property, which returns an AudioTrackList object from which you can get the in
dividual tracks contained in the media: var el = document.querySelector("video"); var tracks = el.audioTracks; You can then access the media's in
dividual tracks using either array syntax or functions such as forEach(). This first example gets the first audio track on the media: var firstTrack = tracks[0]; The next example scans through all of the media's audio tracks, enabling any that are in t...
AudioTrackList - Web APIs
Properties This interface also inherits properties from its parent interface, EventTarget. length Read only The number of tracks in the list. ...
BaseAudioContext.createChannelSplitter() - Web APIs
Syntax baseAudioContext.createChannelSplitter(numberOfOutputs); Parameters numberOfOutputs The number of channels in the input audio stream that you want to output separately; the default is 6 if this parameter is not specified. Returns A ChannelSplitterNode. Example The following simple example shows how you could separate a stereo track (say, a piece of music), and process the left and right channel differently. ...
BaseAudioContext.createDynamicsCompressor() - Web APIs
thod of the BaseAudioContext Interface is used to create a DynamicsCompressorNode, which can be used to apply compression to an audio signal. Compression lowers the volume of the loudest parts of the signal and raises the volume of the softest parts. Overall, a louder, richer, and fuller sound can be achieved. It is especially important in games and musical applications where large numbers of in
dividual sounds are played simultaneously, where you want to control the overall signal level and help avoid clipping (distorting) of the audio output. Syntax baseAudioCtx.createDynamicsCompressor(); Returns A DynamicsCompressorNode. Example The below code demonstrates a simple usage of createDynamicsCompressor() to add compression to an audio track. For a more complete example, have a look at ...
CSSNumericValue - Web APIs
icArray CSSPerspective CSSPositionValue CSSRotate CSSSkew CSSSkeyX CSSSkeyW CSSTranslate CSSUnitValue Properties None. Event handlers No Methods CSSNumericValue.add Adds a supplied number to the CSSNumericValue. CSSNumericValue.sub Subtracts a supplied number from the CSSNumericValue. CSSNumericValue.mul Multiplies the CSSNumericValue by the supplied value. CSSNumericValue.
div Divides the CSSNumericValue by the supplied value. CSSNumericValue.min Returns the minimum value passed CSSNumericValue.max Returns the maximum value passed CSSNumericValue.equals True if all the values are the exact same type and value, in the same order. Otherwise, false. CSSNumericValue.to Converts value into another one with the specified unit. CSSNumericValue.toSum TBD CSSNumeric...
CSSPositionValue.CSSPositionValue() - Web APIs
The CSSPositionValue constructor creates a new CSSPositionValue object which represents values for properties that take a position, for example object-position. Syntax cvar cssPositionValue = new CSSPositionValue(x, y) Parameters x A position along the web page's horizontal axis. y A position along the web page's vertical axix. Examples The following example positions a container <
div> 5 pixels from the top and 10 pixels from the left of the page. let some
Div = document.getElementById('container'); let position = new CSSPositionValue(CSS.px(5), CSS.px(10)); some
Div.attributeStyleMap.set('object-position', position); console.log(position.x.value, position.y.value); // 5 10 ...
CSSPositionValue.x - Web APIs
The x property of the CSSPositionValue interface returns returns the item's position along the web page's horizontal axis. Syntax var x = CSSPositionValue.x Value A CSSNumericValue. Example The following example positions a container <
div> 5 pixels from the top and 10 pixels from the left of the page. let some
Div = document.getElementById('container'); let position = new CSSPositionValue(CSS.px(5), CSS.px(10)); some
Div.attributeStyleMap.set('object-position', position); console.log(position.x.value, position.y.value); ...
CSSPositionValue.y - Web APIs
The y property of the CSSPositionValue interface returns the item's position along the vertical axis. Syntax var y = CSSPositionValue.y Value A CSSNumericValue. Example The following example positions a container <
div> 5 pixels from the top and 10 pixels from the left of the page. let replaceEl = document.getElementById('container'); let position = new CSSPositionValue(CSS.px(5), CSS.px(10)); some
Div.attributeStyleMap.set('object-position', position); console.log(position.x.value, position.y.value); ...
CSSPositionValue - Web APIs
erties that take a position, for example object-position. Constructor CSSPositionValue.CSSPositionValue() Creates a new CSSPositionValue object. Properties CSSPositionValue.x Returns the item's position along the web page's horizontal axis. CSSPositionValue.y Returns the item's position along the vertical axis. Methods None. Examples The following example positions a container <
div> 5 pixels from the top and 10 pixels from the left of the page. let replacedEl = document.getElementById( 'image' ); let position = new CSSPositionValue( CSS.px(35), CSS.px(40) ); replacedEl.attributeStyleMap.set( 'object-position', position ); console.log( position.x.value, position.y.value ); console.log( replacedEl.computedStyleMap().get('object-position') ); We set the object-position pro...
CSSPrimitiveValue.getRectValue() - Web APIs
ng the Rect interface. Syntax var rectValue = cssPrimitiveValue.getRectValue(); Return value A Rect object representing the rect value. Exceptions Type Description DOMException An INVALID_ACCESS_ERR is raised if the CSS value doesn't contain a Rect value. (i.e. this is not CSS_RECT). Example var cs = window.getComputedStyle(document.getElementById("clipped
Div")); var cssValue = cs.getPropertyCSSValue("clip"); console.log(cssValue.getRectValue()); Specifications Specification Status Comment Document Object Model (DOM) Level 2 Style SpecificationThe definition of 'CSSPrimitiveValue.getRectValue' in that specification. Obsolete Initial definition ...
CSSStyleDeclaration.item() - Web APIs
propertyName = style.item(index); Parameters index is the index of the node to be fetched. The index is zero-based. Return value propertyName is a DOMString that is the name of the CSS property at the specified index. JavaScript has a special simpler syntax for obtaining an item from a NodeList by index: var propertyName = style[index]; Example var style = document.getElementById('
div1').style; var propertyName = style.item(1); // or simply style[1] - returns the second style listed Specifications Specification Status Comment CSS Object Model (CSSOM)The definition of 'CSSStyleDeclaration.item()' in that specification. Working Draft Document Object Model (DOM) Level 2 Style SpecificationThe definition of 'CSSStyleDeclaration' in th...
CSSStyleDeclaration.length - Web APIs
The read-only property returns an integer that represents the number of style declarations in this CSS declaration block. Syntax var num = styles.length; Value An integer that provides the number of styles explictly set on the parent of the instance. Example The following gets the number of explicitly set styles on the following HTML element: <
div id="
div1" style="margin: 0 10px; background-color: #CA1; font-family: monospace"></
div> JavaScript code: var my
Div = document.getElementById('
div1'); var
divStyle = my
Div.style; var len =
divStyle.length; // 6 Specifications Specification Status Comment CSS Object Model (CSSOM)The definition of 'CSSStyleDeclaration.length' in that specification. Working Draft Document Object Model (DOM) Level 2...
CSSStyleSheet.cssRules - Web APIs
which provides a real-time, up-to-date list of every CSS rule which comprises the stylesheet. Each item in the list is a CSSRule defining a single rule. Syntax var rules = cssStyleSheet.cssRules; Value A live-updating CSSRuleList containing each of the CSS rules making up the stylesheet. Each entry in the rule list is a CSSRule object describing one rule making up the stylesheet. ...
CSSStyleSheet - Web APIs
Another rule might be an at-rule such as @import or @media, and so forth. See the Notes section for the various ways a CSSStyleSheet object can be obtained. Properties Inherits properties from its parent, StyleSheet. cssRules Read only Returns a live CSSRuleList which maintains an up-to-date list of the CSSRule objects that comprise the stylesheet. This is normally used to access in
dividual rules like this: styleSheet.cssRules[i] // where i = 0..cssRules.length-1 To add or remove items in cssRules, use the CSSStyleSheet's insertRule() and deleteRule() methods. ownerRule Read only If this stylesheet is imported into the document using an @import rule, the ownerRule property returns the corresponding CSSImportRule; otherwise, this property's value is null. Methods Inh...
CSSUnitValue.CSSUnitValue() - Web APIs
a new CSSUnitValue object which represents values that contain a single unit type. For example, "42px" would be represented by a CSSNumericValue. Syntax var CSSUnitValue = new CSSUnitValue() Parameters value Returns a double indicating the number of units. unit Returns a USVString indicating the type of unit. Examples The following shows a method of creating a CSSPositionValue from in
dividual CSSUnitValue constructors. let pos = new CSSPositionValue( new CSSUnitValue(5, "px"), new CSSUnitValue(10, "px")); Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSUnitValue' in that specification. Working Draft Initial definition. ...
CSSUnitValue.unit - Web APIs
The CSSUnitValue.unit read-only property of the CSSUnitValue interface returns a USVString indicating the type of unit. Syntax var aString = CSSUnitValue.unit; Value A USVString. Examples The following creates a CSSPositionValue from in
dividual CSSUnitValue constructors, then queries the CSSUnitValue.unit. let pos = new CSSPositionValue( new CSSUnitValue( 5, "px" ), new CSSUnitValue( 10, "em" )); console.log( pos.x.unit ); // "px" console.log( pos.y.unit ); // "em" Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSUnitValue.unit' in that specification. Working Draft Initial definition. ...
CSSUnitValue.value - Web APIs
The CSSUnitValue.value property of the CSSUnitValue interface returns a double indicating the number of units. Syntax var cssUnitValue = CSSUnitValue.value; CSSUnitValue.value = cssUnitValue; Value A double. Examples The following creates a CSSPositionValue from in
dividual CSSUnitValue constructors, then queries the CSSUnitValue.value. let pos = new CSSPositionValue( new CSSUnitValue( 5, "px" ), new CSSUnitValue( 10, "px" )); console.log( pos.x.value ); // 5 console.log( pos.y.value ); // 10 Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSUnitValue.value' in that specification. Working Draft Initial definition. ...
CSSUnitValue - Web APIs
px" would be represented by a CSSNumericValue. Constructor CSSStyleValue.CSSUnitValue() Creates a new CSSUnitValue object. Properties CSSUnitValue.value Returns a double indicating the number of units. CSSUnitValue.unit Returns a USVString indicating the type of unit. Event handlers None. Methods None. Examples The following shows a method of creating a CSSPositionValue from in
dividual CSSUnitValue constructors. let pos = new CSSPositionValue( new CSSUnitValue(5, "px"), new CSSUnitValue(10, "px")); Specifications Specification Status Comment CSS Typed OM Level 1The definition of 'CSSUnitValue' in that specification. Working Draft Initial definition. ...
CanvasPattern.setTransform() - Web APIs
support DOMMatrix as an input to setTransform(), so for example you could replace the SVGMatrix in the above example with the following: const matrix = new DOMMatrix([1, .2, .8, 1, 0, 0]); Edit the code below and see your changes update live in the canvas: Playable code <canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas> <svg id="svg1" style="display:none"></svg> <
div class="playable-buttons"> <input id="edit" type="button" value="Edit" /> <input id="reset" type="button" value="Reset" /> </
div> <textarea id="code" class="playable-code" style="height:120px"> var img = new Image(); img.src = 'https://mdn.mozillademos.org/files/222/Canvas_createpattern.png'; img.onload = function() { var pattern = ctx.createPattern(img, 'repeat'); pattern.setTransform(mat...
CanvasRenderingContext2D.drawImage() - Web APIs
t is zero. INVALID_STATE_ERR The image has no image data. TYPE_MISMATCH_ERR The specified source element isn't supported. NS_ERROR_NOT_AVAILABLE The image is not loaded yet. Use .complete === true and .onload to determine when it is ready. Examples Drawing an image to the canvas This example draws an image to the canvas using the drawImage() method. HTML <canvas id="canvas"></canvas> <
div style="display:none;"> <img id="source" src="https://udn.realityripple.com/samples/db/f374e9c6fc.jpg" width="300" height="227"> </
div> JavaScript The source image is taken from the coordinates (33, 71), with a width of 104 and a height of 124. It is drawn to the canvas at (21, 20), where it is given a width of 87 and a height of 104. const canvas = document.getElementById('can...
CanvasRenderingContext2D.scrollPathIntoView() - Web APIs
canvas> JavaScript const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.fillRect(10, 10, 30, 30); ctx.scrollPathIntoView(); Edit the code below to see your changes update live in the canvas: Playable code <canvas id="canvas" width="400" height="200" class="playable-canvas"> <input id="button" type="range" min="1" max="12"> </canvas> <
div class="playable-buttons"> <input id="edit" type="button" value="Edit" /> <input id="reset" type="button" value="Reset" /> </
div> <textarea id="code" class="playable-code"> ctx.beginPath(); ctx.rect(10, 10, 30, 30); ctx.scrollPathIntoView();</textarea> var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); var textarea = document.getElementById("code"); var reset ...
CanvasRenderingContext2D.setTransform() - Web APIs
nsform matrix, it multiplies it with a given one. Syntax ctx.setTransform(a, b, c, d, e, f); ctx.setTransform(matrix); The transformation matrix is described by: [acebdf001]\left[ \begin{array}{ccc} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{array} \right] Parameters setTransform() has two types of parameter that it can accept. The older type consists of several parameters representing the in
dividual components of the transformation matrix to set: a (m11) Horizontal scaling. A value of 1 results in no scaling. b (m12) Vertical skewing. c (m21) Horizontal skewing. d (m22) Vertical scaling. A value of 1 results in no scaling. e (dx) Horizontal translation (moving). f (dy) Vertical translation (moving). The newer type consists of a single parameter, matrix, representing a 2D...
A basic ray-caster - Web APIs
eporters to get to another level. But I'm pretty confident all those things could be added given enough time. The canvas API supports pixel copying of images, so textures seem feasible. I'll leave that for another article, probably from another person. =) The ray-caster The nice people here have manually copied my files up so you can take a look, and for your hacking enjoyment I've posted the in
dividual file contents as code listings (see below). So there you are, fire up Safari 1.3+ or Firefox 1.5+ or some other browser that supports the <canvas> element and enjoy! input.js | Level.js | Player.js | RayCaster.html | RayCaster.js | trace.css | trace.js See also Canvas tutorial ...
Compositing example - Web APIs
orresponding pixel of the bottom layer. A darker picture is the result.', 'The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)', 'A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.', 'Retains the darkest pixels of both layers.', 'Retains the lightest pixels of both layers.', '
Divides the bottom layer by the inverted top layer.', '
Divides the inverted bottom layer by the top layer, and then inverts the result.', 'A combination of multiply and screen like overlay, but with top and bottom layer swapped.', 'A softer version of hard-light. Pure black or white does not result in pure black or white.', 'Subtracts the bottom layer from the top layer or the other way round to alwa...
Canvas API - Web APIs
geData RenderingContext TextMetrics OffscreenCanvas Path2D ImageBitmapRenderingContext Note: The interfaces related to the WebGLRenderingContext are referenced under WebGL. CanvasCaptureMediaStream is a related interface. Guides and tutorials Canvas tutorial A comprehensive tutorial covering both the basic usage of the Canvas API and its advanced features. HTML5 Canvas Deep
Dive A hands-on, book-length introduction to the Canvas API and WebGL. Canvas Handbook A handy reference for the Canvas API. Demo: A basic ray-caster A demo of ray-tracing animation using canvas. Manipulating video using canvas Combining <video> and <canvas> to manipulate video data in real time. Libraries The Canvas API is extremely powerful, but not always simple to use. The libraries lis...
ChildNode.replaceWith() - Web APIs
g objects. DOMString objects are inserted as equivalent Text nodes. Syntax [Throws, Unscopable] void ChildNode.replaceWith((Node or DOMString)... nodes); Parameters nodes A set of Node or DOMString objects to replace. Exceptions HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy. Examples Using replaceWith() var parent = document.createElement("
div"); var child = document.createElement("p"); parent.appendChild(child); var span = document.createElement("span"); child.replaceWith(span); console.log(parent.outerHTML); // "<
div><span></span></
div>" ChildNode.replaceWith() is unscopable The replaceWith() method is not scoped into the with statement. See Symbol.unscopables for more information. with(node) { replaceWith("foo"); } // Refere...
ContentIndex - Web APIs
ms within the content index and iterates over each entry, building a list for the interface. ...
ConvolverNode.normalize - Web APIs
The normalize property of the ConvolverNode interface is a boolean that controls whether the impulse response from the buffer will be scaled by an equal-power normalization when the buffer attribute is set, or not. Its default value is true in order to achieve a more uniform output level from the convolver, when loaded with
diverse impulse responses. If normalize is set to false, then the convolution will be rendered with no pre-processing/scaling of the impulse response. Changes to this value do not take effect until the next time the buffer attribute is set. Syntax var audioCtx = new AudioContext(); var convolver = audioCtx.createConvolver(); convolver.normalize = false; Value A boolean. Example var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); var convolver ...
CustomElementRegistry.whenDefined() - Web APIs
ons Exception Description SyntaxError If the provided name is not a valid custom element name, the promise rejects with a SyntaxError. Examples This example uses whenDefined() to detect when the custom elements that make up a menu are defined. The menu displays placeholder content until the actual menu content is ready to display. <nav id="menu-container"> <
div class="menu-placeholder">Loading...</
div> <nav-menu> <menu-item>Item 1</menu-item> <menu-item>Item 2</menu-item> ... <menu-item>Item N</menu-item> </nav-menu> </nav> const container = document.getElementById('menu-container'); const placeholder = container.querySelector('.menu-placeholder'); // Fetch all the children of menu that are not yet defined. const undefinedElements...
DOMImplementation.hasFeature() - Web APIs
The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use. Syntax const flag = document.implementation.hasFeature(feature, version); Parameters feature A DOMString representing the feature name. ...
DOMTokenList.values() - Web APIs
Syntax tokenList.values(); Parameters None. Return value Returns an iterator. Examples In the following example we retrieve the list of classes set on a <span> element as a DOMTokenList using Element.classList. We when retrieve an iterator containing the values using values(), then iterate through those values using a for ... of loop, writing each one to the <span>'s Node.textContent. ...
DataTransferItem.webkitGetAsEntry() - Web APIs
. Return value A FileSystemEntry-based object describing the dropped item. This will be either FileSystemFileEntry or FileSystemDirectoryEntry. Example In this example, a drop zone is created, which responds to the drop event by scanning through the dropped files and directories, outputting a hierarchical directory listing. HTML content The HTML establishes the drop zone itself, which is a <
div> element with the ID "dropzone", and an unordered list element with the ID "listing". <p>Drag files and/or directories to the box below!</p> <
div id="dropzone"> <
div id="boxtitle"> Drop Files Here </
div> </
div> <h2>Directory tree:</h2> <ul id="listing"> </ul> CSS content The styles used by the example are shown here. #dropzone { text-align: center; width: 300px; height: 100px...
DataTransferItemList.remove() - Web APIs
ault(); // Set the dropEffect to move ev.dataTransfer.dropEffect = "move" } function dragend_handler(ev) { console.log("dragEnd"); var dataList = ev.dataTransfer.items; for (var i = 0; i < dataList.length; i++) { dataList.remove(i); } // Clear any remaining drag data dataList.clear(); } HTML <h1>Example uses of <code>DataTransferItemList</code> methods and property</h1> <
div> <p id="source" ondragstart="dragstart_handler(event);" ondragend="dragend_handler(event);" draggable="true"> Select this element, drag it to the Drop Zone and then release the selection to move the element.</p> </
div> <
div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</
div> CSS
div { margin: 0em; padding: 2em; } #source { ...
Document.cookie - Web APIs
quest slower. It is highly recommended for you to use WHATWG DOM Storage if you are going to keep "client-only" data. RFC 2965 (Section 5.3, "Implementation Limits") specifies that there should be no maximum length of a cookie's key or value size, and encourages implementations to support arbitrarily large cookies. Each browser's implementation maximum will necessarily be different, so consult in
dividual browser documentation. The reason for the syntax of the document.cookie accessor property is due to the client-server nature of cookies, which differs from other client-client storage methods (like, for instance, localStorage): The server tells the client to store a cookie HTTP/1.0 200 OK Content-type: text/html Set-Cookie: cookie_name1=cookie_value1 Set-Cookie: cookie_name2=cookie_value...
Document.createAttribute() - Web APIs
to a particular element in this manner. The string given in parameter is converted to lowercase. Syntax attribute = document.createAttribute(name) Parameters name is a string containing the name of the attribute. Return value A Attr node. Exceptions INVALID_CHARACTER_ERR if the parameter contains invalid characters for XML attribute. Example var node = document.getElementById("
div1"); var a = document.createAttribute("my_attrib"); a.value = "newVal"; node.setAttributeNode(a); console.log(node.getAttribute("my_attrib")); // "newVal" Specifications Specification Status Comment DOMThe definition of 'Document.createAttribute()' in that specification. Living Standard Precised behavior with uppercase characters Document Object Model (DOM...
Document: fullscreenerror event - Web APIs
dler property onfullscreenerror As with the fullscreenchange event, two fullscreenerror events are fired; the first is sent to the Element which failed to change modes, and the second is sent to the Document which owns that element. ...
DocumentFragment.querySelectorAll() - Web APIs
ctors. If the selectors specified in parameter are invalid a DOMException with a SYNTAX_ERR value is raised. Note: The definition of this API was moved to the ParentNode interface. Syntax elementList = documentfragment.querySelectorAll(selectors); Parameters selectors Is a DOMString containing one or more CSS selectors separated by commas. Examples This example returns a list of all
div elements within the DocumentFragment with a class of either "note" or "alert": var matches = documentfrag.querySelectorAll("
div.note,
div.alert"); Specifications Specification Status Comment Selectors API Level 1The definition of 'DocumentFragment.querySelectorAll' in that specification. Obsolete Initial definition. ...
Element.attachShadow() - Web APIs
reference to its ShadowRoot. Elements you can attach a shadow to Note that you can't attach a shadow root to every type of element. There are some that can't have a shadow DOM for security reasons (for example <a>), and more besides. The following is a list of elements you can attach a shadow root to: Any autonomous custom element with a valid name <article> <aside> <blockquote> <body> <
div> <footer> <h1> <h2> <h3> <h4> <h5> <h6> <header> <main> <nav> <p> <section> <span> Syntax var shadowroot = element.attachShadow(shadowRootInit); Parameters shadowRootInit A ShadowRootInit dictionary, which can contain the following fields: mode A string specifying the encapsulation mode for the shadow DOM tree. This can be one of: open: Elements of the shadow...
Element: fullscreenerror event - Web APIs
property onfullscreenerror As with the fullscreenchange event, two fullscreenerror events are fired; the first is sent to the Element which failed to change modes, and the second is sent to the Document which contains that element. ...
Element.getAttribute() - Web APIs
ied attribute on the element. If the given attribute does not exist, the value returned will either be null or "" (the empty string); see Non-existing attributes for details. Syntax let attribute = element.getAttribute(attributeName); where attribute is a string containing the value of attributeName. attributeName is the name of the attribute whose value you want to get. Examples const
div1 = document.getElementById('
div1'); const align =
div1.getAttribute('align'); alert(align); // Shows the value of align for the element with id="
div1" Description Lower casing When called on an HTML element in a DOM flagged as an HTML document, getAttribute() lower-cases its argument before proceeding. Non-existing attributes Essentially all web browsers (Firefox, Internet Explorer, recent ...
Element.getAttributeNode() - Web APIs
Returns the specified attribute of the specified element, as an Attr node. Syntax var attrNode = element.getAttributeNode(attrName); attrNode is an Attr node for the attribute. attrName is a string containing the name of the attribute. Example // html: <
div id="top" /> let t = document.getElementById("top"); let idAttr = t.getAttributeNode("id"); alert(idAttr.value == "top") Notes When called on an HTML element in a DOM flagged as an HTML document, getAttributeNode lower-cases its argument before proceeding. The Attr node inherits from Node, but is not considered a part of the document tree. Common Node attributes like parentNode, previousSibling, and nextSibling are null for an Attr node. You can, however, get the element to which the attribute belongs with the ownerElement pr...
Element.getAttributeNodeNS() - Web APIs
Returns the Attr node for the attribute with the given namespace and name. Syntax attributeNode = element.getAttributeNodeNS(namespace, nodeName) attributeNode is the node for specified attribute. namespace is a string specifying the namespace of the attribute. nodeName is a string specifying the name of the attribute. == Example == TBD The example needs to be fixed pre> // html: <
div id="top" /> t = document.getElementById("top"); specialNode = t.getAttributeNodeNS( "http://www.mozilla.org/ns/specialspace", "id"); // iNode.value = "full-top" </pre Notes getAttributeNodeNS is more specific than getAttributeNode in that it allows you to specify attributes that are part of a particular namespace. The corresponding setter method is setAttributeNodeNS. DOM methods dealing with eleme...
Element.hasAttributeNS() - Web APIs
boolean value indicating whether the current element has the specified attribute. Syntax result = element.hasAttributeNS(namespace,localName) result is the boolean value true or false. namespace is a string specifying the namespace of the attribute. localName is the name of the attribute. ...
Element.insertAdjacentHTML() - Web APIs
after its last child. 'afterend': After the element itself. text The string to be parsed as HTML or XML and inserted into the tree. Visualization of position names <!-- beforebegin --> <p> <!-- afterbegin --> foo <!-- beforeend --> </p> <!-- afterend --> Note: The beforebegin and afterend positions work only if the node is in the DOM tree and has a parent element. Example // <
div id="one">one</
div> var d1 = document.getElementById('one'); d1.insertAdjacentHTML('afterend', '<
div id="two">two</
div>'); // At this point, the new structure is: // <
div id="one">one</
div><
div id="two">two</
div> Notes Security considerations When inserting HTML into a page by using insertAdjacentHTML(), be careful not to use user input that hasn't been escaped. It is not recommended you use ...
Element: mouseenter event - Web APIs
d with the corresponding mouseleave (which is fired at the element when the mouse exits its content area), the mouseenter event acts in a very similar way to the CSS :hover pseudo-class. Examples The mouseover documentation has an example illustrating the difference between mouseover and mouseenter. mouseenter The following trivial example uses the mouseenter event to change the border on the
div when the mouse enters the space alloted to it. It then adds an item to the list with the number of the mouseenter or mouseleave event. HTML <
div id='mouseTarget'> <ul id="unorderedList"> <li>No events yet!</li> </ul> </
div> CSS Styling the
div to make it more visible. #mouseTarget { box-sizing: border-box; width:15rem; border:1px solid #333; } JavaScript var enterEventCount = 0; ...
Element: mouseout event - Web APIs
he mouseout event. mouseout and mouseleave The following example illustrates the difference between mouseout and mouseleave events. The mouseleave event is added to the <ul> to color the list purple whenever the mouse exits the <ul>. mouseout is added to the list to color the targeted element orange when the mouse exits it. When you try this out, you'll find that mouseout is delivered to the in
dividual list items, while mouseleave goes to the overall list, courtesy of the hierarchy of the items and the fact that list items obscure the underlying <ul>. HTML <ul id="test"> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> JavaScript let test = document.getElementById("test"); // Briefly make the list purple when the mouse moves off the // <ul> element test.addEventListener("m...
Element.prefix - Web APIs
The Element.prefix read-only property returns the namespace prefix of the specified element, or null if no prefix is specified. Before DOM4 this API was defined within the Node interface. Syntax string = element.prefix Examples The following logs "x" to the console. <x:
div onclick="console.log(this.prefix)"/> Notes This will only work when a namespace-aware parser is used, i.e. when a document is served with an XML MIME type. This will not work for HTML documents. Specifications Specification Status Comment DOMThe definition of 'Element: prefix' in that specification. Living Standard ...
Element.removeAttributeNode() - Web APIs
The removeAttributeNode() method of the Element object removes the specified attribute from the current element. Syntax removedAttr = element.removeAttributeNode(attributeNode) attributeNode is the Attr node that needs to be removed. removedAttr is the removed Attr node. Example // Given: <
div id="top" align="center" /> var d = document.getElementById("top"); var d_align = d.getAttributeNode("align"); d.removeAttributeNode(d_align); // align is now removed: <
div id="top" /> Notes If the removed attribute has a default value, it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable. There is no removeAttributeNodeNS method; the removeAttributeNode method can remove both namespaced attributes an...
Element.setAttributeNode() - Web APIs
The setAttributeNode() method adds a new Attr node to the specified element. Syntax var replacedAttr = element.setAttributeNode(attribute); attribute is the Attr node to set on the element. replacedAttr is the replaced attribute node, if any, returned by this function. Example This example copies the align attribute from one element to another. HTML <
div id="one" align="left">one</
div> <
div id="two">two</
div> JavaScript let d1 = document.getElementById('one'); let d2 = document.getElementById('two'); let a = d1.getAttributeNode('align'); d2.setAttributeNode(a.cloneNode(true)); // Returns: 'left' alert(d2.attributes[1].value); Notes If the attribute named already exists on the element, that attribute is replaced with the new one and the replaced one is returned. This metho...
Element.shadowRoot - Web APIs
ng Element.shadowRoot. From here we use standard DOM traversal techniques to find the <style> element inside the shadow DOM and then update the CSS found inside it: function updateStyle(elem) { const shadow = elem.shadowRoot; const childNodes = Array.from(shadow.childNodes); childNodes.forEach(childNode => { if (childNode.nodeName === 'STYLE') { childNode.textContent = `
div { width: ${elem.getAttribute('l')}px; height: ${elem.getAttribute('l')}px; background-color: ${elem.getAttribute('c')}; } `; } }); } Specifications Specification Status Comment DOMThe definition of 'shadowRoot' in that specification. Living Standard ...
Element: show event - Web APIs
The show event is fired when a contextmenu event was fired on/bubbled to an element that has a contextmenu attribute. Bubbles No Cancelable No Interface Event Event handler property onshow Examples <
div contextmenu="test"></
div> <menu type="context" id="test"> <menuitem label="alert" onclick="alert('the alert label has been clicked')" /> </menu> <script> document.getElementById("test").addEventListener("show", function(e){ alert("the context menu will be displayed"); }, false); </script> Specifications Specification Status HTML5The definition of 'show event' in that specification. Recommendation ...
Element.tagName - Web APIs
gName property is "IMG" (for HTML documents; it may be cased differently for XML/XHTML documents). Syntax elementName = Element.tagName; Value A string indicating the element's tag name. This string's capitalization depends on the document type: For DOM trees which represent HTML documents, the returned tag name is always in the canonical upper-case form. For example, tagName called on a <
div> element returns "
DIV". The tag names of elements in an XML DOM tree are returned in the same case in which they're written in the original XML file. If an XML document includes a tag "<SomeTag>", then the tagName property's value is "SomeTag". For Element objects, the value of tagName is the same as the value of the nodeName property the element object inherits from Node. Example HTML <spa...
Event() - Web APIs
nal A Boolean indicating whether the event will trigger listeners outside of a shadow root (see Event.composed for more details). The default is false. Example // create a look event that bubbles up and cannot be canceled const evt = new Event("look", {"bubbles":true, "cancelable":false}); document.dispatchEvent(evt); // event can be dispatched from any element, not only the document my
Div.dispatchEvent(evt); Specifications Specification Status Comment DOMThe definition of 'Event()' in that specification. Living Standard Initial definition ...
Event - Web APIs
ypes of events, some of which use other interfaces based on the main Event interface. Event itself contains the properties and methods which are common to all events. Many DOM elements can be set up to accept (or "listen" for) these events, and execute code in response to process (or "handle") them. Event-handlers are usually connected (or "attached") to various HTML elements (such as <button>, <
div>, <span>, etc.) using EventTarget.addEventListener(), and this generally replaces using the old HTML event handler attributes. Further, when properly added, such handlers can also be disconnected if needed using removeEventListener(). Note: One element can have several such handlers, even for the exact same event--particularly if separate, independent code modules attach them, each for its own ...
FeaturePolicy.allowedFeatures() - Web APIs
As such, allowedFeatures() method returns a subset of directives returned by features(). Syntax const allowed = FeaturePolicy.allowedFeatures() Parameters None. Return value An array of strings representing the Feature Policy directive names that are allowed by the Feature Policy this method is called on. Example The followin example logs all the allowed directives for the current document. ...
FeaturePolicy.allowsFeature() - Web APIs
It returns a Boolean that is true if and only if the specified feature is allowed in the specified context (or the default context if no context is specified). Syntax const allowed = FeaturePolicy.allowsFeature(<feature>) or const allowed = FeaturePolicy.allowsFeature(<feature>, <origin>) Parameters Feature name A specific feature name must be specified. Origin name Optional An origin URL to check the feature on. If it is omitted the default origin is used. Return value A Boolean that is true if and only if the feature is allowed. ...
FileReader.readAsDataURL() - Web APIs
ocument.querySelector('input[type=file]').files[0]; const reader = new FileReader(); reader.addEventListener("load", function () { // convert image file to base64 string preview.src = reader.result; }, false); if (file) { reader.readAsDataURL(file); } } Live Result Example reading multiple files HTML <input id="browse" type="file" onchange="previewFiles()" multiple> <
div id="preview"></
div> JavaScript function previewFiles() { var preview = document.querySelector('#preview'); var files = document.querySelector('input[type=file]').files; function readAndPreview(file) { // Make sure `file.name` matches our extensions criteria if ( /\.(jpe?g|png|gif)$/i.test(file.name) ) { var reader = new FileReader(); reader.addEventListener("load...
FileSystemDirectoryReader.readEntries() - Web APIs
e reading from the directory. It receives one input parameter: a FileError object describing the error which occurred. Return value undefined. Example In this example, a drop zone is created, which responds to the drop event by scanning through the dropped files and directories, outputting a hierarchical directory listing. HTML content The HTML establishes the drop zone itself, which is a <
div> element with the ID "dropzone", and an unordered list element with the ID "listing". <p>Drag files and/or directories to the box below!</p> <
div id="dropzone"> <
div id="boxtitle"> Drop Files Here </
div> </
div> <h2>Directory tree:</h2> <ul id="listing"> </ul> CSS content The styles used by the example are shown here. #dropzone { text-align: center; width: 300px; height: 100px...
FontFaceSet.check() - Web APIs
ed and are available. Syntax bool = aFontFaceSet.check(font); bool = aFontFaceSet.check(font, text); Returns A Boolean that is true if the font list is available Parameters font: a font specification using the CSS value syntax, e.g. "italic bold 16px Roboto" text: limit the font faces to those whose Unicode range contains at least one of the characters in text. This does not check for in
dividual glyph coverage. Examples document.fonts.check("12px courier"); // returns true if the font courier is available at 12px document.fonts.check("12px MyFont", "ss"); // returns true if the font 'MyFont' has a ss character. Specifications Specification Status Comment CSS Font Loading Module Level 3The definition of 'check' in that specification. Working Draft ...
FontFaceSet.load() - Web APIs
text); Returns A Promise of an Array of FontFace loaded. The promise is fulfilled when all the fonts are loaded; it is rejected if one of the fonts failed to load. Parameters font: a font specification using the CSS value syntax, e.g. "italic bold 16px Roboto" text: limit the font faces to those whose Unicode range contains at least one of the characters in text. This does not check for in
dividual glyph coverage. Examples // returns a promise that will be fulfilled or rejected according the success to load MyFont // The code in 'then' can assume the availability of that font. document.fonts.load("12px MyFont", "ss").then(...); Specifications Specification Status Comment CSS Font Loading Module Level 3The definition of 'load' in that specification. Wor...
Using FormData Objects - Web APIs
>Your email address:</label> <input type="email" autocomplete="on" autofocus name="userid" placeholder="email" required size="32" maxlength="64" /><br /> <label>Custom file label:</label> <input type="text" name="filelabel" size="12" maxlength="32" /><br /> <label>File to stash:</label> <input type="file" name="file" required /> <input type="submit" value="Stash the file!" /> </form> <
div></
div> Then you can send it using code like the following: var form = document.forms.namedItem("fileinfo"); form.addEventListener('submit', function(ev) { var oOutput = document.querySelector("
div"), oData = new FormData(form); oData.append("CustomField", "This is some extra data"); var oReq = new XMLHttpRequest(); oReq.open("POST", "stash.php", true); oReq.onload = function...
Gamepad - Web APIs
A Gamepad object can be returned in one of two ways: via the gamepad property of the gamepadconnected and gamepaddisconnected events, or by grabbing any position in the array returned by the Navigator.getGamepads() method. Properties Gamepad.axes Read only An array representing the controls with axes present on the device (e.g. analog thumb sticks). Gamepad.buttons Read only An array of gamepadButton objects representing the buttons present on the device. Gamepad.connected Read only A boolean indicating whether the gamepad is still connected to the system. ...
GamepadButton - Web APIs
A GamepadButton object is returned by querying any value of the array returned by the buttons property of the Gamepad interface. Note: This is the case in Firefox Gecko 28 and later; Chrome and earlier Firefox versions still return an array of double values when this property is accessed. Properties GamepadButton.value Read only A double value used to represent the current state of analog buttons, such as the triggers on many modern gamepads. ...
GlobalEventHandlers.onclick - Web APIs
MouseEvent object as its sole argument. Within the function, this will be the element upon which the event was triggered. Only one onclick handler can be assigned to an object at a time. You may prefer to use the EventTarget.addEventListener() method instead, since it's more flexible. Examples Detecting clicks This example simply changes the color of an element when it's clicked upon. HTML <
div id="demo">Click here</
div> JavaScript document.getElementById('demo').onclick = function changeContent() { document.getElementById('demo').innerHTML = "Help me"; document.getElementById('demo').style = "Color: red"; } Result Getting the coordinates of clicks This example displays the coordinates at which the most recent mouse button click occurred. HTML <p>Click anywhere in this ...
GlobalEventHandlers.onpointercancel - Web APIs
dler The pointercancel event handler for element targetElement. Example This example shows two ways to use onpointercancel to handle an element's pointercancel events. <html> <script> function cancelHandler(ev) { // Process the pointercancel event } function init() { var el = document.getElementById('target1'); el.onpointercancel = cancelHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointercancel="cancelHandler(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointercancel' in that specification. Recommendation Non-stable version Pointer EventsThe definition of 'onpointercancel' in that spec...
GlobalEventHandlers.onpointerdown - Web APIs
} This code's job is to just restore the original text into the target box after the user's interaction with the element ends (for example, when they release the mouse button, or when they lift the stylus or finger from the screen). In addition, the event's preventDefault() method is called to ensure that the mouseup event isn't triggered unnecessarily. HTML The HTML is extremely simple: <
div id="target"> Tap me, click me, or touch me! </
div> CSS The CSS simply sets up the appearance of the target, and doesn't affect its functionality at all. #target { width: 400px; height: 30px; text-align: center; font: 16px "Open Sans", "Helvetica", sans-serif; color: white; background-color: blue; border: 2px solid darkblue; cursor: pointer; user-select: none; -moz-user...
GlobalEventHandlers.onpointerenter - Web APIs
Handler The pointerenter event handler for element targetElement. Example This example shows two ways to use onpointerenter to set an element's pointerenter event handler. <html> <script> function enterHandler(ev) { // Process the pointerenter event } function init() { let el = document.getElementById('target1'); el.onpointerenter = enterHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointerenter="enterHandler(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointerenter' in that specification. Recommendation Non-stable version Pointer EventsThe definition of 'onpointerenter' in that specific...
GlobalEventHandlers.onpointerleave - Web APIs
er which will be invoked to handle pointerleave events sent to the target. Example This example shows two ways to use onpointerleave to set an element's pointerleave event handler. <html> <script> function leaveHandler(ev) { // Process the pointerleave event } function init() { var el=document.getElementById("target1"); el.onpointerleave = leaveHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointerleave="leaveHandler(event)"> Touch me ... </
div> </body> </html> See Using Pointer Events for additional details. Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointerleave' in that specification. Recommendation Non-stable version Pointer EventsThe...
GlobalEventHandlers.onpointermove - Web APIs
e moveHandler The pointermove event handler for element targetElement. Example This example shows two ways to use onpointermove to set an element's pointermove event handler. <html> <script> function moveHandler(ev) { // Process the pointermove event } function init() { let el=document.getElementById('target1'); el.onpointermove = moveHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointermove="moveHandler(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointermove' in that specification. Recommendation Non-stable version Pointer EventsThe definition of 'onpointermove' in that specificatio...
GlobalEventHandlers.onpointerout - Web APIs
; Value outHandler The pointerout event handler for element targetElement. Example This example shows two ways to use onpointerout to set an element's pointerout event handler. <html> <script> function outHandler(ev) { // Process the pointerout event } function init() { let el=document.getElementById('target1'); el.onpointerout = outHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointerout="outHandler(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointerout' in that specification. Recommendation Non-stable version Pointer EventsThe definition of 'onpointerout' in that specification. ...
GlobalEventHandlers.onpointerover - Web APIs
overHandler The pointerover event handler for element targetElement. Example This example shows two ways to use onpointerover to set an element's pointerover event handler. <html> <script> function overHandler(ev) { // Process the pointerover event } function init() { let el = document.getElementById('target1'); el.onpointerover = overHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointerover="overHandler(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointerover' in that specification. Recommendation Non-stable version Pointer EventsThe definition of 'onpointerover' in that specificatio...
GlobalEventHandlers.onpointerup - Web APIs
nterup; Value upHandler The pointerup event handler for element targetElement. Example This example shows two ways to use onpointerup to set an element's pointerup event handler. <html> <script> function upHandler(ev) { // Process the pointerup event } function init() { let el = document.getElementById('target1'); el.onpointerup = upHandler; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" onpointerup="upHandler(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Pointer Events - Level 2The definition of 'onpointerup' in that specification. Recommendation Non-stable version Pointer EventsThe definition of 'onpointerup' in that specification. Ob...
GlobalEventHandlers.ontouchcancel - Web APIs
eturn value cancelHandler The touchcancel event handler for element someElement. Example This example shows two ways to use ontouchcancel to set an element's touchcancel event handler. <html> <script> function cancelTouch(ev) { // Process the event } function init() { let el = document.getElementById('target1'); el.ontouchcancel = cancelTouch; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" ontouchcancel="cancelTouch(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Touch Events - Level 2 Draft Non-stable version. ...
GlobalEventHandlers.ontouchend - Web APIs
etElement.ontouchend; Return value endHandler The touchend event handler for element targetElement. Example This example shows two ways to use ontouchend to set an element's touchend event handler. <html> <script> function endTouch(ev) { // Process the event } function init() { var el=document.getElementById("target1"); el.ontouchend = endTouch; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" ontouchend="endTouch(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Touch Events - Level 2 Draft Non-stable version. ...
GlobalEventHandlers.ontouchmove - Web APIs
Return value moveHandler The touchmove event handler for element someElement. Example This example shows two ways to use ontouchmove to set an element's touchmove event handler. <html> <head> <script> function moveTouch(ev) { // Process the event } function init() { var el=document.getElementById("target1"); el.ontouchmove = moveTouch; } </script> </head> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" ontouchmove="moveTouch(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Touch Events - Level 2 Draft Non-stable version. ...
GlobalEventHandlers.ontouchstart - Web APIs
rt; Return value startHandler The touchstart event handler for element someElement. Example This example shows two ways to use ontouchstart to set an element's touchstart event handler. <html> <script> function startTouch(ev) { // Process the event } function init() { let el = document.getElementById('target1'); el.ontouchstart = startTouch; } </script> <body onload="init();"> <
div id="target1"> Touch me ... </
div> <
div id="target2" ontouchstart="startTouch(event)"> Touch me ... </
div> </body> </html> Specifications Specification Status Comment Touch Events - Level 2 Draft Non-stable version. ...
GlobalEventHandlers.ontransitioncancel - Web APIs
n and transitionend events to detect when the transition begins and ends, to cause a text update to occur during the transition. This could also be used to trigger animations or other effects, to allow chaining of reactions. In addition, we also use a click event to make the box dissappear (display: none;), showing how it triggers the transitioncancel event to fire. HTML This simply creates a <
div> which we'll style with CSS below to make into a box that resizes and changes color and such. <
div class="box"></
div> CSS The CSS below styles the box and applies a transition effect which makes the box's color and size change, and causes the box to rotate, while the mouse cursor hovers over it. .box { margin-left: 70px; margin-top: 30px; border-style: solid; border-width: 1px; dis...
GlobalEventHandlers.ontransitionend - Web APIs
the value of elapsedTime, which is zero until the delay period ends and the animation begins. Example In this example, we use the transitionrun and transitionend events to detect when the transition begins and ends, to cause a text update to occur during the transition. This could also be used to trigger animations or other effects, to allow chaining of reactions. HTML This simply creates a <
div> which we'll style with CSS below to make into a box that resizes and changes color and such. <
div class="box"></
div> CSS The CSS below styles the box and applies a transition effect which makes the box's color and size change, and causes the box to rotate, while the mouse cursor hovers over it. .box { margin-left: 70px; margin-top: 30px; border-style: solid; border-width: 1px; dis...
HTMLAnchorElement.referrerPolicy - Web APIs
lude the origin and the path (but not the fragment, password, or username). This case is unsafe as it can leak path information that has been concealed to third-party by using TLS. Examples var elt = document.createElement("a"); var linkText = document.createTextNode("My link"); elt.appendChild(linkText); elt.href = "https://developer.mozilla.org/"; elt.referrerPolicy = "no-referrer"; var
div = document.getElementById("
divAround");
div.appendChild(elt); // When clicked, the link will not send a referrer header. Specifications Specification Status Comment Referrer PolicyThe definition of 'referrerPolicy attribute' in that specification. Candidate Recommendation Added the referrerPolicy property. Browser compatibility The compatibility table ...
HTMLCollection.item - Web APIs
Syntax var element = HTMLCollection.item(index) Parameters index The position of the Node to be returned. Elements appear in an HTMLCollection in the same order in which they appear in the document's source. ...
HTMLDetailsElement: toggle event - Web APIs
tate of a <details> element is toggled. Bubbles No Cancelable No Interface Event Event handler property None Default Action Toggles the open state of the <details> element. Examples This example logs chapters that are open. Chapters are removed from the log when they are closed. HTML <aside id="log"> <b>Open chapters:</b> <
div data-id="ch1" hidden>I</
div> <
div data-id="ch2" hidden>II</
div> <
div data-id="ch3" hidden>III</
div> </aside> <section id="summaries"> <b>Chapter summaries:</b> <details id="ch1"> <summary>Chapter I</summary> Philosophy reproves Boethius for the foolishness of his complaints against Fortune. Her very nature is caprice. </details> <details id="ch2"> <summary>Chapter II</summ...
HTMLElement: animationcancel event - Web APIs
animated.addEventListener('animationcancel', () => { console.log('Animation canceled'); }); animated.style.display = 'none'; The same, but using the onanimationcancel property instead of addEventListener(): const animated = document.querySelector('.animated'); animated.onanimationcancel = () => { console.log('Animation canceled'); }; animated.style.display = 'none'; Live example HTML <
div class="animation-example"> <
div class="container"> <p class="animation">You chose a cold night to visit our planet.</p> </
div> <button class="activate" type="button">Activate animation</button> <
div class="event-log"></
div> </
div> CSS .container { height: 3rem; } .event-log { width: 25rem; height: 2rem; border: 1px solid black; margin: 0.2rem; padding: 0.2r...
HTMLElement: animationend event - Web APIs
ed and listens for the animationend event: const animated = document.querySelector('.animated'); animated.addEventListener('animationend', () => { console.log('Animation ended'); }); The same, but using the onanimationend event handler property: const animated = document.querySelector('.animated'); animated.onanimationend = () => { console.log('Animation ended'); }; Live example HTML <
div class="animation-example"> <
div class="container"> <p class="animation">You chose a cold night to visit our planet.</p> </
div> <button class="activate" type="button">Activate animation</button> <
div class="event-log"></
div> </
div> CSS .container { height: 3rem; } .event-log { width: 25rem; height: 2rem; border: 1px solid black; margin: .2rem; padding: .2rem...
HTMLElement: animationiteration event - Web APIs
ion', () => { iterationCount++; console.log(`Animation iteration count: ${iterationCount}`); }); The same, but using the onanimationiteration event handler property: const animated = document.querySelector('.animated'); let iterationCount = 0; animated.onanimationiteration = () => { iterationCount++; console.log(`Animation iteration count: ${iterationCount}`); }; Live example HTML <
div class="animation-example"> <
div class="container"> <p class="animation">You chose a cold night to visit our planet.</p> </
div> <button class="activate" type="button">Activate animation</button> <
div class="event-log"></
div> </
div> CSS .container { height: 3rem; } .event-log { width: 25rem; height: 2rem; border: 1px solid black; margin: 0.2rem; padding: 0.2r...
HTMLElement: animationstart event - Web APIs
animationstart event and logs a message when it is fired: const animated = document.querySelector('.animated'); animated.addEventListener('animationstart', () => { console.log('Animation started'); }); The same, but using onanimationstart: const animated = document.querySelector('.animated'); animated.onanimationstart = () => { console.log('Animation started'); }; Live example HTML <
div class="animation-example"> <
div class="container"> <p class="animation">You chose a cold night to visit our planet.</p> </
div> <button class="activate" type="button">Activate animation</button> <
div class="event-log"></
div> </
div> CSS .container { height: 3rem; } .event-log { width: 25rem; height: 2rem; border: 1px solid black; margin: 0.2rem; padding: 0.2r...
HTMLElement.lang - Web APIs
t.lang property gets or sets the base language of an element's attribute values and text content. The language code returned by this property is defined in the Tags for Identifying Languages (BCP47) IETF document. Common examples include "en" for English, "ja" for Japanese, "es" for Spanish and so on. The default value of this attribute is unknown. Note that this attribute, though valid at the in
dividual element level described here, is most often specified for the root element of the document. This also only works with the lang attribute and not with xml:lang. Syntax var languageUsed = elementNodeReference.lang; // Get the value of lang elementNodeReference.lang = NewLanguage; // Set new value for lang languageUsed is a string variable that gets the language in which the text of the cu...
HTMLElement.offsetTop - Web APIs
The HTMLElement.offsetTop read-only property returns the distance of the current element relative to the top of the offsetParent node. Syntax topPos = element.offsetTop; Parameters topPos is the number of pixels from the top of the closest relatively positioned parent element. Example var d = document.getElementById("
div1"); var topPos = d.offsetTop; if (topPos > 10) { // object is offset more // than 10 pixels from its parent } Specification Specification Status Comment CSS Object Model (CSSOM) View ModuleThe definition of 'offsetTop' in that specification. Working Draft Browser compatibility The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out...
HTMLElement: transitioncancel event - Web APIs
'.transition'); transition.addEventListener('transitioncancel', () => { console.log('Transition canceled'); }); The same, but using the ontransitioncancel property instead of addEventListener(): const transition = document.querySelector('.transition'); transition.ontransitioncancel = () => { console.log('Transition canceled'); }; Live example In the following example, we have a simple <
div> element, styled with a transition that includes a delay: <
div class="transition"></
div> <
div class="message"></
div> .transition { width: 100px; height: 100px; background: rgba(255,0,0,1); transition-property: transform background; transition-duration: 2s; transition-delay: 2s; } .transition:hover { transform: rotate(90deg); background: rgba(255,0,0,0); } To this, we'll add so...
HTMLElement: transitionend event - Web APIs
nend event: const transition = document.querySelector('.transition'); transition.addEventListener('transitionend', () => { console.log('Transition ended'); }); The same, but using the ontransitionend: const transition = document.querySelector('.transition'); transition.ontransitionend = () => { console.log('Transition ended'); }; Live example In the following example, we have a simple <
div> element, styled with a transition that includes a delay: <
div class="transition">Hover over me</
div> <
div class="message"></
div> .transition { width: 100px; height: 100px; background: rgba(255,0,0,1); transition-property: transform background; transition-duration: 2s; transition-delay: 1s; } .transition:hover { transform: rotate(90deg); background: rgba(255,0,0,0); } To this,...
HTMLElement: transitionrun event - Web APIs
itionrun', () => { console.log('Transition is running but hasn\'t necessarily started transitioning yet'); }); The same, but using the ontransitionrun property instead of addEventListener(): el.ontransitionrun = () => { console.log('Transition started running, and will start transitioning when the transition delay has expired'); }; Live example In the following example, we have a simple <
div> element, styled with a transition that includes a delay: <
div class="transition">Hover over me</
div> <
div class="message"></
div> .transition { width: 100px; height: 100px; background: rgba(255,0,0,1); transition-property: transform, background; transition-duration: 2s; transition-delay: 1s; } .transition:hover { transform: rotate(90deg); background: rgba(255,0,0,0); } To this...
HTMLElement: transitionstart event - Web APIs
tionstart Examples This code adds a listener to the transitionstart event: element.addEventListener('transitionstart', () => { console.log('Started transitioning'); }); The same, but using the ontransitionstart property instead of addEventListener(): element.ontransitionrun = () => { console.log('Started transitioning'); }; Live example In the following example, we have a simple <
div> element, styled with a transition that includes a delay: <
div class="transition">Hover over me</
div> <
div class="message"></
div> .transition { width: 100px; height: 100px; background: rgba(255,0,0,1); transition-property: transform, background; transition-duration: 2s; transition-delay: 1s; } .transition:hover { transform: rotate(90deg); background: rgba(255,0,0,0); } To this...
HTMLImageElement.crossOrigin - Web APIs
const image = new Image(200, 200); image.addEventListener("load", () => container.prepend(image) ); image.addEventListener("error", () => { const errMsg = document.createElement("output"); errMsg.value = `Error loading image at ${url}`; container.append(errMsg); }); image.crossOrigin = "anonymous"; image.alt = ""; image.src = url; } loadImage(imageUrl); HTML <
div class="container"> <p>Here's a paragraph. It's a very interesting paragraph. You are captivated by this paragraph. Keep reading this paragraph. Okay, now you can stop reading this paragraph. Thanks for reading me.</p> </
div> CSS body { font: 1.125rem/1.5, Helvetica, sans-serif; } .container { display: flow-root; width: 37.5em; border: 1px solid #d2d2d2; } img { float: left; ...
HTMLImageElement.referrerPolicy - Web APIs
igin of the page, that is roughly the scheme, the host and the port. "unsafe-url" meaning that the referrer will include the origin and the path (but not the fragment, password, or username). This case is unsafe as it can leak path information that has been concealed to third-party by using TLS. Examples var img = new Image(); img.src = 'img/logo.png'; img.referrerPolicy = 'origin'; var
div = document.getElementById('
divAround');
div.appendChild(img); // Fetch the image using the origin as the referrer Specifications Specification Status Comment Referrer PolicyThe definition of 'referrerPolicy attribute' in that specification. Candidate Recommendation Added the referrerPolicy property. Browser compatibility The compatibility table on this...
HTMLImageElement.sizes - Web APIs
selects an image and width that best meets the specified values. How exactly the images are used may depend upon the browser and what the pixel density of the user's display is. Buttons at the bottom of the example let you actually modify the sizes property slightly, switching the largest of the three widths for the image between 40em and 50em. HTML <article> <h1>An amazing headline</h1> <
div class="test"></
div> <p>This is even more amazing content text. It's really spectacular. And fascinating. Oh, it's also clever and witty. Award-winning stuff, I'm sure.</p> <img src="/files/16870/new-york-skyline-wide.jpg" srcset="/files/16870/new-york-skyline-wide.jpg 3724w, /files/16869/new-york-skyline-4by3.jpg 1961w, /files/16871/new-york-skyl...
HTMLImageElement.srcset - Web APIs
e for use in the <img> element, see Image file type and format guide. Example HTML The HTML below indicates that the default image is the 200 pixel wide version of the clock image we use in several places throughout our documentation. Also specified by the srcset attribute is that the 200-pixel version should be used for 1x displays while the 400-pixel version should be used for 2x displays. <
div class="box"> <img src="/files/16797/clock-demo-200px.png" alt="Clock" srcset="/files/16864/clock-demo-200px.png 1x, /files/16797/clock-demo-400px.png 2x"> </
div> CSS The CSS simply specifies that the image and its surrounding box should be 200 pixels square and should have a simple border around it. Also provided is the word-break attribute, using the break-all value to tell th...
HTMLInputElement.stepDown() - Web APIs
emeter is a numeric value. If no parameter is passed, stepDecrement defaults to 1. If the value is a float, the value will increment as if Math.floor(stepDecrement) was passed. If the value is negative, the value will be incremented instead of decremented. ...
HTMLInputElement.stepUp() - Web APIs
s set to any, an InvalidStateError exception is thrown. Syntax element.stepUp( [ stepIncrement ] ); Parameters stepIncrement The optional stepIncrement paremeter is a numeric value. If no parameter is passed, stepIncrement defaults to 1. ...
HTMLTableElement.cellPadding - Web APIs
Syntax HTMLTableElement.cellPadding = padding; var padding = HTMLTableElement.cellPadding; padding is either a number of pixels (e.g. "10") or a percentage value (e.g. "10%"). ...
HTMLTableElement.cellSpacing - Web APIs
Any two cells are separated by the sum of the cellSpacing of each of the two cells. Syntax HTMLTableElement.cellSpacing = spacing; var spacing = HTMLTableElement.cellSpacing; Value A DOMString which is either a number of pixels (such as "10") or a percentage value (like "10%"). ...
HTMLTableElement.rows - Web APIs
objects representing all of the <tr> elements contained in the table. This provides quick access to all of the table rows, without having to manually search for them. Example myrows = mytable.rows; firstRow = mytable.rows[0]; lastRow = mytable.rows.item(mytable.rows.length-1); This demonstrates how you can use both array syntax (line 2) and the HTMLCollection.item() method (line 3) to obtain in
dividual rows in the table. Specifications Specification Status Comment HTML Living StandardThe definition of 'HTMLTableElement: rows' in that specification. Living Standard ...
Dragging and Dropping Multiple Items - Web APIs
types.length; t++) { output(" " + types[t] + ": "); try { var data = dt.mozGetDataAt(types[t], i); output("(" + (typeof data) + ") : <" + data + " >\n"); } catch (ex) { output("<<error>>\n"); dump(ex); } } } } function output(text) { document.getElementById("output").textContent += text; dump(text); } </script> </head> <body> <
div id="output" style="min-height: 100px; white-space: pre; border: 1px solid black;" ondragenter="document.getElementById('output').textContent = ''; event.stopPropagation(); event.preventDefault();" ondragover="event.stopPropagation(); event.preventDefault();" ondrop="event.stopPropagation(); event.preventDefault(); dodrop(event);"> <
div> Fix</
div> </
div> </body> </html> This ex...
IDBDatabase.createObjectStore() - Web APIs
As the property is an identifier, it should be unique to every object, and every object should have that property. This method can be called only within a versionchange transaction. ...
IDBObjectStore - Web APIs
ey or IDBKeyRange. If no arguments are provided, it returns the total number of records in the store. IDBObjectStore.createIndex() Creates a new index during a version upgrade, returning a new IDBIndex object in the connected database. IDBObjectStore.delete() returns an IDBRequest object, and, in a separate thread, deletes the store object selected by the specified key. This is for deleting in
dividual records out of an object store. IDBObjectStore.deleteIndex() Destroys the specified index in the connected database, used during a version upgrade. IDBObjectStore.get() Returns an IDBRequest object, and, in a separate thread, returns the store object store selected by the specified key. This is for retrieving specific records from an object store. IDBObjectStore.getKey() Returns an IDB...
ImageData() - Web APIs
rray[80000] } Initializing ImageData with an array This example instantiates an ImageData object with pixel colors defined by an array. HTML <canvas id="canvas"></canvas> JavaScript The array (arr) has a length of 40000: it consists of 10,000 pixels, each of which is defined by 4 values. The ImageData constructor specifies a width of 200 for the new object, so its height defaults to 10,000
divided by 200, which is 50. const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); const arr = new Uint8ClampedArray(40000); // Iterate through every pixel for (let i = 0; i < arr.length; i += 4) { arr[i + 0] = 0; // R value arr[i + 1] = 190; // G value arr[i + 2] = 0; // B value arr[i + 3] = 255; // A value } // Initialize a new ImageData object le...
Key Values - Web APIs
Qt::Key_Multiply (0x0D7) KEYCODE_NUMPAD_MULTIPLY (155) "Add" [1] The numeric keypad's addition key, +. VK_ADD (0x6B) kVK_ANSI_KeypadPlus (0x45) GDK_KEY_KP_Add (0xFFAB) KEYCODE_NUMPAD_ADD (157) "Clear" The numeric keypad's Clear key. kVK_ANSI_KeypadClear (0x47) GDK_KEY_Clear (0xFF0B) Qt::Key_Clear (0x0100000B) KEYCODE_CLEAR (28) "
Divide" [1] The numeric keypad's
division key, /. VK_
DIVIDE (0x6F) kVK_ANSI_Keypad
Divide (0x4B) GDK_KEY_KP_
Divide (0xFFAF) Qt::Key_Slash (0x2F) KEYCODE_NUMPAD_
DIVIDE (154) "Subtract" [1] The numeric keypad's subtraction key, -. VK_SUBTRACT (0x6D) kVK_ANSI_KeypadMinus (0x4E) GDK_KEY_KP_Subtract (0xFFAD) KEYCODE_NUMPAD_SUBTRACT (156) "Separator" [...
KeyframeEffect.getKeyframes() - Web APIs
nction used from this keyframe until the next keyframe in the series. composite The KeyframeEffect.composite operation used to combine the values specified in this keyframe with the underlying value. This will be absent if the composite operation specified on the effect is being used. Examples In the Red Queen Race example, we can inspect Alice and the RedQueen's animation to see its in
dividual keyframes like so: // Return the array of keyframes redQueen_alice.effect.getKeyframes(); Specifications Specification Status Comment Web AnimationsThe definition of 'KeyframeEffect.getKeyframes()' in that specification. Working Draft Editor's draft. ...
KeyframeEffect.target - Web APIs
e An Element, CSSPseudoElement, or null. Examples In the Follow the White Rabbit example, whiteRabbit sets the target element to be animated: var whiteRabbit = document.getElementById("rabbit"); var rabbitDownKeyframes = new KeyframeEffect( whiteRabbit, [ { transform: 'translateY(0%)' }, { transform: 'translateY(100%)' } ], { duration: 3000, fill: 'forwards' } ); // returns <
div id="rabbit">Click the rabbit's ears!</
div> rabbitDownKeyframes.target; Specifications Specification Status Comment Web AnimationsThe definition of 'keyframeEffect' in that specification. Working Draft Editor's draft. ...
LocalMediaStream - Web APIs
need to update any code that does use it as soon as possible or your content or application will stop working. See Stopping a video stream in MediaStreamTrack to learn how. All other functionality is found in MediaStream. The primary reason for this interface to exist was to add a stop() method to its MediaStream parent interface. However, control over playback of media has been moved to the in
dividual MediaStreamTrack objects, so this is no longer necessary. Instead, media is stopped by calling MediaStreamTrack.stop() on each track that needs to be stopped. The example for MediaStreamTrack.stop() demonstrates how to stop a multi-track stream, which is what LocalMediaStream.stop() used to be used for. Methods LocalMediaStream.stop() Stops the stream. When the source of the stream is a...
MediaDevices.getUserMedia() - Web APIs
human-readable string explaining the problem. Because this error can occur even when the user has not yet granted permission to use the underlying device, it can potentially be used as a fingerprinting surface. SecurityError User media support is disabled on the Document on which getUserMedia() was called. The mechanism by which user media support is enabled and disabled is left up to the in
dividual user agent. TypeError The list of constraints specified is empty, or has all constraints set to false. This can also happen if you try to call getUserMedia() in an insecure context, since navigator.mediaDevices is undefined in an insecure context. Privacy and security As an API that may involve significant privacy concerns, getUserMedia()'s specification lays out a wide array of privacy...
MediaElementAudioSourceNode - Web APIs
Methods Inherits methods from its parent, AudioNode. Example This simple example creates a source from an <audio> element using createMediaElementSource(), then passes the audio through a GainNode before feeding it into the AudioDestinationNode for playback. When the mouse pointer is moved, the updatePage() function is invoked, which calculates the current gain as a ratio of mouse Y position
divided by overall window height. You can therefore increase and decrease the volume of the playing music by moving the mouse pointer up and down. Note: You can also view this example running live, or view the source. var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); var myAudio = document.querySelector('audio'); var pre = document.querySelector('pre'); var myScript = docum...
MediaKeyMessageEvent() - Web APIs
The MediaKeyMessageEvent constructor creates a new MediaKeyMessageEvent object which creates a new instance of MediaKeyMessageEvent. Syntax var mediaKeyMessageEvent = new MediaKeyMessageEvent(typeArg, options) Parameters typeArg A DOMString containing one of May be one of license-request, license-renewal, license-renewal, or in
dividualization-request. options Options are as follows: messageType: A developer-defined message type that allows applications to differentiate messages without parsing them. message: An array containing the message generated by the content decryption module. Browser Compatibility The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-com...
MediaKeyMessageEvent.messageType - Web APIs
The MediaKeyMessageEvent.messageType read-only property indicates the type of message. It may be one of license-request, license-renewal, license-release, or in
dividualization-request. Syntax var messageType = mediaKeyMessageEvent.messageType; Specifications Specification Status Comment Encrypted Media ExtensionsThe definition of 'messageType' in that specification. Recommendation Initial definition ...
MediaQueryList - Web APIs
Specifications Specification Status Comment CSS Object Model (CSSOM) View ModuleThe definition of 'MediaQueryList' in that specification. Working Draft Initial definition ...
MediaStream Recording API - Web APIs
ady for you to do with as you will; the event has a data attribute whose value is a Blob that contains the media data. You can force a dataavailable event to occur, thereby delivering the latest sound to you so you can filter it, save it, or whatever. Recording stops automatically when the source media stops playing. You can stop recording at any time by calling MediaRecorder.stop(). Note: In
dividual Blobs containing slices of the recorded media will not necessarily be in
dividually playable. The media needs to be reassembled before playback. If anything goes wrong during recording, an error event is sent to the MediaRecorder. You can listen for error events by setting up a onerror event handler. Example here, we use an HTML Canvas as source of the MediaStream, and stop recording aft...
MediaTrackConstraints.aspectRatio - Web APIs
call to MediaDevices.getSupportedConstraints(). However, typically this is unnecessary since browsers will simply ignore any constraints they're unfamiliar with. Syntax var constraintsObject = { aspectRatio: constraint }; constraintsObject.aspectRatio = constraint; Value A ConstrainDouble describing the acceptable or required value(s) for a video track's aspect ratio. The value is the width
divided by the height and is rounded to ten decimal places. For example, the standard high-definition video aspect ratio of 16:9 can be computed as 1920/1080, or 1.7777777778. If this value is a number, the user agent will attempt to obtain media whose aspect ratio is as close as possible to this number given the capabilities of the hardware and the other constraints specified. Otherwise, the value ...
MediaTrackConstraints.displaySurface - Web APIs
displaySurface ==="application") { mayHaveBackdropFlag = true; } Following this code, mayHaveBackdrop is true if the display surface contained in the stream is of type monitor or application; either of these may have non-content backdrop areas. Later code can use this flag to determine whether or not to perform special processing, such as to remove or replace the backdrop, or to "cut" the in
dividual display areas out of the received frames of video. Examples Here are some example constraints objects for getDisplayMedia() that make use of the displaySurface property. In addition, see Example: Constraint exerciser in Capabilities, constraints, and settings for a complete example showing how constraints are used. TBD Specifications Specification Status Comment ...
MediaTrackSettings.aspectRatio - Web APIs
by a call to MediaDevices.getSupportedConstraints(). However, typically this is unnecessary since browsers will simply ignore any constraints they're unfamiliar with. Syntax var aspectRatio = MediaTrackSettings.aspectRatio; Value A double-precision floating-point number indicating the current configuration of the track's aspect ratio. The aspect ratio is computed by taking the track's width,
dividing by its height, and rounding the result to ten decimal places. For example, the standard 16:9 high-definition aspect ratio can be computed as 1920/1080, or 1.7777777778. Example See Example: Constraint exerciser in Capabilities, constraints, and settings for an example. Specifications Specification Status Comment Media Capture and StreamsThe definition of 'aspe...
MediaTrackSettings - Web APIs
lue indicating the current value of the volume property, specifying the volume level of the track. This value will be between 0.0 (silent) to 1.0 (maximum supported volume). Properties of video tracks aspectRatio A double-precision floating point value indicating the current value of the aspectRatio property, specified precisely to 10 decimal places. This is the width of the image in pixels
divided by its height in pixels. Common values include 1.3333333333 (for the classic television 4:3 "standard" aspect ratio, also used on tablets such as Apple's iPad), 1.7777777778 (for the 16:9 high-definition widescreen aspect ratio), and 1.6 (for the 16:10 aspect ratio common among widescreen computers and tablets). facingMode A DOMString indicating the current value of the facingMode property,...
MediaTrackSupportedConstraints.frameRate - Web APIs
roperty is present, its value is always true. Example This simple example looks to see if your browser supports constraining the frame rate when requesting video tracks. JavaScript let result = document.getElementById("result"); if (navigator.mediaDevices.getSupportedConstraints().frameRate) { result.innerHTML = "Supported!"; } else { result.innerHTML = "Not supported!"; } HTML <
div id="result"> </
div> CSS #result { font: 14px "Arial", sans-serif; } Result The output, showing if your browser supports the frameRate constraint, is: While this example is trivial, you can replace the simple output of "Supported" vs. "Not supported" with code to provide alternative methods for presenting the audiovisual information you want to share with the user or otherwise work wi...
MouseEvent.pageX - Web APIs
r", updateDisplay, false); box.addEventListener("mouseleave", updateDisplay, false); The JavaScript code uses addEventListener() to register the function updateDisplay() as the event handler for the mousemove, mouseenter, and mouseleave events. updateDisplay() simply replaces the contents of the <span> elements meant to contain the X and Y coordinates with the values of pageX and pageY. HTML <
div class="box"> <p> Move the mouse around in this box to watch its coordinates change. </p> <p> <code>pageX</code>: <span id="x">n/a</span> </p> <p> <code>pageY</code>: <span id="y">n/a</span> </p> </
div> The HTML is simple; the box we'll be watching for mouse events on is given the class "box". It has two <span> elements, one with the ID "x" and one with the ID "y". Those w...
MutationRecord - Web APIs
It is the object that is passed to MutationObserver's callback. Properties Property Type Description MutationRecord.type String Returns "attributes" if the mutation was an attribute mutation, "characterData" if it was a mutation to a CharacterData node, and "childList" if it was a mutation to the tree of nodes. MutationRecord.target Node Returns the node the mutation affected, depending on the MutationRecord.type. For attributes, it is the element whose attribute changed. For characterData, it is the CharacterData node. For childList, it is the node whose children changed. ...
Navigator.deviceMemory - Web APIs
It is then clamped within lower and upper bounds to protect the privacy of owners of very low- or high-memory devices. Syntax memoryAmount = navigator.deviceMemory Value A floating point number; one of 0.25, 0.5, 1, 2, 4, 8. ...
Navigator - Web APIs
n Firefox 64 onwards. Navigator.credentials Returns the CredentialsContainer interface which exposes methods to request credentials and notify the user agent when interesting events occur such as successful sign in or sign out. Navigator.deviceMemory Read only Returns the amount of device memory in gigabytes. This value is an approximation given by rounding to the nearest power of 2 and
dividing that number by 1024. Navigator.doNotTrack Reports the value of the user's do-not-track preference. When this value is "yes", your web site or application should not track the user. Navigator.mediaDevices Returns a reference to a MediaDevices object which can then be used to get information about available media devices (MediaDevices.enumerateDevices()), find out what constrainable pr...
NavigatorPlugins.plugins - Web APIs
vigator.plugins array and comparing every plugin's name. This privacy change does not disable any plugins; it just hides some plugin names from enumeration. Syntax var plugins = navigator.plugins; plugins is PluginArray object used to access Plugin objects either by name or as a list of items. The returned value is not a JavaScript array, but has the length property and supports accessing in
dividual items using bracket notation (plugins[2]), as well as via item(index) and namedItem("name") methods. Examples The following example function returns the version of the Shockwave Flash plugin. function getFlashVersion() { var flash = navigator.plugins.namedItem('Shockwave Flash'); if (typeof flash != 'object') { // flash is not present return undefined; } if(flash.version){...
Node.isSupported() - Web APIs
method hasFeature on DOMImplementation. Possible values defined within the core DOM specification are listed on the DOM Level 2 Conformance Section. version Is a DOMString containing the version number of the feature to test. In DOM Level 2, version 1, this is the string 2.0. If the version is not specified, supporting any version of the feature will cause the method to return true. Example <
div id="doc"> </
div> <script> // Get an element and check to see if its supports the DOM2 HTML Module. var main = document.getElementById('doc'); var output = main.isSupported('HTML', '2.0'); </script> Specifications Specification Status Comment Document Object Model (DOM) Level 3 Core SpecificationThe definition of 'Node.isSupported()' in that specification. Obs...
Node.nodeType - Web APIs
hat the node is. It distinguishes different kind of nodes from each other, such as elements, text and comments. Syntax var type = node.nodeType; Returns an integer which specifies the type of the node. Possible values are listed in Node type constants. Constants Node type constants Constant Value Description Node.ELEMENT_NODE 1 An Element node like <p> or <
div>. Node.TEXT_NODE 3 The actual Text inside an Element or Attr. Node.CDATA_SECTION_NODE 4 A CDATASection, such as <!CDATA[[ ... ]]>. Node.PROCESSING_INSTRUCTION_NODE 7 A ProcessingInstruction of an XML document, such as <?xml-stylesheet ... ?>. Node.COMMENT_NODE 8 A Comment node, such as <!-- ... -->. Node.DOCUMENT_NODE 9 A ...
Node.normalize() - Web APIs
The Node.normalize() method puts the specified node and all of its sub-tree into a "normalized" form. In a normalized sub-tree, no text nodes in the sub-tree are empty and there are no adjacent text nodes. ...
Node.prefix - Web APIs
when a document is served with an XML MIME type. This will not work for HTML documents. ...
NodeList.entries() - Web APIs
The NodeList.entries() method returns an iterator allowing to go through all key/value pairs contained in this object. The values are Node objects. Syntax list.entries(); Return value Returns an iterator. ...
NodeList.prototype.forEach() - Web APIs
accepts 3 parameters: currentValue The current element being processed in someNodeList. currentIndex Optional The index of the currentValue being processed in someNodeList. listObj Optional The someNodeList that forEach() is being applied to. thisArg Optional Value to use as this when executing callback. Return value undefined. ...
NodeList.keys() - Web APIs
The NodeList.keys() method returns an iterator allowing to go through all keys contained in this object. The keys are unsigned integer. Syntax nodeList.keys(); Return value Returns an iterator. ...
NodeList.values() - Web APIs
The NodeList.values() method returns an iterator allowing to go through all values contained in this object. The values are Node objects. Syntax nodeList.values(); Return value Returns an iterator. ...
NodeList - Web APIs
ere are 2 varieties of NodeList: live and static. Live NodeLists In some cases, the NodeList is live, which means that changes in the DOM automatically update the collection. For example, Node.childNodes is live: const parent = document.getElementById('parent'); let child_nodes = parent.childNodes; console.log(child_nodes.length); // let's assume "2" parent.appendChild(document.createElement('
div')); console.log(child_nodes.length); // outputs "3" Static NodeLists In other cases, the NodeList is static, where any changes in the DOM does not affect the content of the collection. The ubiquitous document.querySelectorAll() method returns a static NodeList. It's good to keep this distinction in mind when you choose how to iterate over the items in the NodeList, and whether you should cach...
OfflineAudioContext.OfflineAudioContext() - Web APIs
tax var offlineAudioCtx = new OfflineAudioContext(numberOfChannels, length, sampleRate); var offlineAudioCtx = new OfflineAudioContext(options); Parameters You can specify the parameters for the OfflineAudioContext() constructor as either the same set of parameters as are inputs into the AudioContext.createBuffer() method, or by passing those parameters in an options object. Either way, the in
dividual parameters are the same. numberOfChannels An integer specifying the number of channels the resulting AudioBuffer should have. length An integer specifying the size of the buffer to create for the audio context, in sample-frames, where one sample-frame is a unit that can contain a single sample of audio data for every channel in the audio data. For example, a 5-second buffer with a samp...
ParentNode.children - Web APIs
The ParentNode property children is a read-only property that returns a live HTMLCollection which contains all of the child elements of the node upon which it was called. Syntax let children = node.children; Value An HTMLCollection which is a live, ordered collection of the DOM elements which are children of node. You can access the in
dividual child nodes in the collection by using either the item() method on the collection, or by using JavaScript array-style notation. If the node has no element children, then children is an empty list with a length of 0. Example const foo = document.getElementById('foo'); for (let i = 0; i < foo.children.length; i++) { console.log(foo.children[i].tagName); } Polyfill // Overwrites native 'children' prototype. // Adds Document & DocumentFragment ...
PaymentAddress.regionCode - Web APIs
The regionCode read-only attribute of the PaymentAddress interface returns a one-, two-, or three-alphanumeric code (DOMString) representing the region of the address (e.g., "CA" for California, or "11" for Lisbon, Portugal). The code is derived from the ISO 3166-2 standard, which defines codes for identifying the sub
divisions (e.g., states, provinces, autonomous regions, etc.) of all countries in the world. If the browser can't determine the region code, or the country doesn't use regions for postal addresses, it returns an empty string. Syntax var regionCode = paymentAddress.regionCode; Value A DOMString indicating the one to three character alphanumeric code representing the region portion of the address. This should correspond to region, but should be the ISO 3166--2 standard's r...
PaymentAddress - Web APIs
dress.postalCode Read only A DOMString specifying a code used by a jurisdiction for mail routing, for example, the ZIP code in the United States or the PIN code in India. PaymentAddress.recipient Read only A DOMString giving the name of the recipient, purchaser, or contact person at the payment address. PaymentAddress.region Read only A DOMString containing the top level administrative sub
division of the country, for example a state, province, oblast, or prefecture. PaymentAddress.regionCode Read only A DOMString specifying the region of the address, represented as a "code element" of an ISO3166-2 country sub
division name (e.g. "QLD" for Queensland, Australia, "CA" for California, and so on). PaymentAddress.sortingCode Read only A DOMString providing a postal sorting code such a...
PluginArray - Web APIs
Note: Own properties of PluginArray objects are no longer enumerable in the latest browser versions. ...
RTCIceCandidatePairStats.totalRoundTripTime - Web APIs
ts. Syntax totalRTT = rtcIceCandidatePairStats.totalRoundTripTime; Value This floating-point value indicates the total number of seconds which have elapsed between sending out STUN connectivity and consent check requests and receiving their responses, for all such requests made so far on the connection described by this candidate pair. You can calculate the average round-trip time (RTT) by
dividing this value by the value of the responsesReceived property: rtt = rtcIceCandidatePairStats.totalRoundTripTime / rtcIceCandidatePairStats.responsesReceived; Specifications Specification Status Comment Identifiers for WebRTC's Statistics APIThe definition of 'RTCIceCandidatePairStats.totalRoundTripTime' in that specification. Candidate Recommendation ...
RTCIceCandidatePairStats - Web APIs
te of the connection between the two candidates. totalRoundTripTime Optional A floating-point value indicating the total time, in seconds, that has elapsed between sending STUN requests and receiving responses to them, for all such requests made to date on this candidate pair. This includes botyh connectivity check and consent check requests. You can compute the average round trip time (RTT) by
dividing this value by responsesReceived. transportId Optional A DOMString that uniquely identifies the RTCIceTransport that was inspected to obtain the transport-related statistics (as found in RTCTransportStats) used in generating this object. Obsolete properties The following properties have been removed from the specification and should no longer be used. You should update any existing code ...
RTCInboundRtpStreamStats.qpSum - Web APIs
he VP8 codec, the QP value can be anywhere from 1 to 127 and is found in the frame header element "y_ac_qi", whose value is defined in RFC 6386: 19.2. H.264 uses a QP which ranges from 0 to 51; in this case, it's an index used to derive a scaling matrix used during the quantization process. Additionally, QP is not likely to be the only parameter the codec uses to adjust the compression. See the in
dividual codec specifications for details. Example Calculating average quantization The calculateAverageQP() function shown below computes the average QP for the given RTCStats object that contains RTP stream statistics, returning 0 if the object doesn't describe an RTP stream. function calculateAverageQP(stats) { let frameCount = 0; switch(stats.type) { case "inbound-rtp": case "rem...
RTCInboundRtpStreamStats - Web APIs
ount An integer specifying the number of times the receiver has notified the sender that some amount of encoded video data for one or more frames has been lost, using Picture Loss Indication (PLI) packets. This is only available for video streams. qpSum A 64-bit value containing the sum of the QP values for every frame decoded by this RTP receiver. You can determine the average QP per frame by
dividing this value by framesDecoded. Valid only for video streams. receiverId A string indicating which identifies the RTCAudioReceiverStats or RTCVideoReceiverStats object associated with the stream's receiver. This ID is stable across multiple calls to getStats(). remoteId A string which identifies the RTCRemoteOutboundRtpStreamStats object that provides statistics for the remote peer for this...
RTCOutboundRtpStreamStats.qpSum - Web APIs
he VP8 codec, the QP value can be anywhere from 1 to 127 and is found in the frame header element "y_ac_qi", whose value is defined in RFC 6386: 19.2. H.264 uses a QP which ranges from 0 to 51; in this case, it's an index used to derive a scaling matrix used during the quantization process. Additionally, QP is not likely to be the only parameter the codec uses to adjust the compression. See the in
dividual codec specifications for details. Example Calculating average quantization The calculateAverageQP() function shown below computes the average QP for the given RTCStats object that contains RTP stream statistics, returning 0 if the object doesn't describe an RTP stream. function calculateAverageQP(stats) { let frameCount = 0; switch(stats.type) { case "inbound-rtp": case "rem...
RTCPeerConnection: icecandidate event - Web APIs
is ongoing */ break; case "complete": /* gathering has ended */ break; } }); As you can see in this example, the icegatheringstatechange event lets you know when the value of the RTCPeerConnection property iceGatheringState has been updated. If that value is now complete, you know that ICE gathering has just ended. This is a more reliable approach than looking at the in
dividual ICE messages for one indicating that the ICE session is finished. Examples This example creates a simple handler for the icecandidate event that uses a function called sendMessage() to create and send a reply to the remote peer through the signaling server. First, an example using addEventListener(): pc.addEventListener("icecandidate", ev => { if (ev.candidate) { sendMessage({ ...
RTCPeerConnection.onconnectionstatechange - Web APIs
The RTCPeerConnection.onconnectionstatechange property specifies an EventHandler which is called to handle the connectionstatechange event when it occurs on an instance of RTCPeerConnection. This happens whenever the aggregate state of the connection changes. The aggregate state is a combination of the states of all of the in
dividual network transports being used by the connection. Syntax RTCPeerConnection.onconnectionstatechange = eventHandler; Value A function which is called by the browser when the connectionstatechange event occurs on the RTCPeerConnection. The function receives as input a single parameter, which is an object of type Event. The event object contains no special information of note; you can look at the value of the peer connection's connectionState property to determi...
RTCRtpStreamStats.qpSum - Web APIs
he VP8 codec, the QP value can be anywhere from 1 to 127 and is found in the frame header element "y_ac_qi", whose value is defined in RFC 6386: 19.2. H.264 uses a QP which ranges from 0 to 51; in this case, it's an index used to derive a scaling matrix used during the quantization process. Additionally, QP is not likely to be the only parameter the codec uses to adjust the compression. See the in
dividual codec specifications for details. Example Calculating average quantization The calculateAverageQP() function shown below computes the average QP for the given RTCRtpStreamStats object, returning 0 if the object doesn't describe an RTP stream. function calculateAverageQP(stats) { let frameCount = 0; switch(stats.type) { case "inbound-rtp": case "remote-inbound-rtp": fra...
Range.cloneContents() - Web APIs
events are duplicated as they are for the DOM Core cloneNode method. HTML id attributes are also cloned, which can lead to an invalid document through cloning. Partially selected nodes include the parent tags necessary to make the document fragment valid. Syntax documentFragment = range.cloneContents(); Example range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); documentFragment = range.cloneContents(); document.body.appendChild(documentFragment); Specifications Specification Status Comment DOMThe definition of 'Range.cloneContents()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.cloneContents()' in that ...
Range.cloneRange() - Web APIs
The Range.cloneRange() method returns a Range object with boundary points identical to the cloned Range. The returned clone is copied by value, not reference, so a change in either Range does not affect the other. Syntax clone = range.cloneRange(); Example range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); clone = range.cloneRange(); Specifications Specification Status Comment DOMThe definition of 'Range.cloneRange()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.cloneRange()' in that specification. Obsolete Initial specification. ...
Range.collapse() - Web APIs
tent, specifying a single-point in a DOM tree. To determine if a Range is already collapsed, see the Range.collapsed property. Syntax range.collapse(toStart); Parameters toStart Optional A Boolean value: true collapses the Range to its start, false to its end. If omitted, it defaults to false . Example var range = document.createRange(); referenceNode = document.getElementsByTagName("
div").item(0); range.selectNode(referenceNode); range.collapse(true); Specifications Specification Status Comment DOMThe definition of 'Range.collapse()' in that specification. Living Standard The parameter is now optional and default to false. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.collapse()' in that sp...
Range.compareBoundaryPoints() - Web APIs
nge.START_TO_START compares the start boundary-point of sourceRange to the start boundary-point of Range. If the value of the parameter is invalid, a DOMException with a NotSupportedError code is thrown. sourceRange A Range to compare boundary points with the range. Example var range, sourceRange, compare; range = document.createRange(); range.selectNode(document.getElementsByTagName("
div")[0]); sourceRange = document.createRange(); sourceRange.selectNode(document.getElementsByTagName("
div")[1]); compare = range.compareBoundaryPoints(Range.START_TO_END, sourceRange); Specifications Specification Status Comment DOMThe definition of 'Range.compareBoundaryPoints()' in that specification. Living Standard No change. Document Object Model (DOM) ...
Range.comparePoint() - Web APIs
offset is the number of child nodes between the start of the reference node. Syntax returnValue = range.comparePoint(referenceNode, offset) Parameters referenceNode The Node to compare with the Range. offset An integer greater than or equal to zero representing the offset inside the referenceNode. Example range = document.createRange(); range.selectNode(document.getElementsByTagName('
div').item(0)); returnValue = range.comparePoint(document.getElementsByTagName('p').item(0), 1); Specification Specification Status Comment DOMThe definition of 'Range.comparePoint()' in that specification. Living Standard Initial specification. ...
Range.deleteContents() - Web APIs
The Range.deleteContents() method removes the contents of the Range from the Document. Unlike Range.extractContents(), this method does not return a DocumentFragment containing the deleted content. Syntax range.deleteContents() Example range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); range.deleteContents(); Specifications Specification Status Comment DOMThe definition of 'Range.deleteContents()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.deleteContents()' in that specification. Obsolete Initial specification. ...
Range.detach() - Web APIs
The Range.detach() method does nothing. It used to disable the Range object and enable the browser to release associated resources. The method has been kept for compatibility. Syntax range.detach(); Example var range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); range.detach(); Specifications Specification Status Comment DOMThe definition of 'Range.detach()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.detach()' in that specification. Obsolete Initial specification. ...
Range.extractContents() - Web APIs
re also cloned, which can lead to an invalid document if a partially-selected node is extracted and appended to the document. Partially selected nodes are cloned to include the parent tags necessary to make the document fragment valid. Syntax documentFragment = range.extractContents(); Example Basic example var range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); var documentFragment = range.extractContents(); document.body.appendChild(documentFragment); Moving items between containers This example lets you move items between two containers. Select one or more item, and then click "swap" to move them to the opposite container. HTML <p id="list1">123456</p> <button id="swap">Swap selected item(s)</button> <p id="list2">abcdef</p> CSS bod...
Range.getBoundingClientRect() - Web APIs
bject that bounds the contents of the range; this is a rectangle enclosing the union of the bounding rectangles for all the elements in the range. This method is useful for determining the viewport coordinates of the cursor or selection inside a text box. See Element.getBoundingClientRect() for details on the returned value. Syntax boundingRect = range.getBoundingClientRect() Example HTML <
div id="highlight"></
div> <p>This example positions a "highlight" rectangle behind the contents of a range. The range's content <b>starts here</b> and continues on until it <b>ends here</b>. The bounding client rectangle contains everything selected in the range.</p> CSS #highlight { background: yellow; position: absolute; z-index: -1; } p { width: 200px; } JavaScript const range = docum...
Range.getClientRects() - Web APIs
The Range.getClientRects() method returns a list of DOMRect objects representing the area of the screen occupied by the range. This is created by aggregating the results of calls to Element.getClientRects() for all the elements in the range. Syntax rectList = range.getClientRects() Example range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); rectList = range.getClientRects(); Specification Specification Status Comment CSS Object Model (CSSOM) View ModuleThe definition of 'Range.getClientRects()' in that specification. Working Draft Initial specification. ...
Range.insertNode() - Web APIs
w node is a document fragment, the children of the document fragment are inserted instead. Syntax range.insertNode(newNode); Parameters newNode The Node to insert at the start of the range. Example range = document.createRange(); newNode = document.createElement("p"); newNode.appendChild(document.createTextNode("New Node Inserted Here")); range.selectNode(document.getElementsByTagName("
div").item(0)); range.insertNode(newNode); Specifications Specification Status Comment DOMThe definition of 'Range.insertNode()' in that specification. Living Standard No change Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.insertNode()' in that specification. Obsolete Initial definition ...
Range.intersectsNode() - Web APIs
The Range.intersectsNode() method returns a boolean indicating whether the given Node intersects the Range. Syntax bool = range.intersectsNode( referenceNode ) Parameters referenceNode The Node to compare with the Range. Example var range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); var bool = range.intersectsNode(document.getElementsByTagName("p").item(0)); Specification Specification Status Comment DOMThe definition of 'Range.intersectNode()' in that specification. Living Standard Initial definition. ...
Range.isPointInRange() - Web APIs
he Range. It returns true if the point (cursor position) at offset within ReferenceNode is within this range. Syntax bool = range.isPointInRange( referenceNode, offset ) Parameters referenceNode The Node to compare with the Range. offset The offset into Node of the point to compare with the Range. Example range = document.createRange(); range.selectNode(document.getElementsByTagName("
div").item(0)); bool = range.isPointInRange(document.getElementsByTagName("p").item(0),1); Specification Specification Status Comment DOMThe definition of 'Range.isPointInRange()' in that specification. Living Standard Initial definition. ...
Range.selectNode() - Web APIs
The Range.selectNode() method sets the Range to contain the Node and its contents. The parent Node of the start and end of the Range will be the same as the parent of the referenceNode. Syntax range.selectNode(referenceNode); Parameters referenceNode The Node to select within a Range. Example let range = document.createRange(); let referenceNode = document.getElementsByTagName('
div').item(0); range.selectNode(referenceNode); Specifications Specification Status Comment DOMThe definition of 'Range.selectNode()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.selectNode()' in that specification. Obsolete Initial specification. ...
Range.selectNodeContents() - Web APIs
end of the Range will be the reference node. The startOffset is 0, and the endOffset is the number of child Nodes or number of characters contained in the reference node. Syntax range.selectNodeContents(referenceNode); Parameters referenceNode The Node whose contents will be selected within a Range. Example range = document.createRange(); referenceNode = document.getElementsByTagName("
div")[0]; range.selectNodeContents(referenceNode); Live sample This example lets the user select and deselect a paragraph with buttons. Document.createRange(), Range.selectNodeContents(), and Selection.addRange() are used to select the content. Window.getSelection() and Selection.removeAllRanges() are used to deselect it. HTML <p id="p"><b>Use the buttons below</b> to select or deselect the cont...
Range.setEndAfter() - Web APIs
The Range.setEndAfter() method sets the end position of a Range relative to another Node. The parent Node of end of the Range will be the same as that for the referenceNode. Syntax range.setEndAfter(referenceNode); Parameters referenceNode The Node to end the Range after. Example var range = document.createRange(); var referenceNode = document.getElementsByTagName('
div').item(0); range.setEndAfter(referenceNode); Specifications Specification Status Comment DOMThe definition of 'Range.setEndAfter()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.setEndAfter()' in that specification. Obsolete Initial specification. ...
Range.setEndBefore() - Web APIs
The Range.setEndBefore() method sets the end position of a Range relative to another Node. The parent Node of end of the Range will be the same as that for the referenceNode. Syntax range.setEndBefore(referenceNode); Parameters referenceNode The Node to end the Range before. Example var range = document.createRange(); var referenceNode = document.getElementsByTagName("
div").item(0); range.setEndBefore(referenceNode); Specifications Specification Status Comment DOMThe definition of 'Range.setEndBefore()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.setEndBefore()' in that specification. Obsolete Initial specification. ...
Range.setStartAfter() - Web APIs
The Range.setStartAfter() method sets the start position of a Range relative to a Node. The parent Node of the start of the Range will be the same as that for the referenceNode. Syntax range.setStartAfter(referenceNode); Parameters referenceNode The Node to start the Range after. Example var range = document.createRange(); var referenceNode = document.getElementsByTagName("
div").item(0); range.setStartAfter(referenceNode); Specifications Specification Status Comment DOMThe definition of 'Range.setStartAfter()' in that specification. Living Standard No change. Document Object Model (DOM) Level 2 Traversal and Range SpecificationThe definition of 'Range.setStartAfter()' in that specification. Obsolete Initial specification. ...
SpeechRecognitionEvent.results - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; } Specifica...
SpeechRecognitionEvent - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; } Specifica...
SpeechRecognitionResult.isFinal - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; console.l...
SpeechRecognitionResult.item() - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; } Specifica...
SpeechRecognitionResult.length - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; console.l...
SpeechRecognitionResult - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; } Specifica...
SpeechRecognitionResultList.item() - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; } Specifica...
SpeechRecognitionResultList.length - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; console.l...
SpeechRecognitionResultList - Web APIs
SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object // The SpeechRecognitionResultList object contains SpeechRecognitionResult objects. // It has a getter so it can be accessed like an array // The first [0] returns the SpeechRecognitionResult at position 0. // Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain in
dividual results. // These also have getters so they can be accessed like arrays. // The second [0] returns the SpeechRecognitionAlternative at position 0. // We then return the transcript property of the SpeechRecognitionAlternative object var color = event.results[0][0].transcript; diagnostic.textContent = 'Result received: ' + color + '.'; bg.style.backgroundColor = color; } Specifica...
StorageEstimate - Web APIs
d by the StorageManager to provide estimates of the size of a site's or application's data store and how much of it is in use. The estimate() method returns an object that conforms to this dictionary when its Promise resolves. These values are only estimates for several reasons, including both performance and preventing storage capacity data from being used for fingerprinting purposes. See the in
dividual property pages for details. Properties quota Secure context A numeric value in bytes which provides a conservative approximation of the total storage the user's device or computer has available for the site origin or Web app. It's possible that there's more than this amount of space available though you can't rely on that being the case. usage Secure context A numeric value in bytes a...
Stylesheet.href - Web APIs
of the StyleSheet interface returns the location of the style sheet. Syntax uri = stylesheet.href Parameters uri is a string containing the stylesheet's URI. Example // on a local machine: <html> <head> <link rel="StyleSheet" href="example.css" type="text/css" /> <script> function sref() { alert(document.styleSheets[0].href); } </script> </head> <body> <
div class="thunder">Thunder</
div> <button onclick="sref()">ss</button> </body> </html> // returns "file:////C:/Windows/Desktop/example.css Notes If the style sheet is a linked style sheet, the value of its attribute is its location. For inline style sheets, the value of this attribute is NULL. This property is read-only in Firefox, Opera, Google Chrome, and Safari, and it is read/write in I...
TextTrackList - Web APIs
Properties This interface also inherits properties from its parent interface, EventTarget. length Read only The number of tracks in the list. ...
Touch.radiusX - Web APIs
described by radiusX and radiusY is rotated clockwise about its center. The following simple code snippet, registers a single handler for the touchstart, touchmove and touchend events. When the src element is touched, the element's width and height will be calculate based on the touch point's radiusX and radiusY values and the element will then be rotated using the touch point's rotationAngle. <
div id="src"> ... </
div> var src = document.getElementById("src"); src.addEventListener('touchstart', rotate); src.addEventListener('touchmove', rotate); src.addEventListener('touchend', rotate); function rotate (e) { var touch = e.changedTouches.item(0); // Turn off default event handling e.preventDefault(); // Rotate element 'src'. src.style.width = touch.radiusX * 2 + 'px'; src.s...
URL - Web APIs
port A USVString containing the port number of the URL. protocol A USVString containing the protocol scheme of the URL, including the final ':'. search A USVString indicating the URL's parameter string; if any parameters are provided, this string includes all of them, beginning with the leading ? character. searchParams Read only A URLSearchParams object which can be used to access the in
dividual query parameters found in search. username A USVString containing the username specified before the domain name. Methods toString() Returns a USVString containing the whole URL. It is a synonym for URL.href, though it can't be used to modify the value. toJSON() Returns a USVString containing the whole URL. It returns the same string as the href property. Static methods createO...
URL API - Web APIs
de snippet above, the value returned by addr.href is https://someguy@mysite.com/login. This is true for any of the writable properties. Queries The search property on a URL contains the query string portion of the URL. For example, if the URL is https://mysite.com/login?user=someguy&page=news, then the value of the search property is ?user=someguy&page=news. ...
USBEndpoint - Web APIs
aranteed to be delivered or generate an error and is also given dedicated bus time for transmission. "isochronous" - Provides unreliable data transfer for payloads that must be delivered periodically. They are given dedicated bus time but if a deadline is missed the data is dropped. USBEndpoint.packetSize Returns the size of the packets that data sent through this endpoint will be
divided into. Examples While sometimes the developer knows ahead of time the exact layout of a device's endpoints there are cases where this must be discovered at runtime. For example, a USB serial device must provide bulk input and output endpoints but their endpoint numbers will depend on what other interfaces the device provides. This code identifies the correct endpoints by searching for the ...
USBIsochronousInTransferPacket - Web APIs
Constructor USBIsochronousInTransferPacket.USBIsochronousInTransferPacket() Creates a new USBIsochronousInTransferPacket object with the provided status and data fields. ...
USBIsochronousInTransferResult - Web APIs
om the USB device to the USB host. Constructor USBIsochronousInTransferResult.USBIsochronousInTransferResult() Creates a new USBIsochronousInTransferResult object with the provided packets and data fields. Properties USBIsochronousInTransferResult.dataRead only Returns a DataView object containing the data received from the device. This is the combined data from all packets. See the in
dividual DataView objects in the packets array for the portion of this buffer containing data from each packet. USBIsochronousInTransferResult.packetsRead only Returns an array of USBIsochronousInTransferPacket objects containing the result of each request to receive a packet from the device. Specifications Specification Status Comment WebUSBThe definition of 'USBIsochro...
USBIsochronousOutTransferPacket - Web APIs
Constructor USBIsochronousOutTransferPacket.USBIsochronousOutTransferPacket() Creates a new USBIsochronousOutTransferPacket object with the provided status and bytesWritten fields. ...
ValidityState.stepMismatch - Web APIs
oes not conform to the constraints set by the element's step attribute. If the field is numeric in nature, including the date, month, week, time, datetime-local, number and range types and the step value is not any, if the value don't doesn't conform to the constraints set by the step and min values, then stepMismatch will be true. If the remainder of the form control's value less the min value,
divided by the step value (which defaults to 1 if ommitted) is not zero, there is a mismatch. Given the following: <input type="number" min="20" max="40" step="2"/> if (value - min) / 2 != 0, stepMismatch will be true. If true, the element matches the :invalid and :out-of-range CSS pseudo-classes. Specifications Specification Status Comment HTML Living StandardThe defin...
ValidityState - Web APIs
rangeUnderflow Read only A Boolean that is true if the value is less than the minimum specified by the min attribute, or false if it is greater than or equal to the minimum. If true, the element matches the :invalid and :out-of-range CSS pseudo-classes. stepMismatch Read only A Boolean that is true if the value does not fit the rules determined by the step attribute (that is, it's not evenly
divisible by the step value), or false if it does fit the step rule. If true, the element matches the :invalid and :out-of-range CSS pseudo-classes. tooLong Read only A Boolean that is true if the value exceeds the specified maxlength for HTMLInputElement or HTMLTextAreaElement objects, or false if its length is less than or equal to the maximum length. Note: This property is never true in Gecko, ...
VideoTrack - Web APIs
eBuffer Read only The SourceBuffer that created the track. Returns null if the track was not created by a SourceBuffer or the SourceBuffer has been removed from the MediaSource.sourceBuffers attribute of its parent media source. Usage notes To get a VideoTrack for a given media element, use the element's videoTracks property, which returns a VideoTrackList object from which you can get the in
dividual tracks contained in the media: var el = document.querySelector("video"); var tracks = el.videoTracks; You can then access the media's in
dividual tracks using either array syntax or functions such as forEach(). This first example gets the first video track on the media: var firstTrack = tracks[0]; The next example scans through all of the media's video tracks, activating the first video...
VideoTrackList - Web APIs
Properties This interface also inherits properties from its parent interface, EventTarget. length Read only The number of tracks in the list. ...
WebGL2RenderingContext - Web APIs
uniformMatrix[234]x[234]fv() Methods specifying matrix values for uniform variables. WebGL2RenderingContext.vertexAttribI4[u]i[v]() Methods specifying integer values for generic vertex attributes. WebGL2RenderingContext.vertexAttribIPointer() Specifies integer data formats and locations of vertex attributes in a vertex attributes array. Drawing buffers WebGL2RenderingContext.vertexAttrib
Divisor() Modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with gl.drawArraysInstanced() and gl.drawElementsInstanced(). WebGL2RenderingContext.drawArraysInstanced() Renders primitives from array data. In addition, it can execute multiple instances of the range of elements. WebGL2RenderingContext.drawElementsInstanced() Renders primitiv...
WebGLRenderingContext.getVertexAttrib() - Web APIs
_VERTEX_ATTRIB: Returns a Float32Array (with 4 elements) representing the current value of the vertex attribute at the given index. When using a WebGL 2 context, the following values are available additionally: gl.VERTEX_ATTRIB_ARRAY_INTEGER: Returns a GLboolean indicating whether or not an integer data type is in the vertex attribute array at the given index. gl.VERTEX_ATTRIB_ARRAY_
DIVISOR: Returns a GLint describing the frequency
divisor used for instanced rendering. When using the ANGLE_instanced_arrays extension: ext.VERTEX_ATTRIB_ARRAY_
DIVISOR_ANGLE: Returns a GLint describing the frequency
divisor used for instanced rendering. Return value Returns the requested vertex attribute information (as specified with pname). Examples gl.getVertexAtt...
WebGLRenderingContext.stencilMaskSeparate() - Web APIs
The WebGLRenderingContext.stencilMaskSeparate() method of the WebGL API controls enabling and disabling of front and/or back writing of in
dividual bits in the stencil planes. The WebGLRenderingContext.stencilMask() method can set both, the front and back stencil writemasks to one value at the same time. Syntax void gl.stencilMaskSeparate(face, mask); Parameters face A GLenum specifying whether the front and/or back stencil writemask is updated. The possible values are: gl.FRONT gl.BACK gl.FRONT_AND_BACK mask A GLuint specifying a bit mask to enable or disable writing of in
dividual bits in the stencil planes. By default, the mask is all 1. Return value None. Examples gl.stencilMaskSeparate(gl.FRONT, 110101); To get the current stencil masks, query the STENCIL_WRI...
WebGLRenderingContext.vertexAttrib[1234]f[v]() - Web APIs
ointer are context-global, i.e. they aren't part of the shader state (like generix vertex attribute indexes to shader variable bindings) and aren't part of the vertex array object state (like enabled vertex attribute arrays). The only way to change the values is by calling this function again. ...
WebGLRenderingContext - Web APIs
le coverage parameters for anti-aliasing effects. WebGLRenderingContext.stencilFunc() Sets the both front and back function and reference value for stencil testing. WebGLRenderingContext.stencilFuncSeparate() Sets the front and/or back function and reference value for stencil testing. WebGLRenderingContext.stencilMask() Controls enabling and disabling of both the front and back writing of in
dividual bits in the stencil planes. WebGLRenderingContext.stencilMaskSeparate() Controls enabling and disabling of front and/or back writing of in
dividual bits in the stencil planes. WebGLRenderingContext.stencilOp() Sets both the front and back-facing stencil test actions. WebGLRenderingContext.stencilOpSeparate() Sets the front and/or back-facing stencil test actions. Buffers WebGLRende...
WebGL by example - Web APIs
rt explanations that showcase WebGL concepts and capabilities. The examples are sorted according to topic and level of difficulty, covering the WebGL rendering context, shader programming, textures, geometry, user interaction, and more. Examples by topic The examples are sorted in order of increasing difficulty. But rather than just presenting them in a single long list, they are additionally
divided into topics. Sometimes we revisit a topic several times, such as when needing to discuss it initially at a basic level, and later at intermediate and advanced levels. Instead of trying to juggle shaders, geometry, and working with GPU memory, already in the first program, the examples here explore WebGL in an incremental way. We believe that it leads to a more effective learning experience a...
Creating 3D objects using WebGL - Web APIs
<< PreviousNext >> Let's take our square plane into three dimensions by adding five more faces to create a cube. To do this efficiently, we're going to switch from drawing using the vertices directly by calling the gl.drawArrays() method to using the vertex array as a table, and referencing in
dividual vertices in that table to define the positions of each face's vertices, by calling gl.drawElements(). Consider: each face requires four vertices to define it, but each vertex is shared by three faces. We can pass a lot fewer data around by building an array of all 24 vertices, then referring to each vertex by its index into that array instead of moving entire sets of coordinates around. If you wonder why we need 24 vertices, and not just 8, it is because each corner belongs to three fa...
WebGL best practices - Web APIs
que pioneered by the Google Maps team is the notion of a per-pixel VRAM budget: 1) For one system (e.g. a particular desktop / laptop), decide the maximum amount of VRAM your application should use. 2) Compute the number of pixels covered by a maximized browser window. E.g. (window.innerWidth * devicePixelRatio) * (window.innerHeight * window.devicePixelRatio) 3) The per-pixel VRAM budget is (1)
divided by (2), and is a constant. This constant should generally be portable among systems. Mobile devices typically have smaller screens than powerful desktop machines with large monitors. Re-compute this constant on a few target systems to get a reliable estimate. Now adjust all internal caching in the application (WebGLBuffers, WebGLTextures, etc.) to obey a maximum size, computed by this const...
WebRTC coding guide - Web APIs
Once you have an overall understanding of what WebRTC does and how it works, your mind likely turns to implementation. How do you create a Web application that uses two-way video or data streams without having to do all the hard work of compressing frames, building streams, and so forth by yourself? This coding guide will explain in depth how WebRTC works, and will
dive into actual code that uses WebRTC to do useful things. There are no subpages at this time. If you need to learn more about the fundamentals of how WebRTC and its protocols work, check out our High-level guides for WebRTC. ...
WebRTC connectivity - Web APIs
, indicating that there isn't a pending description. The pendingLocalDescription contains not just the offer or answer under consideration, but any local ICE candidates which have already been gathered since the offer or answer was created. Similarly, pendingRemoteDescription includes any remote ICE candidates which have been provided by calls to RTCPeerConnection.addIceCandidate(). See the in
dividual articles on these properties and methods for more specifics, and Codecs used by WebRTC for information about codecs supported by WebRTC and which are compatible with which browsers. The codecs guide also offers guidance to help you choose the best codecs for your needs. ICE candidates As well as exchanging information about the media (discussed above in Offer/Answer and SDP), peers must ex...
Establishing a connection: The WebRTC perfect negotiation pattern - Web APIs
: pc.localDescription); } } else if (candidate) { try { await pc.addIceCandidate(candidate); } catch(err) { if (!ignoreOffer) { throw err; } } } } catch(err) { console.error(err); } } While the difference in code size is minor, and the complexity isn't reduced much either, the code is much, much more reliable. Let's take a
dive into the code to see how it works now. On receiving a description In the revised code, if the received message is an SDP description, we check to see if it arrived while we're attempting to transmit an offer. If the received message is an offer and the local peer is the impolite peer, and a collision is occurring, we ignore the offer because we want to continue to try to use the offer that's a...
Lifetime of a WebRTC session - Web APIs
tion than 32-bit addresses would last, so other smart people came up with a way to let multiple computers share the same 32-bit IP address. Network Address Translation (NAT) is a standard which supports this address sharing by handling routing of data inbound and outbound to and from devices on a LAN, all of which are sharing a single WAN (global) IP address. The problem for users is that each in
dividual computer on the Internet no longer necessarily has a unique IP address, and, in fact, each device's IP address may change not only if they move from one network to another, but if their network's address is changed by NAT and/or DHCP. For developers trying to do peer-to-peer networking, this introduces a conundrum: without a unique identifier for every user device, it's not possible to insta...
Using WebRTC data channels - Web APIs
efficient routines that make sure there's always data ready to send without over-using memory or swamping the channel completely. <<<write more about using bufferedAmount, bufferedAmountLowThreshold, onbufferedamountlow, and bufferedamountlow here>>> ... Understanding message size limits For any data being transmitted over a network, there are size restrictions. At a fundamental level, the in
dividual network packets can't be larger than a certain value (the exact number depends on the network and the transport layer being used). At the application level--that is, within the user agent's implementation of WebRTC on which your code is running--the WebRTC implementation implements features to support messages that are larger than the maximum packet size on the network's transport layer. Th...
WebRTC Statistics API - Web APIs
transport Statistics about a transport used by the connection. RTCTransportStats RTCStats Specifications Specification Status Comment Identifiers for WebRTC's Statistics APIThe definition of 'WebRTC statistics types' in that specification. Candidate Recommendation Compatibility for in
dividual statistic types WebRTC 1.0: Real-time Communication Between BrowsersThe definition of 'RTCStatsReport' in that specification. Candidate Recommendation Compatibility of statistic reporting ...
Writing a WebSocket server in C# - Web APIs
et"); Console.WriteLine(); } } } } client.html <!doctype html> <style> textarea { vertical-align: bottom; } #output { overflow: auto; } #output > p { overflow-wrap: break-word; } #output span { color: blue; } #output span.error { color: red; } </style> <h2>WebSocket Test</h2> <textarea cols=60 rows=6></textarea> <button>send</button> <
div id=output></
div> <script> // http://www.websocket.org/echo.html var button = document.querySelector("button"), output = document.querySelector("#output"), textarea = document.querySelector("textarea"), // wsUri = "ws://echo.websocket.org/", wsUri = "ws://127.0.0.1/", websocket = new WebSocket(wsUri); button.addEventListener("click", onClickBut...
Fundamentals of WebXR - Web APIs
or a headset of some kind. A VR headset is worn on the head, with a strap that goes behind the head to fasten it in place, and one or two displays whose screens are focused into the eyes using lenses. By presenting a slightly different image to each eye, the illusion of depth is created, giving the user a simulated 3D experience. The vast majority of headsets use a single display whose frame is
divided in half, with one half focused onto each of the user's eyes. For example, if a headset uses a 2560x1440 screen, with the left half being used for the left eye's view and the right half or the right eye's view, the framebuffer is used like this: The simplest headsets have no integrated sensors, and simply focus each half of the screen into the corresponding eye. A common example of this is ...
Inputs and input sources - Web APIs
ze action describes this in more detail. Any additional capabilities a WebXR controller may have are accessed through the input source's gamepad object. This object provides access to all of the buttons, axes, trackpads, and so forth that may be a part of the controller. See Advanced controllers using the gamepad object to learn how to use these controllers. Properties of input sources Each in
dividual XRInputSource has a set of properties that describe the input's available axes and buttons, which hand the user's holding it in, and how the input source is used to handle targeting within the 3D space. Handedness Handedness, indicated by the XRInputSource property handedness, is a string which indicates which of the viewer's hands the controller is in: left or right. It can also be set to...
WebXR application life cycle - Web APIs
This serves as preparation for the next few articles in these WebXR guides, which cover starting up and shutting down a WebXR session, geometry, simulating cameras, spatial tracking, and more. Life cycle outline Most applications using WebXR will follow a similar overall design pattern: Check to see if the user's device and browser are both capable of presenting the XR experience you want to provide. ...
WebXR performance guide - Web APIs
iables through which various vectors, matrices, and quaternions pass over time. It makes sense, then, to have a limited set of these objects, simply replacing their contents with the new information each time you need to use them. They can be thought of as being similar to the registers in a microprocessor: a limited set of memory storage slots for specific kinds of data or use cases. While an in
dividual vector or matrix doesn't occupy an inordinate amount of memory, the sheer number of vectors and matrices and other structures that are used to build each frame of a 3D scene means the memory management becomes a problem eventually if you keep allocating and de-allocating memory objects. Consider the following function drawScene(gl, view, programInfo, buffers, texture, deltaTime) { ... ...
Targeting and hit detection - Web APIs
involve not only interpreting the imagery from the device's camera (if available) but also potentially multiple additional sensors. Some devices include infrared sensors to help range objects, and others provide powerful LIDAR systems, which use lasers (usually infrared lasers, which can't be seen by the human eye) to determine range to objects in the world. The details of how to work with an in
dividual platform's ranging system is beyond the scope of this article. However, there's hope: a proposal has been floated for a WebXR Hit Test Module that would layer atop WebXR to provide an API for performing hit testing and collision detection. ...
Basic concepts behind Web Audio API - Web APIs
s. When a buffer plays, you will hear the left most sample frame, and then the one right next to it, etc. In the case of stereo, you will hear both channels at the same time. Sample frames are very useful, because they are independent of the number of channels, and represent time, in a useful way for doing precise audio manipulation. Note: To get a time in seconds from a frame count, simply
divide the number of frames by the sample rate. To get a number of frames from a number of samples, simply
divide by the channel count. Here's a couple of simple examples: var context = new AudioContext(); var buffer = context.createBuffer(2, 22050, 44100); Note: In digital audio, 44,100 Hz (alternately represented as 44.1 kHz) is a common sampling frequency. Why 44.1kHz? Firstly, because th...
Window.content - Web APIs
refers to the Window of the currently selected tab). Note: Some examples use _content instead of content. The former has been deprecated for a long time, and you should use content in any new code. Syntax var windowObject = window.content; Example Executing the following code in a chrome XUL window with a <browser type="content-primary"/> element in it draws a red border around the first
div on the page currently displayed in the browser: content.document.getElementsByTagName("
div")[0].style.border = "solid red 1px"; Specification None. See also Working with windows in chrome code When accessing content documents from privileged code, be aware of XPCNativeWrappers. ...
Window.getComputedStyle() - Web APIs
Syntax var style = window.getComputedStyle(element [, pseudoElt]); element The Element for which to get the computed style. pseudoEltOptional A string specifying the pseudo-element to match. Omitted (or null) for real elements. ...
Window: load event - Web APIs
o Cancelable No Interface Event Event handler property onload Examples Log a message when the page is fully loaded: window.addEventListener('load', (event) => { console.log('page is fully loaded'); }); The same, but using the onload event handler property: window.onload = (event) => { console.log('page is fully loaded'); }; Live example HTML <
div class="controls"> <button id="reload" type="button">Reload</button> </
div> <
div class="event-log"> <label>Event log:</label> <textarea readonly class="event-log-contents" rows="8" cols="30"></textarea> </
div> CSS body { display: grid; grid-template-areas: "control log"; } .controls { grid-area: control; display: flex; align-items: center; justify-content: center; } .event...
self.createImageBitmap() - Web APIs
indicates the output height. resizeQuality: Specifies the algorithm to be used for resizing the input to match the output dimensions. One of pixelated, low (default), medium, or high. Return value A Promise which resolves to an ImageBitmap object containing bitmap data from the given rectangle. Example Creating sprites from a sprite sheet This example loads a sprite sheet, extracts in
dividual sprites, and then renders each sprite to the canvas. A sprite sheet is an image containing multiple smaller images, each of which you want to be able to render separately. var canvas = document.getElementById('myCanvas'), ctx = canvas.getContext('2d'), image = new Image(); // Wait for the sprite sheet to load image.onload = function() { Promise.all([ // Cut out two sprites from the s...
XRInputSourcesChangeEvent() - Web APIs
this constructor yourself, as these events are created and sent to you by the WebXR system. Syntax newInputSourcesChangeEvent = new XRInputSourcesChangeEvent(type, eventInitDict); Parameters type A DOMString indicating the type of event which has occurred. This string must always be inputsourceschange. eventInitDict An object conforming to the XRInputSourcesChangeEventInit dictionary, pro
dividing the initial values for the event. Return value A newly-created XRInputSourcesChangeEvent object configured based upon the input parameters provided. Event types inputsourceschange Delivered to the XRSession when the set of input devices available to it changes. Example The following snippet of code creates a new XRInputSourcesChangeEvent object indicating that a single new input s...
XRWebGLLayer.getNativeFramebufferScaleFactor() static method - Web APIs
of 1280x1440 pixels). Consider a frame buffer which at full size looks like this: If, on this device, it's determined that due to GPU limitations the browser needs to reduce image quality in order to improve performance to an acceptable level, it might choose to halve the resolution. In this case, the value returned by XRWebGLLayer.getNativeFramebufferScaleFactor() will be 2.0. This method of
dividing the frame buffer between views is shown in the following diagram. Now the width and height of the frame buffer are 50% what they were before, resulting in a total frame buffer size of 1280 by 720 pixels, with each eye's half of the buffer being 640x720 pixels. Now we can see the coordinates of each of the viewports representing these two views: Since each eye gets half of the frame buf...
Web APIs
tes GeolocationPosition GeolocationPositionError GeometryUtils GestureEvent GlobalEventHandlers Gyroscope H HTMLAnchorElement HTMLAreaElement HTMLAudioElement HTMLBRElement HTMLBaseElement HTMLBaseFontElement HTMLBodyElement HTMLButtonElement HTMLCanvasElement HTMLCollection HTMLContentElement HTMLDListElement HTMLDataElement HTMLDataListElement HTMLDetailsElement HTMLDialogElement HTML
DivElement HTMLDocument HTMLElement HTMLEmbedElement HTMLFieldSetElement HTMLFontElement HTMLFormControlsCollection HTMLFormElement HTMLFrameSetElement HTMLHRElement HTMLHeadElement HTMLHeadingElement HTMLHtmlElement HTMLHyperlinkElementUtils HTMLIFrameElement HTMLImageElement HTMLInputElement HTMLIsIndexElement HTMLKeygenElement HTMLLIElement HTMLLabelElement HTMLLegendElement HTMLLinkElemen...
Using the aria-invalid attribute - Accessibility
} else { elem.setAttribute("aria-invalid", "false"); updateAlert(); } } The snippet below shows the alert functions, which add (or remove) the error message: function updateAlert(msg) { var oldAlert = document.getElementById("alert"); if (oldAlert) { document.body.removeChild(oldAlert); } if (msg) { var newAlert = document.createElement("
div"); newAlert.setAttribute("role", "alert"); newAlert.setAttribute("id", "alert"); var content = document.createTextNode(msg); newAlert.appendChild(content); document.body.appendChild(newAlert); } } Note that the alert has the ARIA role attribute set to "alert." Working Examples: Alert role example (uses the aria-invalid attribute) Notes When ari...
Using the aria-valuemax attribute - Accessibility
not less than or equal to the value of aria-valuemax, this creates an error condition that will be handled by the assistive technology. Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: The snippet below shows a simple slider with a maximum value of 10. ...
Using the aria-valuemin attribute - Accessibility
not less than or equal to the value of aria-valuemax, this creates an error condition that will be handled by the assistive technology. Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: The snippet below shows a simple slider with a minimum value of 1. ...
Using the aria-valuenow attribute - Accessibility
with a percent indicator. For elements with role slider and spinbutton, assistive technologies SHOULD render the actual value to users. Note: Opinions may differ on how assistive technology should handle this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: The snippet below shows a simple slider with a current value of 4. ...
Using the aria-valuetext attribute - Accessibility
e this technique. The information provided above is one of those opinions and therefore not normative. Examples Example 1: The snippet below shows a simple slider for selecting a day of the week. The value of the slider is numeric, and the aria-valuetext attribute is used to provide the name of the day. The application would programmatically update aria-valuetext depending on aria-valuenow. ...
x-ms-aria-flowfrom - Accessibility
ource order. The property serves to define element relationships utilizing ARIA relationship attributes and the aria-flowto property. This proprietary property is specific to Internet Explorer and Microsoft Edge. ...
Using ARIA: Roles, states, and properties - Accessibility
Authors must assign an ARIA role and the appropriate states and properties to an element during its life-cycle, unless the element already has appropriate ARIA semantics (via use of an appropriate HTML element). Addition of ARIA semantics only exposes extra information to a browser's accessibility API, and does not affect a page's DOM. ...
ARIA: tabpanel role - Accessibility
A use is you can use a native feature with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so. Then post full details in best practices section below. Examples Fill in a simple example that nicely shows a typical usage of the property, then perhaps some more complex examples. <
div role="tablist"> <
div role="tab" aria-selected="true" aria-controls="tabpanel-id" id="tab-id" tabindex="0">Tab label</
div> Accessibility concerns Optionally, warn of any potential accessibility concerns that exist with using this property, and how to work around them. Remove this section if there are none to list. Best practices Optionally, here list any best practices that exist for this rol...
ARIA: application role - Accessibility
The application role indicates to assistive technologies that an element and all of its children should be treated similar to a desktop application, and no traditional HTML interpretation techniques should be used. This role should only be used to define very dynamic and desktop-like web applications. <
div role="application">...</
div> This defines this
div element and all of its descendants to be treated like they are part of a desktop application. Description The application role indicates to assistive technologies that this part of the web content contains elements that do not conform to any other known HTML element or WAI-ARIA widget. Any sort of special interpretation of HTML structures and widgets should be suspended, and control should be completely handed over to the browser and ...
ARIA: document role - Accessibility
Generally used in complex composite widgets or applications, the document role can inform assistive technologies to switch context to a reading mode: The document role tells assistive technologies with reading or browse modes to use the document mode to read the content contained within this element. <
div role="dialog"> ... <
div id="InfoText" role="document" tabindex="0"> <p>Some informational text goes here.</p> </
div> ... <button>Close</button> </
div> This example shows a dialog widget with some controls and a section with some informational text that the assistive technology user can read when tabbing to it. Description By default, web pages are treated as documents; assistive technologies (AT) enter browse or read mode when entering a new web page. This mode can be altered th...
ARIA: List role - Accessibility
The ARIA list role can be used to identify a list of items. It is normally used in conjunction with the listitem role, which is used to identify a list item contained inside the list. <section role="list"> <
div role="listitem">List item 1</
div> <
div role="listitem">List item 2</
div> <
div role="listitem">List item 3</
div> </section> Description Any content that consists of an outer container with a list of elements inside it can be identified to assistive technologies using the list and listitem containers respectively. A list must have one or more listitem children, or, alternatively, have one or more groups as children, with each group having one or more listitems as children. There are no hard and fast rules about which elements you should use to markup the list and list items, ...
ARIA: Listitem role - Accessibility
The ARIA listitem role can be used to identify an item inside a list of items. It is normally used in conjunction with the list role, which is used to identify a list container. <section role="list"> <
div role="listitem">List item 1</
div> <
div role="listitem">List item 2</
div> <
div role="listitem">List item 3</
div> </section> Description Any content that consists of an outer container with a list of elements inside it can be identified to assistive technologies using the list and listitem containers respectively. There are no hard and fast rules about which elements you should use to markup the list and list items, but you should make sure that the list items make sense in the context of a list, e.g. a shopping list, recipe steps, driving directions. Warning: If at all possible ...
ARIA: Mark role - Accessibility
ML <mark> element. If possible, you should use this element instead. Examples In the following example we have a document section that has been commented. The commented section is marked up using <span role="mark">. <p>The last half of the song is a slow-rising crescendo that peaks at the <span role="mark" aria-details="thread-1">end of the guitar solo</span>, before fading away sharply.</p> <
div role="comment" id="thread-1" data-author="chris"> <h3>Chris said</h3> <p class="comment-text">I really think this moment could use more cowbell.</p> <p><time datetime="2019-03-30T19:29">March 30 2019, 19:29</time></p> </
div> The related comment is marked up using an HTML structure wrapped with a <
div> containing role="comment". To associate the comment with the text being commented, we ne...
ARIA: Suggestion role - Accessibility
Rex called Tiny</span> </span>. </p> We could even provide an information box saying who made the suggestion and when, and associate it with the suggestion via aria-details: <p>Freida's pet is a <span role="suggestion" aria-details="comment-source"> <span role="deletion">black Cat called Luna</span> <span role="insertion">purple Tyrannosaurus Rex called Tiny</span> </span>. </p> <
div id="comment-source">Suggested by Chris, <time datetime="2019-03-30T19:29">March 30 2019, 19:29</time></
div> Browsers tend to provide a default black strikethrough for deletions, and a black underline for insertions, but you'll probably want to use Accessibility concerns Landmark roles are intended to be used sparingly, to identify larger overall sections of the document. Using too many landmar...
ARIA: switch role - Accessibility
tch role. When the aria-checked attribute's value changes, an accessible event is fired using the system's accessibility API if one is available and it supports the switch role. All elements that are descendants of an element with the switch role applied to it are automatically assigned role presentation. This prevents elements that are used to construct the switch from being interacted with in
dividually by assistive technologies. Text in these elements remains visible to the user agent and may be read or otherwise delivered to the user, unless it's expressly hidden using display: none or aria-hidden="true". The assistive technology, if it supports the switch role, responds by doing the following: Screen readers should announce the element as a switch, optionally providing instruction...
Accessibility: What users can do to browse more safely - Accessibility
accessibility settings. Those in the public sector who must accomodate those with special sensitivities, should consider setting aside at least one work station and becoming familiar with its personalization and accessibility settings. Understanding personalization and accessibility settings can actually be a money-saving endeavor. One work station can be set up to acommodate both a low-vision in
dividual (needs high-contrast) and to accomodate an in
dividual with photosensitive susceptibilities, by simply, adjusting personalization and accessiblity settings. Use modern browers. Learn personalization and accessibility settings Firefox 73 and above (Dekstop) Firefox added support for CSS prefers-reduced-motion in October 2018. Chrome 74 and above (Desktop) Chrome 74 added support for reduc...
Architecture - Accessibility
nt with the information in the parent object's nsIAccessibleText. This is done for backward compatibility with older MSAA clients which didn't have access to a text interface. The children of a Hypertext object are a superset of the links it exposes. The new system makes it easier to show caret positions etc., which will be an improvement in IA2 over MSAA. Example Take the following HTML code: <
div>Hello<a href="http://www.mozilla.org/access">My link<img src="image.gif">is cool</a>Bye</
div> Both the <a> and <img> are hyperlinks Also, both the <
div> and <a> are hypertexts So the <a> is both a hypertext and a hyperlink, because it contains text and is contained within text. This means that we have an exact mirror to the dom, but text lives in the parents instead of in the leaves, which now d...
HTML To MSAA - Accessibility
D if link is traversed n/a "jump" if @href is valid n/a br ROLE_SYSTEM_ WHITESPACE '\n' (new line char) STATE_SYSTEM_ READONLY n/a n/a n/a button ROLE_SYSTEM_ PUSHBUTTON from child nodes n/a STATE_SYSTEM_ FOCUSABLE STATE_SYSTEM_ DEFAULT if @type attribute has value "submit" n/a "press" n/a caption BSTR role n/a n/a n/a description_for (0x100f), points to table element
div BSTR role n/a n/a n/a n/a n/a n/a fieldset ROLE_SYSTEM_ GROUPING text equivalent from child legend element n/a n/a labelled_by (1003), points to legend element n/a n/a hr ROLE_SYSTEM_ SEPARATOR n/a n/a n/a n/a n/a n/a img, input @type=image ROLE_SYSTEM_ GRAPHIC from @alt attribute, empty @alt attribute means name can't be calculated at all n/a STATE_SYSTEM_ ANIMATED if image has more ...
Understanding the Web Content Accessibility Guidelines - Accessibility
jor things that web content must be to be considered accessible (see Understanding the Four Principles of Accessibility for the WCAG definitions). Each of the links below will take you to pages that further expand on these areas, giving you practical advice on how to write your web content so it conforms to the success criteria outlined in each of the WCAG 2.0 and 2.1 guidelines that further sub-
divides each principle. Perceivable: Users must be able to perceive it in some way, using one or more of their senses. Operable: Users must be able to control UI elements (e.g. buttons must be clickable in some way -- mouse, keyboard, voice command, etc.). Understandable: The content must be understandable to its users. Robust: The content must be developed using well-adopted web standards that...
-moz-float-edge - CSS: Cascading Style Sheets
e height and width properties include the content, padding, border and margin. padding-box The height and width properties include the content and padding but not the border or margin. Formal definition Initial valuecontent-boxApplies toall elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax border-box | content-box | margin-box | padding-box Examples HTML <
div class="box"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> </
div> CSS .box { display: block; height: 5px; margin: 0.5em auto 0.5em auto; color: gray; -moz-float-edge: margin-box; box-sizing: border-box; } Result Specifications Not part of any standard. ...
-webkit-mask-box-image - CSS: Cascading Style Sheets
border box is to have no mask image. <length> The size of the mask image's offset. See <length> for possible units. <percentage> The mask image's offset has a percentage value relative to the border box's corresponding dimension (width or height). repeat The mask image is repeated as many times as is necessary to span the border box. May include a partial image if the mask image does not
divide evenly into the border box. stretch The mask image is stretched to contain the border box exactly. round The mask image is stretched somewhat and repeated such that there is no partial mask image at the end of the border box. space The mask image is repeated as many times as possible without stretching. There is no partial mask image at the end of the border box. Formal definition Val...
:-moz-window-inactive - CSS: Cascading Style Sheets
t HTML documents, too. Note: Prior to the addition of this pseudo-class, giving different styles to background windows was achieved by setting an attribute (active="true") on the top-level XUL chrome window. This attribute is no longer used. Syntax :-moz-window-inactive Examples This example alters the appearance of a box's background depending on whether its window is active or not. HTML <
div id="mybox"> <p>This is a box!</p> </
div> CSS #mybox { background: linear-gradient(to bottom, yellow, cyan); width: 200px; height: 200px; } #mybox:-moz-window-inactive { background: cyan; } Result The result of this code is shown below. You can view this as a separate page as well. Specifications Not part of any standard. ...
::cue-region - CSS: Cascading Style Sheets
The ::cue-region CSS pseudo-element matches WebVTT cues within a selected element. This can be used to style captions and other cues in media with VTT tracks. ::cue-region { color: yellow; font-weight: bold; } The properties are applied to the entire set of cues as if they were a single unit. The only exception is that background and its shorthand properties apply to each cue in
dividually, to avoid creating boxes and obscuring unexpectedly large areas of the media. Syntax ::cue-region | ::cue-region( <selector> ) Permitted properties Rules whose selectors include this element may only use the following CSS properties: background background-attachment background-clip background-color background-image background-origin background-position background-repeat background-s...
::cue - CSS: Cascading Style Sheets
The ::cue CSS pseudo-element matches WebVTT cues within a selected element. This can be used to style captions and other cues in media with VTT tracks. ::cue { color: yellow; font-weight: bold; } The properties are applied to the entire set of cues as if they were a single unit. The only exception is that background and its longhand properties apply to each cue in
dividually, to avoid creating boxes and obscuring unexpectedly large areas of the media. Syntax ::cue | ::cue( <selector> ) Permitted properties Rules whose selectors include this element may only use the following CSS properties: background background-attachment background-clip background-color background-image background-origin background-position background-repeat background-size color font font-family f...
:dir() - CSS: Cascading Style Sheets
agent, even if inherited. Note: In HTML, the direction is determined by the dir attribute. Other document types may have different methods. Syntax The :dir() pseudo-class requires one parameter, representing the text directionality you want to target. Parameters ltr Target left-to-right elements. rtl Target right-to-left elements. Formal syntax :dir( ltr | rtl ) Examples HTML <
div dir="rtl"> <span>test1</span> <
div dir="ltr">test2 <
div dir="auto">?????</
div> </
div> </
div> CSS :dir(ltr) { background-color: yellow; } :dir(rtl) { background-color: powderblue; } Result Specifications Specification Status Comment HTML Living StandardThe definition of ':dir(ltr)' in that specification. Living Standard No changes. ...
:focus-within - CSS: Cascading Style Sheets
The :focus-within CSS pseudo-class represents an element that has received focus or contains an element that has received focus. In other words, it represents an element that is itself matched by the :focus pseudo-class or has a descendant that is matched by :focus. (This includes descendants in shadow trees.) /* Selects a <
div> when one of its descendants is focused */
div:focus-within { background: cyan; } This selector is useful, to take a common example, for highlighting an entire <form> container when the user focuses on one of its <input> fields. Syntax :focus-within Examples In this example, the form will receive special coloring styles when either text input receives focus. HTML <p>Try typing into this form.</p> <form> <label for="given_name">Given Name:</label> <input...
range - CSS: Cascading Style Sheets
c systems, the range is 1 to positive infinity. For additive systems, the range is 0 to positive infinity. For extends systems, the range is whatever auto would produce for the extended system; if extending a complex predefined style (?7 Complex Predefined Counter Styles), the range is the style's defined range. [ [ | infinite ]{2} ]# Defines a comma-separated list of ranges. For each in
dividual range, the first value is the lower bound and the second value is the upper bound. A range is inclusive, that means it always contains both, the lower and upper bound numbers. If infinite is used as the first value in a range, it represents negative infinity; if it is used as the second value, it represents positive infinity. The range of the counter style is the union of all the ranges defi...
font-display - CSS: Cascading Style Sheets
lock period and an infinite swap period. fallback Gives the font face an extremely small block period and a short swap period. optional Gives the font face an extremely small block period and no swap period. Description The font display timeline The font display timeline is based on a timer that begins the moment the user agent attempts to use a given downloaded font face. The timeline is
divided into the three periods below which dictate the rendering behavior of any elements using the font face. Font block period If the font face is not loaded, any element attempting to use it must render an invisible fallback font face. If the font face successfully loads during this period, it is used normally. Font swap period If the font face is not loaded, any element attempting to use it...
-ms-high-contrast - CSS: Cascading Style Sheets
ntax Syntax not found in DB! Examples The following declarations will match applications that are being displayed in high contrast mode with any color variation, a black-on-white color variation, and a white-on-black color variation, respectively. @media screen and (-ms-high-contrast: active) { /* All high contrast styling rules */ } @media screen and (-ms-high-contrast: black-on-white) {
div { background-image: url('image-bw.png'); } } @media screen and (-ms-high-contrast: white-on-black) {
div { background-image: url('image-wb.png'); } } Accessibility concerns Theming High Contrast Mode's theme colors come from a limited subset of deprecated CSS2 system colors. The available color keywords are: windowText: controls the color of text content. highlightText: controls the colo...
-webkit-transform-2d - CSS: Cascading Style Sheets
n in Safari CSS Reference. Syntax -webkit-transform-2d is a Boolean CSS media feature whose value is true if the browser supports -webkit prefixed CSS 2D transforms. Values true The browser supports the 2D CSS transforms with the -webkit prefix. false The 2D CSS transforms prefixed with -webkit are not supported by the browser. Examples Basic example @media (-webkit-transform-2d) {
div { -webkit-transform: translate(100px, 100px); } } This media feature is only supported by WebKit. If possible, use an @supports feature query instead: @supports (-webkit-transform: translate(100px, 100px)) {
div { -webkit-transform: translate(100px, 100px); } } Specifications Not part of any standard. ...
forced-colors - CSS: Cascading Style Sheets
pport such preferences and if this media query is ever implemented user agents will likely rely on the settings provided by the operating system in use. Examples Note: No browser currently implements this feature so the following example will not work. This example has an annoying color palette by default. This example does not take advantage of the colors provided by the user agent. HTML <
div class="colors">weird color box</
div> CSS .colors { background-color: red; color: grey; } @media (forced-colors: active) { .colors { background-color: white; color: black; } } Result Specifications Specification Status Comment Media Queries Level 5The definition of 'forced-colors' in that specification. Editor's Draft Initial definition. ...
prefers-contrast - CSS: Cascading Style Sheets
an interface that has a higher level of contrast. less Indicates that user has notified the system that they prefer an interface that has a lower level of contrast. User preferences Various operating systems do support such preferences and user agents are likely to rely on the settings provided by the operating system. Examples This example has an annoying low contrast by default. HTML <
div class="contrast">low contrast box</
div> CSS .contrast { width: 100px; height: 100px; outline: 2px dashed black; } @media (prefers-contrast: high) { .contrast { outline: 2px solid black; } } Result Specifications Specification Status Comment Media Queries Level 5The definition of 'prefers-contrast' in that specification. Editor's Draft Init...
prefers-reduced-motion - CSS: Cascading Style Sheets
lity > Remove animations. In Firefox about:config: Add a number preference called ui.prefersReducedMotion and set its value to 1. Changes to this preference take effect immediately. Examples This example has a scaling animation by default. If Reduce Motion is enabled in your accessibility preferences, the animation is toned down to a simple dissolve without vestibular motion triggers. HTML <
div class="animation">animated box</
div> CSS .animation { animation: pulse 1s linear infinite both; } /* Tone down the animation to avoid vestibular motion triggers like scaling or panning large objects. */ @media (prefers-reduced-motion) { .animation { animation-name: dissolve; } } .animation { background-color: #306; color: #fff; font: 1.2em sans-serif; width: 10em; paddi...
prefers-reduced-transparency - CSS: Cascading Style Sheets
no user agent implements this feature, although various operating systems do support such preferences and if this media query is ever implemented user agents will likely rely on the settings provided by the operating systems. Examples Note: No browser currently implements this feature so the following example will not work. This example has an annoying transparency effect by default. HTML <
div class="transparency">transparent box</
div> CSS .transparency { opacity: 0.5; } @media (prefers-reduced-transparency: reduce) { .transparency { opacity: 1; } } Result Specifications Specification Status Comment Media Queries Level 5The definition of 'prefers-reduced-transparency' in that specification. Editor's Draft Initial definition. ...
@supports - CSS: Cascading Style Sheets
The @supports CSS at-rule lets you specify declarations that depend on a browser's support for one or more specific CSS features. This is called a feature query. The rule may be placed at the top level of your code or nested inside any other conditional group at-rule. @supports (display: grid) {
div { display: grid; } } @supports not (display: grid) {
div { float: right; } } In JavaScript, @supports can be accessed via the CSS object model interface CSSSupportsRule. Syntax The @supports at-rule associates a block of statements with a supports condition. The supports condition consists of one or more name-value pairs combined by conjunctions (and), disjunctions (or), and/or negations (not). Precedence of operators can be defined with parentheses. Declaration syntax The ...
CSS Animations tips and tricks - CSS: Cascading Style Sheets
doesn't offer a way to run an animation again. There's no magic resetAnimation() method on elements, and you can't even just set the element's animation-play-state to "running" again. Instead, you have to use clever tricks to get a stopped animation to replay. Here's one way to do it that we feel is stable and reliable enough to suggest to you. HTML content First, let's define the HTML for a <
div> we wish to animate and a button that will play (or replay) the animation. <
div class="box"> </
div> <
div class="runButton">Click me to run the animation</
div> CSS content Now we'll define the animation itself using CSS. Some CSS that's not important (the style of the "Run" button itself) isn't shown here, for brevity. .runButton { cursor: pointer; width: 300px; border: 1px solid black...
Box alignment in grid layout - CSS: Cascading Style Sheets
ing the item inside the grid area it is placed into. The properties align-items and justify-items are applied to the grid container and set the align-self and justify-self properties as a group. This means that you can set alignment for all of your grid Items at once, then override any items that need a different alignment by applying the align-self or justify-self property to the rules for the in
dividual grid Items. The initial value for align-self and justify-self is stretch so the item will stretch over the entire grid area. The exception to this rule is where the item has an intrinsic aspect ratio, for example an image. In this case the item will be aligned to start in both dimensions in order that the image is not distorted. Content alignment justify-content align-content place-co...
Handling content breaks in multicol - CSS: Cascading Style Sheets
ontrol breaks in a number of ways or on several elements, your content needs to break somewhere, so you may not always get the result you intended. To some extent your use of fragmentation is always a suggestion to the browser, to control breaks in this way if it is possible. In addition to the above, browser support for these properties is a little patchy. The compatibility data charts on the in
dividual property pages here on MDN can help you see which browsers support which features. In most cases, the fallback to breaks not being controlled is something you can live with, with suboptimal breaking being untidy rather than a disaster to your layout. ...
CSS Multi-column Layout - CSS: Cascading Style Sheets
Basic example In the following example the column-count property has been applied to the element with a class of container. As the value of column-count is 3, the content is arranged into 3 columns of equal size. ...
Basic concepts of flexbox - CSS: Cascading Style Sheets
x-grow and flex-shrink are proportions. Typically if we had all of our items set to flex: 1 1 200px and then wanted one item to grow at twice the rate, we would set that item to flex: 2 1 200px. However you could use flex: 10 1 200px and flex: 20 1 200px if you wanted. Shorthand values for the flex properties You will very rarely see the flex-grow, flex-shrink, and flex-basis properties used in
dividually; instead they are combined into the flex shorthand. The flex shorthand allows you to set the three values in this order -- flex-grow, flex-shrink, flex-basis. The live example below allows you to test out the different values of the flex shorthand; remember that the first value is flex-grow. Giving this a positive value means the item can grow. The second is flex-shrink -- with a positive...
Ordering Flex Items - CSS: Cascading Style Sheets
continues to follow the order that the items are listed in the source. In the same way that changing the value of flex-direction does not change the order in which items are navigated to, changing this value does not change paint order. It is a visual reversal of the items only. The order property In addition to reversing the order in which flex items are visually displayed, you can target in
dividual items and change where they appear in the visual order with the order property. The order property is designed to lay the items out in ordinal groups. What this means is that items are assigned an integer that represents their group. The items are then placed in the visual order according to that integer, lowest values first. If more than one item has the same integer value, then within tha...
Block and inline layout in normal flow - CSS: Cascading Style Sheets
hanges the behaviour of boxes and the boxes they generate. The display type of an element defines the outer display type; this dictates how the box displays alongside other elements in the same formatting context. It also defines the inner display type, which dictates how boxes inside this element behave. We can see this very clearly when considering a flex layout. In the example below I have a <
div>, which I have given display: flex. The flex container behaves like a block element: it displays on a new line and takes up all of the space it can in the inline direction. This is the outer display type of block. The flex items however are participating in a flex formatting context, because their parent is the element with display: flex, which has an inner display type of flex, establishing the...
In Flow and Out of Flow - CSS: Cascading Style Sheets
e same way) the root element (html) Out of flow items create a new Block Formatting Context (BFC) and therefore everything inside them can be seen as a mini layout, separate from the rest of the page. The root element therefore is out of flow, as the container for everything in our document, and establishes the Block Formatting Context for the document. Floated Items In this example I have a
div, and then two paragraphs. I've added a background colour to the paragraphs, and then floated the
div left. The
div is now out of flow. As a float it is first laid out according to where it would be in normal flow, then taken out of flow and moved to the left as far as possible. You can see the background colour of the following paragraph running underneath, it is only the line boxes of that p...
Basic concepts of Logical Properties and Values - CSS: Cascading Style Sheets
vertical writing mode: Browser support Logical Properties and Values can be thought of as a couple of groups in terms of current browser support. Some of the properties are essentially mappings from the physical versions, for example inline-size for width or margin-inline-start rather than margin-left. These mapped properties are starting to see good browser support, and if you look at the in
dividual pages for the properties in the reference here on MDN you will see that Edge is the only modern browser currently missing these. There are then a group of properties which do not have a direct mapping in terms of existing physical properties. These are shorthands made possible by the fact that we can refer to both edges of the block or inline dimension at once. An example would be margin-bl...
Using the :target pseudo-class in selectors - CSS: Cascading Style Sheets
et { color: red; } Example In the following example, there are five links that point to elements in the same document. Selecting the "First" link, for example, will cause <h1 id="one"> to become the target element. Note that the document may jump to a new scroll position, since target elements are placed on the top of the browser window if possible. <h4 id="one">...</h4> <p id="two">...</p> <
div id="three">...</
div> <a id="four">...</a> <em id="five">...</em> <a href="#one">First</a> <a href="#two">Second</a> <a href="#three">Third</a> <a href="#four">Fourth</a> <a href="#five">Fifth</a> Conclusion In cases where a fragment identifier points to a portion of the document, readers may become confused about which part of the document they're supposed to be reading. By styling the target...
CSS selectors - CSS: Cascading Style Sheets
c". Attribute selector Selects all elements that have the given attribute. Syntax: [attr] [attr=value] [attr~=value] [attr|=value] [attr^=value] [attr$=value] [attr*=value] Example: [autoplay] will match all elements that have the autoplay attribute set (to any value). Grouping selectors Selector list The , is a grouping method, it selects all the matching nodes. Syntax: A, B Example:
div, span will match both <span> and <
div> elements. Combinators Descendant combinator The (space) combinator selects nodes that are descendants of the first element. Syntax: A B Example:
div span will match all <span> elements that are inside a <
div> element. Child combinator The > combinator selects nodes that are direct children of the first element. Syntax: A > B Example: ul > li wi...
Shapes from box values - CSS: Cascading Style Sheets
below I am using an element which has padding, a border, and a margin defined in order that you can see the different ways in which content will flow. margin-box The margin-box is the shape defined by the outside margin edge and includes the corner radius of the shape, should border-radius have been used in defining the element. In the example below, we have a circular purple item which is a <
div> with a height, width, and background colour. The border-radius property has been used to create a circle by setting border-radius: 50%. As the element has a margin, you can see that the content is flowing around the circular shape and the margin applied to it. border-box The border-box value is the shape defined by the outside border edge. This shape follows all of the normal border radius s...
Overview of CSS Shapes - CSS: Cascading Style Sheets
mples above we have used images or a visible element to define the shape, meaning that you can see the shape on the page. Instead, you might simply want to cause some text to flow along a non-rectangular invisible line. You can do this with Shapes, however you will still need a floated item, which you can then make invisible. That could be a redundant element inserted into the document, an empty <
div> or <span> perhaps, but our preference is to use generated content. This means we can keep things used for styling inside the CSS. In this next example, we use generated content to insert an element with height and width of 150px. We can then use Basic Shapes, Box Values or even the Alpha Channel of an image to create a shape for the text to wrap around. Relationship to clip-path The Basic S...
Child combinator - CSS: Cascading Style Sheets
immediate children of the elements matched by the first selector. This is stricter than the descendant combinator, which matches all elements matched by the second selector for which there exists an ancestor element matched by the first selector, regardless of the number of "hops" up the DOM. Syntax selector1 > selector2 { style properties } Examples CSS span { background-color: white; }
div > span { background-color: DodgerBlue; } HTML <
div> <span>Span #1, in the
div. <span>Span #2, in the span that's in the
div.</span> </span> </
div> <span>Span #3, not in the
div at all.</span> Result Specifications Specification Status Comment Selectors Level 4The definition of 'child combinator' in that specification. Working Draft Se...
Layout and the containing block - CSS: Cascading Style Sheets
d position of an element are often impacted by its containing block. Most often, the containing block is the content area of an element's nearest block-level ancestor, but this is not always the case. In this article, we examine the factors that determine an element's containing block. When a user agent (such as your browser) lays out a document, it generates a box for every element. Each box is
divided into four areas: Content area Padding area Border area Margin area Many developers believe that the containing block of an element is always the content area of its parent, but that isn't necessarily true. Let's investigate the factors that determine what an element's containing block is. Effects of the containing block Before learning what determines the containing block of an el...
Descendant combinator - CSS: Cascading Style Sheets
urn, form feed, new line, and tab characters -- between two selectors in the absence of another combinator. Additionally, the white space characters of which the combinator is comprised may contain any number of CSS comments. Syntax selector1 selector2 { /* property declarations */ } Examples CSS li { list-style-type: disc; } li li { list-style-type: circle; } HTML <ul> <li> <
div>Item 1</
div> <ul> <li>Subitem A</li> <li>Subitem B</li> </ul> </li> <li> <
div>Item 2</
div> <ul> <li>Subitem A</li> <li>Subitem B</li> </ul> </li> </ul> Result Specifications Specification Status Comment Selectors Level 4The definition of 'descendant combinator' in that specification. Working Draft ...
Questions about CSS - CSS: Cascading Style Sheets
ading Style Sheets (CSS) is a rule-based language allowing developers to define styles to apply to HTML elements (or other markup structures). CSS gives more control over the appearance of a Web page to the page creator than to the browser designer or the viewer. With CSS, the sources of style definition for a given document element are in this order of precedence: The STYLE attribute on an in
dividual element tag The STYLE element that defines a specific style sheet containing style declarations or a LINK element that links to a separate document containing the STYLE element. In a Web page, the STYLE element is placed between the TITLE statement and the BODY statement. An imported style sheet, using the CSS @import notation to automatically import and merge an external style sheet with ...
ID selectors - CSS: Cascading Style Sheets
ected, its id attribute must match exactly the value given in the selector. /* The element with id="demo" */ #demo { border: red 2px solid; } Syntax #id_value { style properties } Note that syntactically (but not specificity-wise), this is equivalent to the following attribute selector: [id=id_value] { style properties } Examples CSS #identified { background-color: skyblue; } HTML <
div id="identified">This
div has a special ID on it!</
div> <
div>This is just a regular
div.</
div> Result Specifications Specification Status Comment Selectors Level 4The definition of 'ID selectors' in that specification. Working Draft Selectors Level 3The definition of 'ID selectors' in that specification. Recommendation CSS Level 2 (...
Inline formatting context - CSS: Cascading Style Sheets
e concepts The inline formatting context is part of the visual rendering of a web page. Inline boxes are laid out one after the other, in the direction sentences run in the writing mode in use: In a horizontal writing mode, boxes are laid out horizontally, starting on the left. In a vertical writing mode they would be laid out vertically starting at the top. In the example below, the two (<
div>) elements with the black borders form a block formatting context, inside which each word participates in an inline formatting context. The boxes in the horizontal writing mode run horizontally, and the vertical writing mode boxes run vertically. Boxes forming a line are contained by a rectangular area called a line box. This box will be large enough to contain all of the inline boxes in that ...
CSS reference - CSS: Cascading Style Sheets
s-list } ... where : selectors-list ::= selector[:pseudo-class] [::pseudo-element] [, selectors-list] properties-list ::= [property : value] [; properties-list] See the index of selectors, pseudo-classes, and pseudo-elements below. The syntax for each specified value depends on the data type defined for each specified property. Style rule examples strong { color: red; }
div.menu-bar li:hover > ul { display: block; } For a beginner-level introduction to the syntax of selectors, see our guide on CSS Selectors. Be aware that any syntax error in a rule definition invalidates the entire rule. Invalid rules are ignored by the browser. Note that CSS rule definitions are entirely (ASCII) text-based, whereas DOM-CSS / CSSOM (the rule management system) is object-based. ...
Scaling of SVG backgrounds - CSS: Cascading Style Sheets
ified by constrain or cover, that specified size wins. If none of the above cases are met, the image is rendered at the same size as the background area. It's worth noting that the sizing algorithm only cares about the image's dimensions and proportions, or lack thereof. An SVG image with fixed dimensions will be treated just like a raster image of the same size. Source image examples Before
diving in to look at the results of using different kinds of source images and seeing how they look when used with background-size, it would be helpful to look at a few example source images that have different dimensions and sizing settings. In each case, we show what the source image looks like rendered in a 150x150 box, and provide a link to the SVG source. Dimensionless and proportionless This...
Selector list - CSS: Cascading Style Sheets
Syntax element, element, element { style properties } Examples Single Line Grouping Grouping selectors in a single line using a comma-separated lists. h1, h2, h3, h4, h5, h6 { font-family: helvetica; } Multi Line Grouping Grouping selectors in a multiple lines using a comma-separated lists. ...
Shorthand properties - CSS: Cascading Style Sheets
ind when using them: A value which is not specified is set to its initial value. That sounds anecdotal, but it really means that it overrides previously set values. Therefore: background-color: red; background: url(images/bg.gif) no-repeat left top; will not set the color of the background to red but to background-color's default, transparent, as the second rule has precedence. Only the in
dividual properties values can inherit. As missing values are replaced by their initial value, it is impossible to allow inheritance of in
dividual properties by omitting them. The keyword inherit can be applied to a property, but only as a whole, not as a keyword for one value or another. That means that the only way to make some specific value to be inherited is to use the longhand property with the...
<angle-percentage> - CSS: Cascading Style Sheets
Use in calc() Where an <angle-percentage> is specified as an allowable type, this means that the percentage resolves to an angle and therefore can be used in a calc() expression. Specifications Specification Status Comment CSS Values and Units Module Level 4The definition of '<angle-percentage>' in that specification. ...
attr() - CSS: Cascading Style Sheets
string | color | url | integer | number | length | angle | time | frequency | cap | ch | em | ex | ic | lh | rlh | rem | vb | vi | vw | vh | vmin | vmax | mm | Q | cm | in | pt | pc | px | deg | grad | rad | turn | ms | s | Hz | kHz | % Examples content property HTML <p data-foo="hello">world</p> CSS [data-foo]::before { content: attr(data-foo) " "; } Result <color> value HTML <
div class="background" data-background="lime">background expected to be red if your browser does not support advanced usage of attr()</
div> CSS .background { height: 100vh; } .background { background-color: red; } .background[data-background] { background-color: attr(data-background color, red); } Specifications Specification Status Comment CSS Values and ...
border-bottom-width - CSS: Cascading Style Sheets
nd the values are constant within a single document. Formal definition Initial valuemediumApplies toall elements. It also applies to ::first-letter.InheritednoComputed valuethe absolute length or 0 if border-bottom-style is none or hiddenAnimation typea length Formal syntax <line-width>where <line-width> = <length> | thin | medium | thick Examples Comparing bottom border widths HTML <
div>Element 1</
div> <
div>Element 2</
div> CSS
div { border: 1px solid red; margin: 1em 0; }
div:nth-child(1) { border-bottom-width: thick; }
div:nth-child(2) { border-bottom-width: 2em; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-bottom-width' in that specification. Candidate Rec...
border-image-repeat - CSS: Cascading Style Sheets
omputed valueas specifiedAnimation typediscrete Formal syntax [ stretch | repeat | round | space ]{1,2} Examples Repeating border images CSS #bordered { width: 12rem; margin-bottom: 1rem; padding: 1rem; border: 40px solid; border-image: url("https://mdn.mozillademos.org/files/4127/border.png") 27; border-image-repeat: stretch; /* Can be changed in the live sample */ } HTML <
div id="bordered">You can try out various border repetition rules on me!</
div> <select id="repetition"> <option value="stretch">stretch</option> <option value="repeat">repeat</option> <option value="round">round</option> <option value="space">space</option> <option value="stretch repeat">stretch repeat</option> <option value="space round">space round</option> </select> JavaScript var ...
border-image-source - CSS: Cascading Style Sheets
The border-image-source CSS property sets the source image used to create an element's border image. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. The border-image-slice property is used to
divide the source image into regions, which are then dynamically applied to the final border image. Syntax /* Keyword value */ border-image-source: none; /* <image> values */ border-image-source: url(image.jpg); border-image-source: linear-gradient(to top, red, yellow); /* Global values */ border-image-source: inherit; border-image-source: initial; border-image-source: unset; Values none No border image is used. The ...
border-left-width - CSS: Cascading Style Sheets
thick, and the values are constant within a single document. Formal definition Initial valuemediumApplies toall elements. It also applies to ::first-letter.InheritednoComputed valuethe absolute length or 0 if border-left-style is none or hiddenAnimation typea length Formal syntax <line-width>where <line-width> = <length> | thin | medium | thick Examples Comparing border widths HTML <
div>Element 1</
div> <
div>Element 2</
div> CSS
div { border: 1px solid red; margin: 1em 0; }
div:nth-child(1) { border-left-width: thick; }
div:nth-child(2) { border-left-width: 2em; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-left-width' in that specification. Candidate Recommend...
border-radius - CSS: Cascading Style Sheets
e examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. The radius applies to the whole background, even if the element has no border; the exact position of the clipping is defined by the background-clip property. The border-radius property does not apply to table elements when border-collapse is collapse. Note: As with any shorthand property, in
dividual sub-properties cannot inherit, such as in border-radius:0 0 inherit inherit, which would partially override existing definitions. Instead, the in
dividual longhand properties have to be used. Constituent properties This property is a shorthand for the following CSS properties: border-bottom-left-radius border-bottom-right-radius border-top-left-radius border-top-right-radius Syntax ...
border-right-width - CSS: Cascading Style Sheets
thick, and the values are constant within a single document. Formal definition Initial valuemediumApplies toall elements. It also applies to ::first-letter.InheritednoComputed valuethe absolute length or 0 if border-right-style is none or hiddenAnimation typea length Formal syntax <line-width>where <line-width> = <length> | thin | medium | thick Examples Comparing border widths HTML <
div>Element 1</
div> <
div>Element 2</
div> CSS
div { border: 1px solid red; margin: 1em 0; }
div:nth-child(1) { border-right-width: thick; }
div:nth-child(2) { border-right-width: 2em; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-right-width' in that specification. Candidate Recomm...
border-top-width - CSS: Cascading Style Sheets
pattern thin <= medium <= thick, and the values are constant within a single document. Formal definition Initial valuemediumApplies toall elements. It also applies to ::first-letter.InheritednoComputed valuethe absolute length or 0 if border-top-style is none or hiddenAnimation typea length Formal syntax <line-width>where <line-width> = <length> | thin | medium | thick Examples HTML <
div>Element 1</
div> <
div>Element 2</
div> CSS
div { border: 1px solid red; margin: 1em 0; }
div:nth-child(1) { border-top-width: thick; }
div:nth-child(2) { border-top-width: 2em; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'border-top-width' in that specification. Candidate Recommendati...
box-shadow - CSS: Cascading Style Sheets
he border-radius is set to 0, as is the default, the corners of the shadow will be, well, corners. Had we put in a border-radius of any other value, the corners would have been rounded. We added a margin the size of the widest box-shadow to ensure the shadow doesn't overlap adjacent elements or go beyond the border of the containing box. A box-shadow does not impact box model dimensions. HTML <
div><p>Hello World</p></
div> CSS p { box-shadow: 0 0 0 2em #F4AAB9, 0 0 0 4em #66CCFF; margin: 4em; padding:1em; } Result Specifications Specification Status Comment CSS Backgrounds and Borders Module Level 3The definition of 'box-shadow' in that specification. Candidate Recommendation Initial definition ...
color-adjust - CSS: Cascading Style Sheets
to make color or style adjustments to the box when rendering it. CSS .my-box { background-color: black; background-image: linear-gradient(rgba(0, 0, 180, 0.5), rgba(70, 140, 220, 0.5)); color: #900; width: 15rem; height: 6rem; text-align: center; font: 24px "Helvetica", sans-serif; display: flex; align-items: center; justify-content: center; color-adjust: exact; } HTML <
div class="my-box"> <p>Need more contrast!</p> </
div> Result Specifications Specification Status Comment CSS Color Adjustment Module Level 1The definition of 'color-adjust' in that specification. Editor's Draft Initial definition. ...
column-fill - CSS: Cascading Style Sheets
*/ column-fill: inherit; column-fill: initial; column-fill: unset; The column-fill property is specified as one of the keyword values listed below. The initial value is balance so the content will be balanced across the columns. Values auto Columns are filled sequentially. Content takes up only the room it needs, this may result in some columns remaining empty. balance Content is equally
divided between columns. In fragmented contexts, such as paged media, only the last fragment is balanced. Therefore in paged media, only the last page would be balanced. balance-all Content is equally
divided between columns. In fragmented contexts, such as paged media, all fragments are balanced. Formal definition Initial valuebalanceApplies tomulticol elementsInheritednoComputed valueas specif...
column-rule - CSS: Cascading Style Sheets
column-rule shorthand CSS property sets the width, style, and color of the line drawn between columns in a multi-column layout. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. It is a shorthand property that sets the in
dividual column-rule-* properties in a single, convenient declaration: column-rule-width, column-rule-style, and column-rule-color. Note: As with all shorthand properties, any in
dividual value that is not specified is set to its corresponding initial value (possibly overriding values previously set using non-shorthand properties). Syntax column-rule: dotted; column-rule: solid 8px; column-rule: ...
cursor - CSS: Cascading Style Sheets
sw-resize ew-resize Bidirectional resize cursor. ns-resize nesw-resize nwse-resize Zooming zoom-in Something can be zoomed (magnified) in or out. zoom-out Usage notes Although the specification does not define any size limitations for cursor, in
dividual user agents may choose to do so. Cursor changes using images which are outside the size range supported by the browser will generally just be ignored. Check the Browser compatibility table for any notes on cursor size limits. Formal definition Initial valueautoApplies toall elementsInheritedyesComputed valueas specified, but with <url> values made absoluteAnimation typediscrete Formal sy...
<display-legacy> - CSS: Cascading Style Sheets
lement behaves like an inline element and lays out its content according to the flexbox model. It is equivalent to inline flex. inline-grid The element behaves like an inline element and lays out its content according to the grid model. It is equivalent to inline grid. Examples In the below example, we are creating an inline flex container with the legacy keyword inline-flex. HTML <
div class="container"> <
div>Flex Item</
div> <
div>Flex Item</
div> </
div> Not a flex item CSS .container { display: inline-flex; } Result In the new syntax the inline flex container would be created using two values, inline for the outer display type, and flex for the inner display type. .container { display: inline flex; } Specifications Specification Status ...
<display-listitem> - CSS: Cascading Style Sheets
ed together with list-style-type and list-style-position. list-item can also be combined with any <display-outside> keyword and the flow or flow-root <display-inside> keywords. Note: In browsers that support the two-value syntax, if no inner value is specified it will default to flow. If no outer value is specified, the principal box will have an outer display type of block. Examples HTML <
div class="fake-list">I will display as a list item</
div> CSS .fake-list { display: list-item; list-style-position: inside; } Result Specifications Specification Status CSS Display Module Level 3The definition of 'display-listitem' in that specification. Candidate Recommendation ...
font-size - CSS: Cascading Style Sheets
ive to the parent element's font size (unlike all other properties, where they're relative to the font size on the element). This means em units and percentages do the same thing for font-size. One important fact to keep in mind: em values compound. Take the following HTML and CSS: html { font-size: 62.5%; /* font-size 1em = 10px on default browser settings */ } span { font-size: 1.6em; } <
div> <span>Outer <span>inner</span> outer</span> </
div> The result is: Assuming that the browser's default font-size is 16px, the words "outer" would be rendered at 16px, but the word "inner" would be rendered at 25.6px. This is because the inner <span>'s font-size is 1.6em which is relative to its parent's font-size, which is in turn relative to its parent's font-size. This is often called comp...
<frequency-percentage> - CSS: Cascading Style Sheets
The <frequency-percentage> CSS data type represents a value that can be either a <frequency> or a <percentage>. Frequency values, e.g. the pitch of a speaking voice, are not currently used in any CSS properties. Syntax The value of a <frequency-percentage> is either a <frequency> or a <percentage>; see their in
dividual reference pages for details about their syntaxes. Description Use in calc() Where a <frequency-percentage> is specified as an allowable type, this means that the percentage resolves to a frequency and therefore can be used in a calc() expression. Examples Valid percentage values 90% Positive percentage +90% Positive percentage with leading + -90% Negative percentage -- not valid for all properties that use percentages Invalid percentage values 90 % No space...
grid-auto-columns - CSS: Cascading Style Sheets
ze>+where <track-size> = <track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( [ <length> | <percentage> ] )where <track-breadth> = <length-percentage> | <flex> | min-content | max-content | auto<inflexible-breadth> = <length> | <percentage> | min-content | max-content | autowhere <length-percentage> = <length> | <percentage> Examples Setting grid column size HTML <
div id="grid"> <
div id="item1"></
div> <
div id="item2"></
div> <
div id="item3"></
div> </
div> CSS #grid { height: 100px; display: grid; grid-template-areas: "a a"; grid-gap: 10px; grid-auto-columns: 200px; } #grid >
div { background-color: lime; } Result Specifications Specification Status Comment CSS Grid LayoutThe definition of 'grid-auto-columns'...
grid-auto-rows - CSS: Cascading Style Sheets
k-size>+where <track-size> = <track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( [ <length> | <percentage> ] )where <track-breadth> = <length-percentage> | <flex> | min-content | max-content | auto<inflexible-breadth> = <length> | <percentage> | min-content | max-content | autowhere <length-percentage> = <length> | <percentage> Examples Setting grid row size HTML <
div id="grid"> <
div id="item1"></
div> <
div id="item2"></
div> <
div id="item3"></
div> </
div> CSS #grid { width: 200px; display: grid; grid-template-areas: "a a"; grid-gap: 10px; grid-auto-rows: 100px; } #grid >
div { background-color: lime; } Result Specifications Specification Status Comment CSS Grid LayoutThe definition of 'grid-auto-rows' in tha...
height - CSS: Cascading Style Sheets
e height on the root element is relative to the initial containing block.Computed valuea percentage or auto or the absolute lengthAnimation typea length, percentage or calc(); Formal syntax auto | <length> | <percentage> | min-content | max-content | fit-content(<length-percentage>)where <length-percentage> = <length> | <percentage> Examples Setting height using pixels and percentages HTML <
div id="taller">I'm 50 pixels tall.</
div> <
div id="shorter">I'm 25 pixels tall.</
div> <
div id="parent"> <
div id="child"> I'm half the height of my parent. </
div> </
div> CSS
div { width: 250px; margin-bottom: 5px; border: 2px solid blue; } #taller { height: 50px; } #shorter { height: 25px; } #parent { height: 100px; } #child { height: 50%; width: 75%; } Result Speci...
image-set() - CSS: Cascading Style Sheets
ation -- from which the browser picks the most appropriate for the device and settings. Resolution can be used as a proxy for filesize -- a user agent on a slow mobile connection with a high-resolution screen may prefer to receive lower-resolution images rather than waiting for a higher resolution image to load. image-set() allows the author to provide options rather than determining what each in
dividual user needs. Syntax image-set() = image-set( <image-set-option># ) where <image-set-option> = [ <image> | <string> ] <resolution> and <string> is an <url> Values Most commonly you'll see an url() <string> value, but the <image> can be any image type except for an image set. The image-set() function can not be nested inside another image-set() function. <resolution> units include x...
inherit - CSS: Cascading Style Sheets
en the parent element is not the containing block. Examples Exclude selected elements from a rule /* Make second-level headers green */ h2 { color: green; } /* ...but leave those in the sidebar alone so they use their parent's color */ #sidebar h2 { color: inherit; } In this example the h2 elements inside the sidebar might be different colors. For example, if one of them were the child of a
div matched by the rule ...
div#current { color: blue; } ... it would be blue. Specifications Specification Status Comment CSS Cascading and Inheritance Level 4The definition of 'inherit' in that specification. Candidate Recommendation No changes from Level 3. CSS Values and Units Module Level 3The definition of 'inherit' in that specification. Candi...
letter-spacing - CSS: Cascading Style Sheets
implementation-specific limits. User agents may not further increase or decrease the inter-character space in order to justify text. Accessibility concerns A large positive or negative letter-spacing value will make the word(s) the styling is applied to unreadable. For text styled with a very large positive value, the letters will be so far apart that the word(s) will appear like a series of in
dividual, unconnected letters. For text styled with a very large negative value, the letters will overlap each other to the point where the word(s) may be unrecognizable. Legible letter-spacing must be determined on a case-by-case basis, as different font families have different character widths. There is no one value that can ensure all font families automatically maintain their legibility. MDN ...
mask-border-slice - CSS: Cascading Style Sheets
These regions are used to form the components of an element's mask border. Syntax /* All sides */ mask-border-slice: 30%; /* vertical | horizontal */ mask-border-slice: 10% 30%; /* top | horizontal | bottom */ mask-border-slice: 30 30% 45; /* top | right | bottom | left */ mask-border-slice: 7 12 14 5; /* Using the `fill` keyword */ mask-border-slice: 10% fill 7 12; /* Global values */ mask-border-slice: inherit; mask-border-slice: initial; mask-border-slice: unset; The mask-border-slice property may be specified using one to four <number-percentage> values to represent the position of each image slice. ...
mask-border-source - CSS: Cascading Style Sheets
Syntax /* Keyword value */ mask-border-source: none; /* <image> values */ mask-border-source: url(image.jpg); mask-border-source: linear-gradient(to top, red, yellow); /* Global values */ mask-border-source: inherit; mask-border-source: initial; mask-border-source: unset; Values none No mask border is used. <image> Image reference to use for the mask border. ...
mask-clip - CSS: Cascading Style Sheets
ox> = border-box | padding-box | content-box Examples Clipping a mask to the border box CSS #masked { width: 100px; height: 100px; background-color: #8cffa0; margin: 20px; border: 20px solid #8ca0ff; padding: 20px; mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg); mask-size: 100% 100%; mask-clip: border-box; /* Can be changed in the live sample */ } HTML <
div id="masked"> </
div> <select id="clipBox"> <option value="content-box">content-box</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box</option> <option...
mask-composite - CSS: Cascading Style Sheets
d | subtract | intersect | exclude Examples Compositing mask layers with addition CSS #masked { width: 100px; height: 100px; background-color: #8cffa0; mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg), url(https://mdn.mozillademos.org/files/12676/star.svg); mask-size: 100% 100%; mask-composite: add; /* Can be changed in the live sample */ } HTML <
div id="masked"> </
div> <select id="compositeMode"> <option value="add">add</option> <option value="subtract">subtract</option> <option value="intersect">intersect</option> <option value="exclude">exclude</option> </select> JavaScript var clipBox = document.getElementById("compositeMode"); clipBox.addEventListener("change", function (evt) { document.getElementById("masked").style.maskCom...
mask-image - CSS: Cascading Style Sheets
<color> <color-stop-length>?<linear-color-hint> = <length-percentage><length-percentage> = <length> | <percentage><angular-color-stop> = <color> && <color-stop-angle>?<angular-color-hint> = <angle-percentage>where <color-stop-length> = <length-percentage>{1,2}<color-stop-angle> = <angle-percentage>{1,2}<angle-percentage> = <angle> | <percentage> Examples Setting a mask image with a URL HTML <
div id="masked"></
div> CSS #masked { width: 100px; height: 100px; background-color: #8cffa0; -webkit-mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); } Result Specifications Specification Status Comment CSS Masking Module Level 1The definition of 'mask-image' in that spe...
mask-mode - CSS: Cascading Style Sheets
ted valueas specifiedAnimation typediscrete Formal syntax <masking-mode>#where <masking-mode> = alpha | luminance | match-source Examples Using alpha mask mode CSS #masked { width: 227px; height: 200px; background: blue linear-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg); mask-mode: alpha; /* Can be changed in the live sample */ } HTML <
div id="masked"> </
div> <select id="maskMode"> <option value="alpha">alpha</option> <option value="luminance">luminance</option> <option value="match-source">match-source</option> </select> JavaScript var maskMode = document.getElementById("maskMode"); maskMode.addEventListener("change", function (evt) { document.getElementById("masked").style.maskMode = evt.target.value; }); Result ...
mask-origin - CSS: Cascading Style Sheets
x> | margin-boxwhere <box> = border-box | padding-box | content-box Examples Setting mask origin to border-box CSS #masked { width: 100px; height: 100px; margin: 10px; border: 10px solid blue; background-color: #8cffa0; padding: 10px; mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-origin: border-box; /* Can be changed in the live sample */ } HTML <
div id="masked"> </
div> <select id="origin"> <option value="content-box">content-box</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box</option> </select> ...
mask-position - CSS: Cascading Style Sheets
xamples Setting mask position CSS #wrapper { border: 1px solid black; width: 250px; height: 250px; } #masked { width: 250px; height: 250px; background: blue linear-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-repeat: no-repeat; mask-position: top right; /* Can be changed in the live sample */ margin-bottom: 10px; } HTML <
div id="wrapper"> <
div id="masked"> </
div> </
div> <select id="maskPosition"> <option value="top">top</option> <option value="center">center</option> <option value="bottom">bottom</option> <option value="top right" selected>top right</option> <option value="center center">center center</option> <option value="bottom left">bottom left</option> <option value="10px 20px">10px 20px</opti...
mask-repeat - CSS: Cascading Style Sheets
e <repeat-style> = repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2} Examples Setting repeat for a single mask CSS #masked { width: 250px; height: 250px; background: blue linear-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12676/star.svg); mask-repeat: repeat; /* Can be changed in the live sample */ margin-bottom: 10px; } HTML Content <
div id="masked"> </
div> <select id="repetition"> <option value="repeat-x">repeat-x</option> <option value="repeat-y">repeat-y</option> <option value="repeat" selected>repeat</option> <option value="space">space</option> <option value="round">round</option> <option value="no-repeat">no-repeat</option> </select> JavaScript Content var repetition = document.getElementById("repetition"); r...
mask-size - CSS: Cascading Style Sheets
les Setting mask size as a percentage CSS #masked { width: 200px; height: 200px; background: blue linear-gradient(red, blue); -webkit-mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg); mask-image: url(https://mdn.mozillademos.org/files/12668/MDN.svg); -webkit-mask-size: 50%; mask-size: 50%; /* Can be changed in the live sample */ margin-bottom: 10px; } HTML <
div id="masked"> </
div> <select id="maskSize"> <option value="auto">auto</option> <option value="40% 80%">40% 80%</option> <option value="50%" selected>50%</option> <option value="200px 100px">200px 100px</option> <option value="cover">cover</option> <option value="contain">contain</option> </select> JavaScript var maskSize = document.getElementById("maskSize"); maskSize.addEventListen...
mask - CSS: Cascading Style Sheets
The mask CSS shorthand property hides an element (partially or fully) by masking or clipping the image at specific points. As well as the properties listed below, the mask shorthand also resets mask-border to its initial value. It is therefore recommended to use the mask shorthand rather than other shorthands or the in
dividual properties to override any mask settings earlier in the cascade. This will ensure that mask-border has also been reset to allow the new styles to take effect. Constituent properties This property is a shorthand for the following CSS properties: mask-clip mask-composite mask-image mask-mode mask-origin mask-position mask-repeat mask-size Syntax /* Keyword values */ mask: none; /* Image values */ mask: url(mask.png); /* Pixel imag...
max() - CSS: Cascading Style Sheets
involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables may be treated as if auto had been specified. It is permitted to nest min() and other max() functions as expression values. The expressions are full math expressions, so you can use direct addition, subtraction, multiplication and
division without using the calc() function itself. The expression can be values combining the addition ( + ), subtraction ( - ), multiplication ( * ) and
division ( / ) operators, using standard operator precedence rules. Make sure to put a space on each side of the + and - operands. The operands in the expression may be any <length> syntax value. You can (and often need to) combine min() and max()...
min() - CSS: Cascading Style Sheets
involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables may be treated as if auto had been specified. It is permitted to nest max() and other min() functions as expression values. The expressions are full math expressions, so you can use direct addition, subtraction, multiplication and
division without using the calc() function itself. The expression can be values combining the addition ( + ), subtraction ( - ), multiplication ( * ) and
division ( / ) operators, using standard operator precedence rules. Make sure to put a space on each side of the + and - operands. The operands in the expression may be any <length> syntax value. You can (and often need to) combine min() and max()...
minmax() - CSS: Cascading Style Sheets
) CSS properties minmax() function can be used within: grid-template-columns grid-template-rows grid-auto-columns grid-auto-rows Examples CSS #container { display: grid; grid-template-columns: minmax(min-content, 300px) minmax(200px, 1fr) 150px; grid-gap: 5px; box-sizing: border-box; height: 200px; width: 100%; background-color: #8cffa0; padding: 10px; } #container >
div { background-color: #8ca0ff; padding: 5px; } HTML <
div id="container"> <
div> Item as wide as the content, but at most 300 pixels. </
div> <
div> Item with flexible width but a minimum of 200 pixels. </
div> <
div> Inflexible item of 150 pixels width. </
div> </
div> Result Specifications Specification Status Comment CSS Grid LayoutThe defi...
object-fit - CSS: Cascading Style Sheets
/samples/ae/248a9938d9.png" alt="MDN Logo"> <h2>object-fit: scale-down</h2> <img class="scale-down" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="MDN Logo"> <img class="scale-down narrow" src="https://udn.realityripple.com/samples/ae/248a9938d9.png" alt="MDN Logo"> </section> CSS h2 { font-family: Courier New, monospace; font-size: 1em; margin: 1em 0 0.3em; }
div { display: flex; flex-direction: column; flex-wrap: wrap; align-items: flex-start; height: 940px; } img { width: 150px; height: 100px; border: 1px solid #000; } .narrow { width: 100px; height: 150px; margin-top: 10px; } .fill { object-fit: fill; } .contain { object-fit: contain; } .cover { object-fit: cover; } .none { object-fit: none; } .scale-down { object...
opacity - CSS: Cascading Style Sheets
cker MDN Understanding WCAG, Guideline 1.4 explanations Understanding Success Criterion 1.4.3 | W3C Understanding WCAG 2.0 Formal definition Initial value1.0Applies toall elementsInheritednoComputed valuethe specified value, clipped in the range [0,1]Animation typea number Formal syntax <alpha-value>where <alpha-value> = <number> | <percentage> Examples Setting background opacity HTML <
div class="light">You can barely see this.</
div> <
div class="medium">This is easier to see.</
div> <
div class="heavy">This is very easy to see.</
div> CSS
div { background-color: yellow; } .light { opacity: 0.2; /* Barely see the text over the background */ } .medium { opacity: 0.5; /* See the text more clearly over the background */ } .heavy { opacity: 0.9; /* See the text very clearly over th...
outline-offset - CSS: Cascading Style Sheets
The space between an element and its outline is transparent. In other words, it is the same as the parent element's background. Formal definition Initial value0Applies toall elementsInheritednoComputed valueas specified, but with relative lengths converted into absolute lengthsAnimation typea length Formal syntax <length> Examples Setting outline offset in pixels HTML <p>Gallia est omnis
divisa in partes tres.</p> CSS p { outline: 1px dashed red; outline-offset: 10px; background: yellow; border: 1px solid blue; margin: 15px; } Result Specifications Specification Status Comment CSS Basic User Interface Module Level 3The definition of 'outline-offset' in that specification. Recommendation Initial definition Browser compatibilit...
overscroll-behavior-x - CSS: Cascading Style Sheets
inner box has a small width (and height) set on it so it sits comforably inside the viewport, but its content is given a large width so it will scroll horizontally. By default, when the inner box is scrolled and a scroll boundary is reached, the whole page will begin to scroll, which is probably not what we want. To avoid this, you can set overscroll-behavior-x: contain on the inner box: main >
div { height: 300px; width: 500px; overflow: auto; position: relative; top: 100px; left: 100px; overscroll-behavior-x: contain; } Specifications Specification Status Comment CSS Overscroll Behavior Module Level 1The definition of 'overscroll-behavior-x' in that specification. Working Draft ...
place-self - CSS: Cascading Style Sheets
the align-self and justify-self properties) in a relevant layout system such as Grid or Flexbox. If the second value is not present, the first value is also used for it. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
revert - CSS: Cascading Style Sheets
y. The revert keyword is different from and should not be confused with initial, which uses the initial value defined on a per-property basis by the CSS specifications. In contrast, user-agent stylesheets set default values on the basis of CSS selectors. For example, the initial value for the display property is inline, whereas a normal user-agent stylesheet sets the default display value of <
div>s to block, of <table>s to table, etc. Examples Revert vs unset Although revert and unset are similar they differ for some properties for some elements. So in the below example, we set custom font-weight in a global stylesheet, but then try to unset and revert. Unset will keep the text normal because this is an initial value for font-weight property. Revert will revert to bold because this i...
scrollbar-width - CSS: Cascading Style Sheets
W3C Understanding WCAG 2.1 Understanding Success Criterion 2.5.5 | W3C Understanding WCAG 2.1 Formal definition Initial valueautoApplies toscrolling boxesInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax auto | thin | none Examples Sizing overflow scrollbars CSS .scroller { width: 300px; height: 100px; overflow-y: scroll; scrollbar-width: thin; } HTML <
div class="scroller">Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic. Gumbo beet greens corn soko en
dive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</
div> Result Specifications Spe...
shape-image-threshold - CSS: Cascading Style Sheets
ge 0.0 (fully transparent) to 1.0 (fully opaque) are clamped to this range. Formal definition Initial value0.0Applies tofloatsInheritednoComputed valueThe same as the specified value after clipping the <number> to the range [0.0, 1.0].Animation typea number Formal syntax <alpha-value>where <alpha-value> = <number> | <percentage> Examples Aligning text to a gradient This example creates a <
div> block with a gradient background image. The gradient is established as a CSS shape using shape-outside, so that pixels within the gradient which are at least 20% opaque (that is, those pixels with an alpha component greater than 0.2) are considered part of the shape. HTML <
div id="gradient-shape"></
div> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vel at commodi voluptate...
shape-outside - CSS: Cascading Style Sheets
| <percentage><hue> = <number> | <angle><linear-color-stop> = <color> <color-stop-length>?<linear-color-hint> = <length-percentage><angular-color-stop> = <color> && <color-stop-angle>?<angular-color-hint> = <angle-percentage>where <color-stop-length> = <length-percentage>{1,2}<color-stop-angle> = <angle-percentage>{1,2}<angle-percentage> = <angle> | <percentage> Examples Funneling text HTML <
div class="main"> <
div class="left"></
div> <
div class="right"></
div> <p> Sometimes a web page's text content appears to be funneling your attention towards a spot on the page to drive you to follow a particular link. Sometimes you don't notice. </p> </
div> CSS .main { width: 530px; } .left, .right { width: 40%; height: 12ex; background-color: lightgray; } .left { ...
<time-percentage> - CSS: Cascading Style Sheets
Examples Use in calc() Where a <time-percentage> is specified as an allowable type, this means that the percentage resolves to a time and therefore can be used in a calc() expression. ...
touch-action - CSS: Cascading Style Sheets
ted valueas specifiedAnimation typediscrete Formal syntax auto | none | [ [ pan-x | pan-left | pan-right ] | [ pan-y | pan-up | pan-down ] | pinch-zoom ] | manipulation Examples Disabling all gestures The most common usage is to disable all gestures on an element (and its non-scrollable descendants) that provides its own dragging and zooming behavior - such as a map or game surface. HTML <
div id="map"></
div> CSS #map { height: 400px; width: 400px; background: blue; touch-action: none; } Result Specifications Specification Status Comment Compatibility StandardThe definition of 'touch-action' in that specification. Living Standard Added pinch-zoom property value. Pointer Events - Level 3The definition of 'touch-action' in that s...
rotateX() - CSS: Cascading Style Sheets
clockwise rotation, a negative angle a counter-clockwise one. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. 1000cos(a)-sin(a)0sin(a)cos(a) 10000cos(a)-sin(a)00sin(a)cos(a)00001 Examples HTML <
div>Normal</
div> <
div class="rotated">Rotated</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .rotated { transform: rotateX(45deg); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 2The definition of 'rotateX()' in that specification. Editor's Draft Initial definition ...
rotateY() - CSS: Cascading Style Sheets
clockwise rotation, a negative angle a counter-clockwise one. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. cos(a)0sin(a)010-sin(a)0cos(a) cos(a)0sin(a)00100-sin(a)0cos(a)00001 Examples HTML <
div>Normal</
div> <
div class="rotated">Rotated</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .rotated { transform: rotateY(60deg); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 2The definition of 'rotateY()' in that specification. Editor's Draft Initial definition ...
rotateZ() - CSS: Cascading Style Sheets
se rotation, a negative angle a counter-clockwise one. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 This transformation applies to the 3D space and can't be represented on the plane. cos(a)-sin(a)0sin(a)cos(a)0001 cos(a)-sin(a)00 sin(a)cos(a)00 0010 0001 Examples HTML <
div>Normal</
div> <
div class="rotated">Rotated</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .rotated { transform: rotateZ(45deg); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 2The definition of 'rotateZ()' in that specification. Editor's Draft Initial definition ...
scaleX() - CSS: Cascading Style Sheets
Syntax scaleX(s) Values s Is a <number> representing the scaling factor to apply on the abscissa of each point of the element. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 s0 01 s00010001 s00010001 s000010000100001 [s 0 0 1 0 0] Examples HTML <
div>Normal</
div> <
div class="scaled">Scaled</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .scaled { transform: scaleX(0.6); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 1The definition of 'scaleX()' in that specification. Working Draft Initial definition ...
scaleY() - CSS: Cascading Style Sheets
Syntax scaleY(s) Values s Is a <number> representing the scaling factor to apply on the ordinate of each point of the element. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 10 0s 1000s0001 1000s0001 10000s0000100001 [1 0 0 s 0 0] Examples HTML <
div>Normal</
div> <
div class="scaled">Scaled</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .scaled { transform: scaleY(0.6); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 1The definition of 'scaleY()' in that specification. Working Draft Initial definition ...
skewX() - CSS: Cascading Style Sheets
x skewX(a) Values a Is an <angle> representing the angle to use to distort the element along the abscissa. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 1tan(a)01 1tan(a)0010001 1tan(a)0010001 1tan(a)00010000100001 [1 0 tan(a) 1 0 0] Examples HTML <
div>Normal</
div> <
div class="skewed">Skewed</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .skewed { transform: skewX(10deg); /* Equal to skew(10deg) */ background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 1The definition of 'skewX()' in that specification. Working Draft Initial ...
skewY() - CSS: Cascading Style Sheets
x skewY(a) Values a Is an <angle> representing the angle to use to distort the element along the ordinate. Cartesian coordinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 10tan(a)1 100tan(a)10001 100tan(a)10001 1000tan(a)10000100001 [1 tan(a) 0 1 0 0] Examples HTML <
div>Normal</
div> <
div class="skewed">Skewed</
div> CSS
div { width: 80px; height: 80px; background-color: skyblue; } .skewed { transform: skewY(40deg); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 1The definition of 'skewY()' in that specification. Working Draft Initial definition ...
translateX() - CSS: Cascading Style Sheets
rdinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 A translation is not a linear transformation in R2 and can't be represented using a Cartesian-coordinate matrix. 10t010001 10t010001 100t010000100001 [1 0 0 1 t 0] Formal syntax translateX(<length-percentage>) Examples HTML <
div>Static</
div> <
div class="moved">Moved</
div> <
div>Static</
div> CSS
div { width: 60px; height: 60px; background-color: skyblue; } .moved { transform: translateX(10px); /* Equal to translate(10px) */ background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 1The definition of 'translateX()' in that specification. ...
translateY() - CSS: Cascading Style Sheets
dinates on R2 Homogeneous coordinates on RP2 Cartesian coordinates on R3 Homogeneous coordinates on RP3 A translation is not a linear transformation in R2 and can't be represented using a Cartesian-coordinate matrix. 10001t001 10001t001 1000010t00100001 [1 0 0 1 0 t] Formal syntax translateY(<length-percentage>) Examples HTML <
div>Static</
div> <
div class="moved">Moved</
div> <
div>Static</
div> CSS
div { width: 60px; height: 60px; background-color: skyblue; } .moved { transform: translateY(10px); background-color: pink; } Result Specifications Specification Status Comment CSS Transforms Level 1The definition of 'translateY()' in that specification. Working Draft Initial def...
translateZ() - CSS: Cascading Style Sheets
represented on the plane. A translation is not a linear transformation in R3 and can't be represented using a Cartesian-coordinate matrix. 10000100001t0001 Examples In this example, two boxes are created. One is positioned normally on the page, without being translated at all. The second is altered by applying perspective to create a 3D space, then moved towards the user. HTML <
div>Static</
div> <
div class="moved">Moved</
div> CSS
div { position: relative; width: 60px; height: 60px; left: 100px; background-color: skyblue; } .moved { transform: perspective(500px) translateZ(200px); background-color: pink; } What really matters here is the class "moved"; let's take a look at what it does. First, the perspective() function positions the viewer relative to the ...
unicode-bidi - CSS: Cascading Style Sheets
l following the Unicode Bidirectional Algorithm. Formal definition Initial valuenormalApplies toall elements, though some values have no effect on non-inline elementsInheritednoComputed valueas specifiedAnimation typediscrete Formal syntax normal | embed | isolate | bidi-override | isolate-override | plaintext Examples CSS .bible-quote { direction: rtl; unicode-bidi: embed; } HTML <
div class="bible-quote"> A line of text </
div> <
div> Another line of text </
div> Result Specifications Specification Status Comment CSS Writing Modes Module Level 3The definition of 'unicode-bidi' in that specification. Proposed Recommendation Added plaintext, isolate, and isolate-override keywords. CSS Level 2 (Revision 1)The definition of 'unicod...
user-modify - CSS: Cascading Style Sheets
om the list below. Values read-only Default value. Contents are read-only. read-write The user is able to read and write contents. read-write-plaintext-only Same as read-write, but rich text formatting will be lost. write-only The user is able to edit the content, but not to read it. Formal definition Value not found in DB! Formal syntax Syntax not found in DB! Examples HTML <
div class="readwrite">The user is able to change this text.</
div> CSS .readwrite { -moz-user-modify: read-write; -webkit-user-modify: read-write; } Specifications Not part of any standard. A similar property, user-focus, was proposed in early drafts of a predecessor of the CSS3 UI specification, but was rejected by the working group. ...
width - CSS: Cascading Style Sheets
gth-percentage> = <length> | <percentage> Examples Default width p.goldie { background: gold; } <p class="goldie">The Mozilla community produces a lot of great software.</p> Pixels and ems .px_length { width: 200px; background-color: red; color: white; border: 1px solid black; } .em_length { width: 20em; background-color: white; color: red; border: 1px solid black; } <
div class="px_length">Width measured in px</
div> <
div class="em_length">Width measured in em</
div> Percentage .percent { width: 20%; background-color: silver; border: 1px solid red; } <
div class="percent">Width in percentage</
div> max-content p.maxgreen { background: lightgreen; width: intrinsic; /* Safari/WebKit uses a non-standard name */ width: -moz-max-content; /...
word-spacing - CSS: Cascading Style Sheets
values */ word-spacing: inherit; word-spacing: initial; word-spacing: unset; Values normal The normal inter-word spacing, as defined by the current font and/or the browser. <length> Specifies extra spacing in addition to the intrinsic inter-word spacing defined by the font. <percentage> Specifies extra spacing as a percentage of the affected character's advance width. Examples HTML <
div id="moz
div1">Here are many words...</
div> <
div id="moz
div2">...and many more!</
div> CSS #moz
div1 { word-spacing: 15px; } #moz
div2 { word-spacing: 5em; } Accessibility concerns A large positive or negative word-spacing value will make the sentences the styling is applied to unreadable. For text styled with a very large positive value, the words will be so far apart that it will no long...
zoom - CSS: Cascading Style Sheets
tednoComputed valueas specifiedAnimation typean integer Formal syntax normal | reset | <number> | <percentage> Examples First example HTML <p class="small">Small</p> <p class="normal">Normal</p> <p class="big">Big</p> CSS p.small { zoom: 75%; } p.normal { zoom: normal; } p.big { zoom: 2.5; } p { display: inline-block; } p:hover { zoom: reset; } Result Second example HTML <
div id="a" class="circle"></
div> <
div id="b" class="circle"></
div> <
div id="c" class="circle"></
div> CSS
div.circle { width: 25px; height: 25px; border-radius: 100%; text-align: center; vertical-align: middle; display: inline-block; zoom: 1.5; }
div#a { background-color: gold; zoom: normal; }
div#b { background-color: green; zoom: 200%; }
div#c { background-color: blue; zo...
Cross-browser audio basics - Developer guides
An Audio Player with Feedback Consider this snippet of HTML: <audio id="my-audio"> <source src="https://udn.realityripple.com/samples/6c/d385042de2.mp3" type="audio/mpeg"> <source src="https://udn.realityripple.com/samples/28/191a7bd2a5.ogg" type="audio/ogg"> <!-- place fallback here as <audio> supporting browsers will ignore it --> <a href="audiofile.mp3">audiofile.mp3</a> </audio> <
div id="controls"> <span id="loading">loading</span> <button id="play" style="display:none">play</button> <button id="pause" style="display:none" >pause</button> </
div> <
div id="progress"> <
div id="bar"></
div> </
div> Styled like so: #controls { width: 80px; float: left; } #progress { margin-left: 80px; border: 1px solid black; } #bar { height: 20px; background-color: gre...
Creating a cross-browser video player - Developer guides
API HTML5 comes with a JavaScript Media API that allows developers access to and control of HTML5 media. This API will be used to make the custom control set defined above actually do something. In addition, the fullscreen button will use the Fullscreen API, another W3C API that controls the ability of web browsers to show apps using your computer's full screen. Setup Before dealing with the in
dividual buttons, a number of initialisation calls are required. To begin with, it's a good idea to first check if the browser actually supports the <video> element and to only setup the custom controls if it does. This is done by simply checking if a created <video> element supports the canPlayType() method, which any supported HTML5 <video> element should. var supportsVideo = !!document.createEle...
Audio and Video Delivery - Developer guides
The most popular libraries allow you to choose a consistent player design over all browsers and provide a fallback for browsers that don't support audio and video natively. Fallbacks often use Adobe Flash or Microsoft Silverlight ...
Overview of events and handlers - Developer guides
The Event object hierarchy The web browser defines many events of different kinds. Each definition includes, as the data structure passed to the handler function, an object which inherits from the EventPrototype object. A partial diagram of the cl...
Content categories - Developer guides
this category are <base>, <command>, <link>, <meta>, <noscript>, <script>, <style> and <title>. Flow content Elements belonging to the flow content category typically contain text or embedded content. ...
HTML attribute: multiple - HTML: Hypertext Markup Language
browsers. Specifications Specification Status Comment HTML Living StandardThe definition of 'multiple attribute' in that specification. Living Standard HTML5The definition of 'multiple attribute' in that specification. Recommendation Accessibility concerns Provide instructions to help users understand how to complete the form and use in
dividual form controls. Indicate any required and optional input, data formats, and other relevant information. When using the multiple attribute, inform the user that multiple values are allowed and provide directions on how to provide multiple values, such as "separate email addresses with a comma." Setting size="1" on a multiple select can make it appear as a single select in some browsers, but t...
HTML attribute: step - HTML: Hypertext Markup Language
more information. Specifications Specification Status Comment HTML Living StandardThe definition of 'step attribute' in that specification. Living Standard HTML5The definition of 'step attribute' in that specification. Recommendation Accessibility concerns Provide instructions to help users understand how to complete the form and use in
dividual form controls. Indicate any required and optional input, data formats, and other relevant information. When using the min attribute, ensure this minimum requirement is understood by the user. Providing instructions within the <label> may be sufficient. If providing instructions outside of labels, which allows more flexible positioning and design, consider using aria-labelledby or aria-descr...
<audio>: The Embed Audio element - HTML: Hypertext Markup Language
e a display value of inline by default, and it is often a good idea set the value to block to improve control over positioning and layout, unless you want it to sit within a text block or similar. You can style the default controls with properties that affect the block as a single unit, so for example you can give it a border and border-radius, padding, margin, etc. You can't however style the in
dividual components inside the audio player (e.g. change the button size or icons, change the font, etc.), and the controls are different across the different browsers. To get a consistent look and feel across browsers, you'll need to create custom controls; these can be marked up and styled in whatever way you want, and then JavaScript can be used along with the HTMLMediaElement API to wire up thei...
<bdo>: The Bidirectional Text Override element - HTML: Hypertext Markup Language
directionality of text, so that the text within is rendered in a different direction. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. The text's characters are drawn from the starting point in the given direction; the in
dividual characters' orientation is not affected (so characters don't get drawn backward, for example). Content categories Flow content, phrasing content, palpable content. Permitted content Phrasing content. Tag omission None, both the starting and ending tag are mandatory. Permitted parents Any element that accepts phrasing content. Implicit...
<bgsound>: The Background Sound element (obsolete) - HTML: Hypertext Markup Language
The Internet Explorer only HTML Background Sound element (<bgsound>) sets up a sound file to play in the background while the page is used; use <audio> instead. Do not use this! In order to embed audio in a Web page, you should be using the <audio> element. Attributes balance This attribute defines a number between -10,000 and +10,000 that determines how the volume will be
divided between the speakers. loop This attribute indicates the number of times a sound is to be played and either has a numeric value or the keyword infinite. src This attribute specifies the URL of the sound file to be played, which must be one of the following types: .wav, .au, or .mid. volume This attribute defines a number between -10,000 and 0 that determines the loudness of a page's backgrou...
<br>: The Line Break element - HTML: Hypertext Markup Language
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. As you can see from the above example, a <br> element is included at each point where we want the text to break. The text after the <br> begins again at the start of the next line of the text block. ...
<content>: The Shadow DOM Content Placeholder element (obsolete) - HTML: Hypertext Markup Language
lect the content to insert in place of the <content> element. Example Here is a simple example of using the <content> element. It is an HTML file with everything needed in it. Note: For this code to work, the browser you display it in must support Web Components. See Enabling Web Components in Firefox. <html> <head></head> <body> <!-- The original content accessed by <content> --> <
div> <h4>My Content Heading</h4> <p>My content text</p> </
div> <script> // Get the <
div> above. var myContent = document.querySelector('
div'); // Create a shadow DOM on the <
div> var shadowroot = myContent.createShadowRoot(); // Insert into the shadow DOM a new heading and // part of the original content: the <p> tag. shadowroot.innerHTML = '<h2>Inserted Heading</h2> <co...
<dd>: The Description Details element - HTML: Hypertext Markup Language
e-examples and send us a pull request. Content categories None. Permitted content Flow content. Tag omission The start tag is required. The end tag may be omitted if the <dd> element is immediately followed by another <dd> element or a <dt> element, or if there is no more content in the parent element. Permitted parents <dl> or (in WHATWG HTML) a <
div> that is inside a <dl>. Previous sibling <dt> or another <dd> element. Implicit ARIA role definition Permitted ARIA roles No role permitted DOM interface HTMLElement Attributes This element's attributes include the global attributes. nowrap If the value of this attribute is set to yes, the definition text will not wrap. The default val...
<dfn>: The Definition element - HTML: Hypertext Markup Language
et. Duo Reges: constructio interrete. Scrupulum, inquam, abeunti; </p> <p>Negare non possum. Dat enim intervalla et relaxat. Quonam modo? Equidem e Cn. Quid de Pythagora? In schola desinis. </p> <p>Ubi ut eam caperet aut quando? Cur iustitia laudatur? Aperiendum est igitur, quid sit voluptas; Quid enim? Non est igitur voluptas bonum. Urgent tamen et nihil remittunt. Quid enim possumus hoc agere
divinius? </p> <p>Because of all of that, we decided to use the <code><a href="#definition-dfn"><dfn></a></code> element for this project.</p> Here we see the definition -- now with an id attribute, "definition-dfn", which can be used as the target of a link. Later on, a link is created using <a> with the href attribute set to "#definition-dfn" to set up the link back to the definition. Resu...
<dt>: The Description Term element - HTML: Hypertext Markup Language
low content, but with no <header>, <footer>, sectioning content or heading content descendants. Tag omission Must have a start tag. The end tag may be omitted if this element is immediately followed by another <dt> or a <dd> element, or if there is no more content in the parent element. Permitted parents Before a <dt> or a <dd> element, inside a <dl> or (in WHATWG HTML) a <
div> that is inside a <dl>. Implicit ARIA role term Permitted ARIA roles listitem DOM interface HTMLElement Up to Gecko 1.9.2 (Firefox 4) inclusive, Firefox implements the HTMLSpanElement interface for this element. Attributes This element only includes the global attributes. Example For an example, see the example provided for the <dl> element. Specific...
<fieldset>: The Field Set element - HTML: Hypertext Markup Language
<legend>Simple fieldset</legend> <input type="radio" id="radio"> <label for="radio">Spirit of radio</label> </fieldset> </form> Disabled fieldset This example shows a disabled <fieldset> with two controls inside it. Note how both the controls are disabled due to being inside a disabled <fieldset>. <form action="#"> <fieldset disabled> <legend>Disabled fieldset</legend> <
div> <label for="name">Name: </label> <input type="text" id="name" value="Chris"> </
div> <
div> <label for="pwd">Archetype: </label> <input type="password" id="pwd" value="Wookie"> </
div> </fieldset> </form> Technical summary Content categories Flow content, sectioning root, listed, form-associated element, palpable content. Permitted cont...
<img>: The Image Embed element - HTML: Hypertext Markup Language
his pixel density descriptor is already defined in srcset, or unless srcset contains w descriptors. srcset One or more strings separated by commas, indicating possible image sources for the user agent to use. Each string is composed of: A URL to an image Optionally, whitespace followed by one of: A width descriptor (a positive integer directly followed by w). The width descriptor is
divided by the source size given in the sizes attribute to calculate the effective pixel density. A pixel density descriptor (a positive floating point number directly followed by x). If no descriptor is specified, the source is assigned the default descriptor of 1x. It is incorrect to mix width descriptors and pixel density descriptors in the same srcset attribute. Duplicate descripto...
<input type="range"> - HTML: Hypertext Markup Language
Unfortunately, no major browsers currently support vertical range controls directly. transform: rotate(-90deg) You can, however, create a vertical range control by drawing a horizontal range control on its side. The easiest way is to use CSS: by applying a transform to rotate the element, you can make it vertical. Let's take a look. HTML The HTML needs to be updated to wrap the <input> in a <
div> to let us correct the layout after the transform is performed (since transforms don't automatically affect the layout of the page): <
div class="slider-wrapper"> <input type="range" min="0" max="11" value="7" step="1"> </
div> CSS Now we need some CSS. First is the CSS for the wrapper itself; this specifies the display mode and size we want so that the page lays out correctly; in essence, it'...
<listing> - HTML: Hypertext Markup Language
ented by all browsers, nor in a consistent way. Even more it is obsoleted in HTML5 and may be rendered by conforming user-agents as the <pre> element, which will interpret the internal HTML! Instead use the <pre> element or if semantically adequate the <code> element, eventually escaping the HTML '<' and '>' so that they don't get interpreted. A monospaced font can also be obtained on a simple <
div> element, by applying an adequate CSS style using monospace as the generic-font value in a font-family property. Attributes This element has no other attributes than the global attributes, common to all elements. DOM interface This element implements the HTMLElement interface. Implementation note: up to Gecko 1.9.2 inclusive, Firefox implements the HTMLSpanElement interface for this eleme...
Standard metadata names - HTML: Hypertext Markup Language
it isn't truly compatible with it can result in unreadable content; all major browsers default to light mode if not otherwise configured. For example, to indicate that a document prefers dark mode but does render functionally in light mode as well: <meta name="color-scheme" content="dark light"> This works at the document level in the same way that the CSS color-scheme property lets in
dividual elements specify their preferred and accepted color schemes. Your styles can adapt to the current color scheme using the prefers-color-scheme CSS media feature. The CSS Device Adaptation specification defines the following metadata name: viewport: gives hints about the size of the initial size of the viewport. Used by mobile devices only. Values for the content of <meta name...
<nextid>: The NeXT ID element (Obsolete) - HTML: Hypertext Markup Language
<NEXTID> to take only a number for a value of its newly-introduced attribute N. HTML "1.k" - Version 1 (first release) In this first published draft of HTML, <NEXTID> is the same as it would take in HTML 2, finally allowing the use of a name instead of only a number for its attribute value. HTML "1.m" - Version 1 (second release) In the next published draft of HTML, <NEXTID> <NEXTID> can be in
dividually deselected for display with a simple SGML command. HTML Version 2 Level 1 This is like the level 2 default but it excludes all the forms elements, i. e. <FORM>, <INPUT>, <TEXTAREA>, <SELECT>, and <OPTION> HTML Version 2 Strict Level 1 This is like regular Level 1 but it also excludes these depreciated elements, along with such constructs as nesting a header (<H*> element) within a link...
<p>: The Paragraph element - HTML: Hypertext Markup Language
nteractive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Content categories Flow content, palpable content. Permitted content Phrasing content. Tag omission The start tag is required. The end tag may be omitted if the <p> element is immediately followed by an <address>, <article>, <aside>, <blockquote>, <
div>, <dl>, <fieldset>, <footer>, <form>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <header>, <hr>, <menu>, <nav>, <ol>, <pre>, <section>, <table>, <ul> or another <p> element, or if there is no more content in the parent element and the parent element is not an <a> element. Permitted parents Any element that accepts flow content. Implicit ARIA role No corresponding role Pe...
<rtc>: The Ruby Text Container element - HTML: Hypertext Markup Language
Phrasing content or <rt> elements. Tag omission The closing tag can be omitted if it is immediately followed by a <rb>, <rtc> or <rt> element opening tag or by its parent closing tag. Permitted parents A <ruby> element. Permitted ARIA roles Any DOM interface HTMLElement Attributes This element only includes the global attributes. Examples <
div class="info"> <ruby> <rbc> <rb>?</rb><rt>jiu</rt> <rb>?</rb><rt>jin</rt> <rb>?</rb><rt>shan</rt> </rbc> <rtc>San Francisco</rtc> </ruby> </
div> .info { padding-top: 10px; font-size: 36px; } Specifications Specification Status Comment HTML 5.2The definition of '<rtc>' in that specification. Recommendation HT...
<select>: The HTML Select element - HTML: Hypertext Markup Language
"parrot">Parrot</option> <option value="macaw">Macaw</option> <option value="albatross">Albatross</option> </optgroup> </select> </label> You'll see that: Multiple options are selectable because we've included the multiple attribute. The size attribute causes only 4 lines to display at a time; you can scroll to view all the options. We've included <optgroup> elements to
divide the options up into different groups. This is a purely visual grouping, its visualization generally consists of the group name being bolded, and the options being indented. The "Hamster" option includes a disabled attribute and therefore can't be selected at all. Technical summary Content categories Flow content, phrasing content, interactive content, listed, labelable, resetta...
<span> - HTML: Hypertext Markup Language
The HTML <span> element is a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang. It should be used only when no other semantic element is appropriate. <span> is very much like a <
div> element, but <
div> is a block-level element whereas a <span> is an inline element. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Content categories Flow content, phrasing content. Permitted content Phrasing content. Ta...
<tbody>: The Table Body element - HTML: Hypertext Markup Language
r from page to page. When a table is presented in a screen context (such as a window) which is not large enough to display the entire table, the user agent may let the user scroll the contents of the <thead>, <tbody>, <tfoot>, and <caption> blocks separately from one another for the same parent table. You may use more than one <tbody> per table as long as they are all consecutive. This lets you
divide the rows in large tables into sections, each of which may be separately formatted if so desired. Examples Below are some examples showing the use of the <tbody> element. For more examples of this tag in use, see the examples for <table>. Basic example In this relatively simple example, we create a table listing information about a group of students with a <thead> and a <tbody>, with a num...
<wbr> - HTML: Hypertext Markup Language
ntent. Implicit ARIA role No corresponding role Permitted ARIA roles Any DOM interface HTMLElement Attributes This element only includes the global attributes. Notes On UTF-8 encoded pages, <wbr> behaves like the U+200B ZERO-WIDTH SPACE code point. In particular, it behaves like a Unicode bidi BN code point, meaning it has no effect on bidi-ordering: <
div dir=rtl>123,<wbr>456</
div> displays, when not broken on two lines, 123,456 and not 456,123. For the same reason, the <wbr> element does not introduce a hyphen at the line break point. To make a hyphen appear only at the end of a line, use the soft hyphen character entity (­) instead. This element was first implemented in Internet Explorer 5.5 and was officially defined in HTML5. Example T...
accesskey - HTML: Hypertext Markup Language
ive technology functionality. What may work for one combination of operating system, assistive technology, and browser may not work with other combinations. Certain accesskey values may not be present on certain keyboards, especially when internationalization is a concern. So adapting to specific languages could cause further problems. accesskey values that rely on numbers may be confusing to in
dividuals experiencing cognitive concerns, where the number doesn't have a logical association with the functionality it triggers. Informing the user that accesskeys are present, so that they are aware of the functionality. If the system lacks a method of notifying the user about this feature, the user might accidentally activate accesskeys. Because of these issues, it is generally advised not to...
HTML: Hypertext Markup Language
Links are a fundamental aspect of the Web. By uploading content to the Internet and linking it to pages created by other people, you become an active participant in the World Wide Web. HTML uses "markup" to annotate text, images, and other content for display in a Web browser. HTML markup includes special "elements" such as <head>, <title>, <body>, <header>, <footer>, <article>, <section>, <p>, <
div>, <span>, <img>, <aside>, <audio>, <canvas>, <datalist>, <details>, <embed>, <nav>, <output>, <progress>, <video>, <ul>, <ol>, <li> and many others. An HTML element is set off from other text in a document by "tags", which consist of the element name surrounded by "<" and ">". The name of an element inside a tag is case insensitive. That is, it can be written in uppercase, lowercase, or a mixtu...
Resource URLs - HTTP
entral/rev/48ea452803907f2575d81021e8678634e8067fc2/browser/app/profile/firefox.js#575 Web sites can easily collect Firefox default preferences by overriding this pref() function and using the script resource:///defaults/preferences/firefox.js. Furthermore, some default values of preferences differ between build configurations, such as platform and locale, which means web sites could identify in
dividual users using this information. Solution In order to fix this problem, Mozilla changed the behavior of loading resource: URIs in bug 863246, which landed in Firefox 57 (Quantum). In the past, web content was able to access whatever resource: URIs were desired -- not only Firefox's internal resources, but also extensions' assets. Now this behavior is prohibited by default. It is however st...
Browser detection using the user agent - HTTP
do user agent sniffing. There is always the alternative of doing feature detection instead. Do you want to provide different HTML depending on which browser is being used? This is usually a bad practice, but there are some cases in which this is necessary. In these cases, you should first analyze your situation to be sure it's really necessary. Can you prevent it by adding some non-semantic <
div> or <span> elements? The difficulty of successfully using user agent detection is worth a few disruptions to the purity of your HTML. Also, rethink your design: can you use progressive enhancement or fluid layouts to help remove the need to do this? Avoiding user agent detection If you want to avoid using user agent detection, you have options! Feature detection Feature detection is where ...
HTTP caching - HTTP
ry often the case, it is checked if an Expires header is present. If an Expires header exists, then its value minus the value of the Date header determines the freshness lifetime. Finally, if neither header is present, look for a Last-Modified header. If this header is present, then the cache's freshness lifetime is equal to the value of the Date header minus the value of the Last-modified header
divided by 10. The expiration time is computed as follows: expirationTime = responseTime + freshnessLifetime - currentAge where responseTime is the time at which the response was received according to the browser. Revved resources The more we use cached resources, the better the responsiveness and the performance of a Web site will be. To optimize this, good practices recommend to set expiratio...
Content negotiation - HTTP
t is in Chrome 46 or later. The Device-Memory value is in Chrome 61 or later. The experimental Accept-CH lists configuration data that can be used by the server to select an appropriate response. Valid values are: Value Meaning Device-Memory Indicates the approximate amount of device RAM. This value is an approximation given by rounding to the nearest power of 2 and
dividing that number by 1024. For example, 512 megabytes will be reported as 0.5. DPR Indicates the client's device pixel ratio. Viewport-Width Indicates the layout viewport width in CSS pixels. Width Indicates the resource width in physical pixels (in other words the intrinsic size of an image). The Accept-Charset header The Accept-Charset header indicates...
Using Feature Policy - HTTP
is enabled, known as an allowlist. If you do not specify a policy for a feature, then a default allowlist will be used. The default allowlist is specific to each feature. The Feature-Policy header is still in an experimental state, and is subject to change at any time. Be wary of this when implementing Feature Policy on your website. Writing a policy A policy is described using a set of in
dividual policy directives. A policy directive is a combination of a defined feature name, and an allowlist of origins that can use the feature. Features within a policy are separated by semicolons. allowlist An allowlist is a list of origins that takes one or more of the following values, separated by spaces: *: The feature will be allowed in this document, and all nested browsing contexts (ifr...
CSP: block-all-mixed-content - HTTP
irective or the other - not both, unless you want to force HTTPS on older browsers that do not force it after a redirect to HTTP. Syntax Content-Security-Policy: block-all-mixed-content; Examples Content-Security-Policy: block-all-mixed-content; <meta http-equiv="Content-Security-Policy" content="block-all-mixed-content"> To disallow http assets on a more granular level, you can also set in
dividual directives to https:. For example, to disallow nonsecure HTTP images: Content-Security-Policy: img-src https: Specifications Specification Status Comment Mixed ContentThe definition of 'block-all-mixed-content' in that specification. Candidate Recommendation Initial definition. ...
CSP: style-src-attr - HTTP
CSP version 3 Directive type Fetch directive default-src fallback Yes. If this directive is absent, the user agent will look for the style-src directive, and if both of them are absent, fallback to default-src directive. ...
Content-Security-Policy - HTTP
pt-src-elem Specifies valid sources for JavaScript <script> elements. script-src-attr Specifies valid sources for JavaScript inline event handlers. style-src Specifies valid sources for stylesheets. style-src-elem Specifies valid sources for stylesheets <style> elements and <link> elements with rel="stylesheet". style-src-attr Specifies valid sources for inline styles applied to in
dividual DOM elements. worker-src Specifies valid sources for Worker, SharedWorker, or ServiceWorker scripts. Document directives Document directives govern the properties of a document or worker environment to which a policy applies. base-uri Restricts the URLs which can be used in a document's <base> element. plugin-types Restricts the set of plugins that can be embedded into a document...
Expect-CT - HTTP
The Expect-CT header lets sites opt in to reporting and/or enforcement of Certificate Transparency requirements, to prevent the use of misissued certificates for that site from going unnoticed. CT requirements can be satisfied via any one of the following mechanisms: X.509v3 certificate extension to allow embedding of signed certificate timestamps issued by in
dividual logs A TLS extension of type signed_certificate_timestamp sent during the handshake Supporting OCSP stapling (that is, the status_request TLS extension) and providing a SignedCertificateTimestampList When a site enables the Expect-CT header, they are requesting that the browser check that any certificate for that site appears in public CT logs. Browsers ignore the Expect-CT header over HTTP; the header only has effe...
Referrer-Policy - HTTP
This policy will leak potentially-private information from HTTPS resource URLs to insecure origins. Carefully consider the impact of this setting. Integration with HTML You can also set referrer policies inside HTML. For example, you can set the referrer policy for the entire document with a <meta> element with a name of referrer: <meta name="referrer" content="origin"> Or set it for in
dividual requests with the referrerpolicy attribute on <a>, <area>, <img>, <iframe>, <script>, or <link> elements: <a href="http://example.com" referrerpolicy="origin"> Alternatively, a noreferrer link relation on an a, area, or link element can be set: <a href="http://example.com" rel="noreferrer"> Integration with CSS CSS can fetch resources referenced from stylesheets. These resources follow ...
Firefox user agent string reference - HTTP
intosh Here, x.y is the version of Mac OS X (for instance, Mac OS X 10.6). Mac OS X version Gecko user agent string Mac OS X on Intel x86 or x86_64 Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0 Mac OS X on PowerPC Mozilla/5.0 (Macintosh; PPC Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0 Linux Linux is a more
diverse platform. Your distribution of Linux might include an extension that changes your user-agent. A few common examples are given below. Linux version Gecko user agent string Linux desktop on i686 CPU Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0 Linux desktop on x86_64 CPU Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefo...
X-DNS-Prefetch-Control - HTTP
done by setting the network.dns.disablePrefetch preference to true. Also, by default, prefetching of embedded link hostnames is not performed on documents loaded over HTTPS. On Firefox, this can be changed by setting the network.dns.disablePrefetchFromHTTPS preference to false. Examples Turning on and off prefetching You can either send the X-DNS-Prefetch-Control header server-side, or from in
dividual documents, using the http-equiv attribute on the <meta> element, like this: <meta http-equiv="x-dns-prefetch-control" content="off"> You can reverse this setting by setting content to "on". Forcing lookup of specific hostnames You can force the lookup of specific hostnames without providing specific anchors using that hostname by using the rel attribute on the <link> element with a link...
HTTP Index - HTTP
, style-src The HTTP Content-Security-Policy (CSP) style-src directive specifies valid sources for stylesheets. 102 CSP: style-src-attr CSP, Content, Content-Security-Policy, Directive, HTTP, Reference, Security, Style, source, style-src, style-src-attr The HTTP Content-Security-Policy (CSP) style-src-attr directive specifies valid sources for inline styles applied to in
dividual DOM elements. 103 CSP: style-src-elem CSP, Content, Content-Security-Policy, Directive, HTTP, Reference, Security, Style, source, style-src, style-src-elem The HTTP Content-Security-Policy (CSP) style-src-elem directive specifies valid sources for stylesheets <style> elements and <link> elements with rel="stylesheet". 104 CSP: trusted-types The HTTP...
Equality comparisons and sameness - JavaScript
at place and propogates out into stoppingForce. Math.atan2 Math.ceil Math.pow Math.round In some cases,it's possible for a -0 to be introduced into an expression as a return value of these methods even when no -0 exists as one of the parameters. For example, using Math.pow to raise -Infinity to the power of any negative, odd exponent evaluates to -0. Refer to the documentation for the in
dividual methods. Math.floor Math.max Math.min Math.sin Math.sqrt Math.tan It's possible to get a -0 return value out of these methods in some cases where a -0 exists as one of the parameters. E.g., Math.min(-0, +0) evaluates to -0. Refer to the documentation for the in
dividual methods. ~ << >> Each of these operators uses the ToInt32 algorithm internally. Since there is only one rep...
Indexed collections - JavaScript
r the values of an array, processing each one in some way. The simplest way to do this is as follows: let colors = ['red', 'green', 'blue'] for (let i = 0; i < colors.length; i++) { console.log(colors[i]) } If you know that none of the elements in your array evaluate to false in a boolean context--if your array consists only of DOM nodes, for example--you can use a more efficient idiom: let
divs = document.getElementsByTagName('
div') for (let i = 0,
div;
div =
divs[i]; i++) { /* Process
div in some way */ } This avoids the overhead of checking the length of the array, and ensures that the
div variable is reassigned to the current item each time around the loop for added convenience. The forEach() method provides another way of iterating over an array: let colors = ['red', 'green',...
Keyed collections - JavaScript
whether to use a Map or an Object: Use maps over objects when keys are unknown until run time, and when all keys are the same type and all values are the same type. Use maps if there is a need to store primitive values as keys because object treats each key as a string whether it's a number value, boolean value or any other primitive value. Use objects when there is logic that operates on in
dividual elements. WeakMap object The WeakMap object is a collection of key/value pairs in which the keys are objects only and the values can be arbitrary values. The object references in the keys are held weakly, meaning that they are a target of garbage collection (GC) if there is no other reference to the object anymore. The WeakMap API is the same as the Map API. One difference to Map objects...
Regular expressions - JavaScript
Escaping If you need to use any of the special characters literally (actually searching for a "*", for instance), you must escape it by putting a backslash in front of it. For instance, to search for "a" followed by "*" followed by "b", you'd use /a\*b/ -- the backslash "escapes" the "*", making it literal instead of special. Similarly, if you're writing a regular expression l...
Working with objects - JavaScript
r by its property name or by its ordinal index. If you initially define a property by its name, you must always refer to it by its name, and if you initially define a property by an index, you must always refer to it by its index. This restriction applies when you create an object and its properties with a constructor function (as we did previously with the Car object type) and when you define in
dividual properties explicitly (for example, myCar.color = "red"). If you initially define an object property with an index, such as myCar[5] = "25 mpg", you subsequently refer to the property only as myCar[5]. The exception to this rule is array-like object reflected from HTML, such as the forms array-like object. You can always refer to objects in these array-like objects by either their ordinal n...
JavaScript Guide - JavaScript
The JavaScript Guide shows you how to use JavaScript and gives an overview of the language. If you need exhaustive information about a language feature, have a look at the JavaScript reference. ...
About the JavaScript reference - JavaScript
nd does not target a web browser environment. Where to find JavaScript information JavaScript documentation of core language features (pure ECMAScript, for the most part) includes the following: The JavaScript guide The JavaScript reference If you are new to JavaScript, start with the guide. Once you have a firm grasp of the fundamentals, you can use the reference to get more details on in
dividual objects and language constructs. Structure of the reference In the JavaScript reference you can find the following chapters: Standard built-in objects This chapter documents all the JavaScript standard built-in objects, along with their methods and properties. Statements and declarations JavaScript applications consist of statements with an appropriate syntax. A single statement may ...
The arguments object - JavaScript
[i]; } } return longest; } You can use arguments.length to count how many arguments the function was called with. If you instead want to count how many parameters a function is declared to accept, inspect that function's length property. Using typeof with arguments The typeof operator returns 'object' when used with arguments console.log(typeof arguments); // 'object' The type of in
dividual arguments can be determined by indexing arguments: console.log(typeof arguments[0]); // returns the type of the first argument Properties arguments.callee Reference to the currently executing function that the arguments belong to. Forbidden in strict mode. arguments.length The number of arguments that were passed to the function. arguments[@@iterator] Returns a new Array iterator o...
Array.prototype.reduceRight() - JavaScript
callback, x) => { setTimeout(callback, randInt(1000), x + 5); }; const mult3 = (callback, x) => { setTimeout(callback, randInt(1000), x * 3); }; const sub2 = (callback, x) => { setTimeout(callback, randInt(1000), x - 2); }; const split = (callback, x) => { setTimeout(callback, randInt(1000), x, x); }; const add = (callback, x, y) => { setTimeout(callback, randInt(1000), x + y); }; const
div4 = (callback, x) => { setTimeout(callback, randInt(1000), x / 4); }; const computation = waterfall(add5, mult3, sub2, split, add,
div4); computation(console.log, 5) // -> 14 // same as: const computation2 = (input, callback) => { const f6 = x=>
div4(callback, x); const f5 = (x, y) => add(f6, x, y); const f4 = x => split(f5, x); const f3 = x => sub2(f4, x); const f2 = x => mult3(f3,...
Date() constructor - JavaScript
ISO8601.) Note: Parsing of date strings with the Date constructor (and Date.parse(), which works the same way) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local. In
dividual date and time component values Given at least a year and month, this form of Date() returns a Date object whose component values (year, month, day, hour, minute, second, and millisecond) all come from the following parameters. Any missing fields are given the lowest possible value (1 for day and 0 for every other component). year Integer value representing the year. Valu...
Date.prototype.getTimezoneOffset() - JavaScript
e A number representing the time-zone offset, in minutes, from the date based on current host system settings to UTC. Description The time-zone offset is the difference, in minutes, from local time to UTC. Note that this means that the offset is positive if the local timezone is behind UTC, and negative if it is ahead. For example, for time zone UTC+10:00 (Australian Eastern Standard Time, Vla
divostok Time, Chamorro Standard Time), -600 will be returned. Current Locale UTC-8 UTC UTC+3 Return Value 480 0 -180 The time zone offset returned is the one that applies for the Date that it's called on. If the host system is configured for daylight saving, the offset will change depending on the date and time that the Date represents and that daylig...
Function.prototype.apply() - JavaScript
er <9--don't accept array-like objects, and will throw an exception. Examples Using apply to append an array to another You can use push to append an element to an array. And, because push accepts a variable number of arguments, you can also push multiple elements at once. But, if you pass an array to push, it will actually add that array as a single element, instead of adding the elements in
dividually. So you end up with an array inside an array. What if that is not what you want? concat does have the desired behaviour in this case, but it does not append to the existing array--it instead creates and returns a new array. But you wanted to append to the existing array... So what now? Write a loop? Surely not? apply to the rescue! const array = ['a', 'b']; const elements = [0, 1, 2]; ...
Function.prototype.call() - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax func.call([thisArg[, arg1, arg2, ...argN]]) Parameters thisArg Optional The value to use as this when calling func. Caution: In certain cases, thisArg may not be the actual value seen by the method. If the method is a function in non-strict mode, null and undefined will be replaced with the global object, and primitive values will be converted to objects. ...
Intl.NumberFormat() constructor - JavaScript
g algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit". For information about this option, see the Intl page. notation The formatting that should be displayed for the number, the defaults is "standard" "standard" plain number formatting "scientific" return the order-of-magnitude for formatted number. "engineering" return the exponent of ten when
divisible by three "compact" string representing exponent, defaults is using the "short" form. numberingSystem Numbering System. Possible values include: "arab", "arabext", " bali", "beng", "deva", "fullwide", " gujr", "guru", "hanidec", "khmr", " knda", "laoo", "latn", "limb", "mlym", " mong", "mymr", "orya", "tamldec", " telu", "thai", "tibt". signDisplay When to display the sign f...
JSON.parse() - JavaScript
parse('"foo"'); // "foo" JSON.parse('[1, 5, "false"]'); // [1, 5, "false"] JSON.parse('null'); // null Using the reviver parameter If a reviver is specified, the value computed by parsing is transformed before being returned. Specifically, the computed value and all its properties (beginning with the most nested properties and proceeding to the original value itself) are in
dividually run through the reviver. Then it is called, with the object containing the property being processed as this, and with the property name as a string, and the property value as arguments. If the reviver function returns undefined (or returns no value, for example, if execution falls off the end of the function), the property is deleted from the object. Otherwise, the property is redefined to...
Number.MIN_VALUE - JavaScript
the number closest to 0, not the most negative number, that JavaScript can represent. MIN_VALUE has a value of approximately 5e-324. Values smaller than MIN_VALUE ("underflow values") are converted to 0. Because MIN_VALUE is a static property of Number, you always use it as Number.MIN_VALUE, rather than as a property of a Number object you created. Examples Using MIN_VALUE The following code
divides two numeric values. If the result is greater than or equal to MIN_VALUE, the func1 function is called; otherwise, the func2 function is called. if (num1 / num2 >= Number.MIN_VALUE) { func1(); } else { func2(); } Specifications Specification ECMAScript (ECMA-262)The definition of 'Number.MIN_VALUE' in that specification. ...
Promise.any() - JavaScript
Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfils, returns a single promise that resolves with the value from that promise. If no promises in the iterable fulfil (if all of the given promises are rejected), then the returned promise is rejected with an AggregateError, a new subclass of Error that groups together in
dividual errors. Essentially, this method is the opposite of Promise.all(). Warning! The Promise.any() method is experimental and not fully supported by all browsers and platforms. It is currently in stage 4 of the TC39 process. Syntax Promise.any(iterable); Parameters iterable An iterable object, such as an Array. Return value An already resolved Promise if the iterable passed is empty. An asynchronousl...
RegExp.prototype.dotAll - JavaScript
Property attributes of RegExp.prototype.dotAll Writable no Enumerable no Configurable yes Description The value of dotAll is a Boolean and true if the "s" flag was used; otherwise, false. ...
RegExp.prototype.global - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
RegExp.prototype.ignoreCase - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
RegExp.input ($_) - JavaScript
Instead, you always use it as RegExp.input or RegExp.$_. The value of the input property is modified whenever the searched string on the regular expression is changed and that string is matching. ...
RegExp.lastMatch ($&) - JavaScript
Instead, you always use it as RegExp.lastMatch or RegExp['$&']. The value of the lastMatch property is read-only and modified whenever a successful match is made. ...
RegExp.lastParen ($+) - JavaScript
Instead, you always use it as RegExp.lastParen or RegExp['$+']. The value of the lastParen property is read-only and modified whenever a successful match is made. ...
RegExp.leftContext ($`) - JavaScript
Instead, you always use it as RegExp.leftContext or RegExp['$`']. The value of the leftContext property is read-only and modified whenever a successful match is made. ...
RegExp.prototype.multiline - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
RegExp.$1-$9 - JavaScript
Instead, you always use them as RegExp.$1, ..., RegExp.$9. The values of these properties are read-only and modified whenever successful matches are made. ...
RegExp.rightContext ($') - JavaScript
Instead, you always use it as RegExp.rightContext or RegExp["$'"]. The value of the rightContext property is read-only and modified whenever a successful match is made. ...
RegExp.prototype.sticky - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
RegExp.prototype.unicode - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
String.prototype.charCodeAt() - JavaScript
of the ASCII character encoding. (For information on Unicode, see the JavaScript Guide.) Note: charCodeAt() will always return a value that is less than 65536. This is because the higher code points are represented by a pair of (lower valued) "surrogate" pseudo-characters which are used to comprise the real character. Because of this, in order to examine (or reproduce) the full character for in
dividual character values of 65536 or greater, for such characters, it is necessary to retrieve not only charCodeAt(i), but also charCodeAt(i+1) (as if manipulating a string with two letters), or to use codePointAt(i) instead. See examples 2 and 3 (below). charCodeAt() returns NaN if the given index is less than 0, or if it is equal to or greater than the length of the string. Backward compatibili...
String.prototype.substring() - JavaScript
NaN arguments as 0, but when it is given negative values it counts backwards from the end of the string to find the indexes. console.log(text.slice(-5, 2)) // => "" console.log(text.slice(-5, -2)) // => "zil" See the slice() page for more examples with negative numbers. Replacing a substring within a string The following example replaces a substring within a string. It will replace both in
dividual characters and substrings. The function call at the end of the example changes the string Brave New World to Brave New Web. // Replaces oldS with newS in the string fullS function replaceString(oldS, newS, fullS) { for (let i = 0; i < fullS.length; ++i) { if (fullS.substring(i, i + oldS.length) == oldS) { fullS = fullS.substring(0, i) + newS + fullS.substring(i + oldS.length, fu...
isNaN() - JavaScript
= NaN evaluate to false. Hence, the necessity of an isNaN function. Origin of NaN values NaN values are generated when arithmetic operations result in undefined or unrepresentable values. Such values do not necessarily represent overflow conditions. A NaN also results from attempted coercion to numeric values of non-numeric values for which no primitive numeric value is available. For example,
dividing zero by zero results in a NaN -- but
dividing other numbers by zero does not. Confusing special-case behavior Since the very earliest versions of the isNaN function specification, its behavior for non-numeric arguments has been confusing. When the argument to the isNaN function is not of type Number, the value is first coerced to a Number. The resulting value is then tested to determine wh...
Grouping operator ( ) - JavaScript
st. Syntax ( ) Description The grouping operator consists of a pair of parentheses around an expression or sub-expression to override the normal operator precedence so that expressions with lower precedence can be evaluated before an expression with higher priority. As it sounds, it groups what's inside of the parentheses. Examples Using the grouping operator Overriding multiplication and
division first, then addition and subtraction to evaluate addition first. var a = 1; var b = 2; var c = 3; // default precedence a + b * c // 7 // evaluated by default like this a + (b * c) // 7 // now overriding precedence // addition before multiplication (a + b) * c // 9 // which is equivalent to a * c + b * c // 9 Specifications Specification ECMAScript (ECMA-262)...
Remainder (%) - JavaScript
The remainder operator (%) returns the remainder left over when one operand is
divided by a second operand. It always takes the sign of the
dividend. The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. Syntax Operator: var1 % var2 Examples Remainder with positive
dividend 12 % 5 // 2 1 % -2 // 1 1 % 2 // 1 2 % 3 // 2 5.5 % 2 // 1.5 Remainder with negative
dividend -12 % 5 // -2 -1 % 2 // -1 -4 % 2 // -0 Remainder with NaN NaN % 2 // NaN Specifications Specification ECMAScript (ECMA-262)The definition of 'Remainder operator' in that specification. ...
Remainder assignment (%=) - JavaScript
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request. ...
import - JavaScript
quoted Strings are allowed. name Name of the module object that will be used as a kind of namespace when referring to the imports. exportN Name of the exports to be imported. aliasN Names that will refer to the named imports. Description The name parameter is the name of the "module object" which will be used as a kind of namespace to refer to the exports. The export parameters specify in
dividual named exports, while the import * as name syntax imports all of them. Below are examples to clarify the syntax. Import an entire module's contents This inserts myModule into the current scope, containing all the exports from the module in the file located in /modules/my-module.js. import * as myModule from '/modules/my-module.js'; Here, accessing the exports means using the module name ...
Transitioning to strict mode - JavaScript
ng IE10). While making web browsers interpret code as strict is easy (just add 'use strict'; at the top of your source code), transitioning an existing code base to strict mode requires a bit more work. This article aims at providing guidance for developers. Gradual transition Strict mode has been designed so that the transition to it can be made gradually. It is possible to change each file in
dividually and even to transition code to strict mode down to the function granularity. Differences from non-strict to strict Syntax errors When adding 'use strict';, the following cases will throw a SyntaxError before the script is executing: Octal syntax var n = 023; with statement Using delete on a variable name delete myVariable; Using eval or arguments as variable or function argument n...
Strict mode - JavaScript
ript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode. Prohibits some syntax likely to be defined in future versions of ECMAScript. See transitioning to strict mode, if you want to change your code to work in the restricted variant of JavaScript. Invoking strict mode Strict mode applies to entire scripts or to in
dividual functions. It doesn't apply to block statements enclosed in {} braces; attempting to apply it to such contexts does nothing. eval code, Function code, event handler attributes, strings passed to WindowTimers.setTimeout(), and related functions are entire scripts, and invoking strict mode in them works as expected. Strict mode for scripts To invoke strict mode for an entire script, put the ...
MathML attribute reference - MathML
Unimplemented linebreak <mo>, <mspace> Unimplemented linebreakmultchar <mo>, <mspace> Unimplemented linebreakstyle <mo>, <mspace> Unimplemented lineleading <mo>, <mspace> linethickness <mfrac> The thickness of the horizontal fraction line. Unimplemented location <mscarries> Unimplemented long
divstyle <mlong
div> Controls the style of the long
division layout. lspace <mo>, <mpadded> The amount of space before the operator (see length for values and units). lquote <ms> The opening quote character (depends on dir) to enclose the content. The default value is """. mathbackground All The background color. You can use #rgb, #rrggbb and HTM...
<menclose> - MathML
HTML color names. mathcolor The text color. You can use #rgb, #rrggbb and HTML color names. notation A list of notations, separated by white space, to apply to the child elements. The symbols are each drawn as if the others are not present, and therefore may overlap. Possible values are: Value Sample Rendering Rendering in your browser Description long
div (default) a2 + b2 long
division symbol actuarial a2 + b2 actuarial symbol radical a2 + b2 square root symbol. Deprecated. Use <msqrt> instead. box a2 + b2 box roundedbox a2 + b2 rounded box circle a2 + b2 circle left ...
<merror> - MathML
h has nothing to do with <merror>. Attributes class, id, style Provided for use with stylesheets. href Used to set a hyperlink to a specified URI. mathbackground The background color. You can use #rgb, #rrggbb and HTML color names. mathcolor The text color and also the fraction line color. You can use #rgb, #rrggbb and HTML color names. Examples <math> <merror> <mrow> <mtext>
Division by zero: </mtext> <mfrac> <mn> 1 </mn> <mn> 0 </mn> </mfrac> </mrow> </merror> </math> Specifications Specification Status Comment MathML 3.0The definition of 'merror' in that specification. Recommendation Current specification MathML 2.0The definition of 'merror' in that specification. Recommendation Initial specific...
<mfenced> - MathML
URI. mathbackground The background color. You can use #rgb, #rrggbb and HTML color names. mathcolor The text color and also the fraction line color. You can use #rgb, #rrggbb and HTML color names. open A string for the opening delimiter. The default value is "(" and any white space is trimmed. separators A sequence of zero or more characters to be used for different separators, optionally
divided by white space, which is ignored. The default value is ",". By specifying more than one character, it is possible to set different separators for each argument in the expression. If there are too many separators, all excess is ignored. If there are too few separators in the expression, the last specified separator is repeated. Examples The last separator is repeated (,) Sample rendering: ...
The "codecs" parameter in common media types - Web media technologies
slient Bit-Sliced Arithmetic Coding) Mobile Internetworking 23 ER AAC LD (Error Resilient AAC Low-Delay; used for two-way communication) LD, Mobile Internetworking 24 ER CELP (Error Resilient Code-Excited Linear Prediction) HQ, LD 25 ER HVXC (Error Resilient Harmonic Vector Excitation Coding) LD 26 ER HILN (Error Resilient Harmonic and In
dividual Line plus Noise) 27 ER Parametric (Error Resilient Parametric) 28 SSC (Sinusoidal Coding) 29 PS (Parametric Stereo) HE-AAC v2 30 MPEG Surround 31 Escape 32 MPEG-1 Layer-1 33 MPEG-1 Layer-2 (MP2) 34 MPEG-1 Layer-3 (MP3) 35 DST (Direct Stream Transfer) ...
Using images in HTML - Web media technologies
e replaced element's object will show the element's background. background-image The background-image CSS property sets one or more background images for an element. Guides These articles provide guidance on selecting and configuring image types. Image file type and format guide A guide to the various image file types commonly supported by web browsers including details about their in
dividual use cases, capabilities, and compatibility factors. Additionally, this article provides guidance for selecting the best image file type for a given situation. Mapping the width and height attributes of media container elements to their aspect-ratio This changes how browsers load images so their aspect ratios are calculated by the browser early on and can later be used to correct the displa...
CSS and JavaScript animation performance - Web Performance
l, I promise! button to enter the config screen. In the search bar, search for the layers.acceleration.draw-fps preference. Double-click the entry to set the value to true. Now you will be able to see three little purple boxes at the upper left corner of the Firefox window. The first box represents FPS. Running the performance test Initially in the test seen below, a total of 1000 <
div> elements are transformed by CSS animation. The animation can be switched to requestAnimationFrame() by clicking the toggle button. Try running them both now, comparing the FPS for each (the first purple box.) You should see that the performance of CSS animations and requestAnimationFrame() are very close. Off main thread animation Even given the test results above, we'd argue that CSS ani...
Critical rendering path - Web Performance
Nodes are connected into a DOM tree based on token hierarchy. If another set of startTag and endTag tokens come between a set of startTag and endTags, you have a node inside a node, which is how we define the hierarchy of the DOM tree. The greater the number of nodes, the longer the following events in the critical rendering path will take. Measure! A few extra nodes won't make a difference, but
divitis can lead to jank. CSS Object Model The DOM contains all the content of the page. The CSSOM contains all the styles of the page; information on how to style that DOM. CSSOM is similar to the DOM, but different. While the DOM construction is incremental, CSSOM is not. CSS is render blocking: the browser blocks page rendering until it receives and processes all of the CSS. CSS is render blocki...
Recommended Web Performance Timings: How long is too long? - Web Performance
ing goal Browsers are single threaded (though background threads are supported for web workers). This means that user interaction, painting, and script execution are all on the same thread. If the thread is busy doing complex JavaScript execution, the main thread will not be available to react to user input, such as pressing a button. For this reason, script execution should be limited in scope,
divided into chunks of code that can be executed in 50ms or less. This makes the thread available for user interactions. Animation goal For scrolling and other animations to look smooth and feel responsive, the content repaints should occur at 60 frames per second (60fps), which is once every 16.7ms. The 16.7 milliseconds includes scripting, reflow, and repaint. Realize a document takes about 6ms t...
Web Performance
dition to the front end components of HTML, CSS, JavaScript, and media files, there are features that can make applications slower and features that can make applications subjectively and objectively faster. There are many APIs, developer tools, best practices, and bad practices relating to web performance. Here we'll introduce many of these features ad the basic level and provide links to deeper
dives to improve performance for each topic. HTML performance features Some attributes and the source order of your mark-up can impact the performance or your website. By minimizing the number of DOM nodes, making sure the best order and attributes are used for including content such as styles, scripts, media, and third-party scripts, you can drastically improve the user experience. This article lo...
begin - SVG: Scalable Vector Graphics
The begin attribute defines when an animation should begin or when an element should be discarded. The attribute value is a semicolon separated list of values. The interpretation of a list of start times is detailed in the SMIL specification in "Evaluation of begin and end time lists". Each in
dividual value can be one of the following : <offset-value>, <syncbase-value>, <event-value>, <repeat-value>, <accessKey-value>, <wallclock-sync-value> or the keyword indefinite. Six elements are using this attribute: <animate>, <animateColor>, <animateMotion>, <animateTransform>, <discard>, and <set> animate, animateColor, animateMotion, animateTransform, set For <animate>, <animateColor>, <animateMotion>, <animateTransform>, and <set>, begin defines when the element should begin, i.e. become activ...
bias - SVG: Scalable Vector Graphics
This allows representation of values that would otherwise be clamped to 0 or 1. Usage notes Value <number> Default value 0 Animatable Yes One application of bias is when it is desirable to have 0.5 gray value be the zero response of the filter. ...
href - SVG: Scalable Vector Graphics
ement can be used as syncbase in an identical fashion to when the URL refers to a valid target element. If the href attribute or the deprecated xlink:href attribute is not provided, then the target element will be the immediate parent element of the current animation element. If both xlink:href and href are specified, the value of the latter attribute is used. Refer to the descriptions of the in
dividual animation elements for any restrictions on what types of elements can be targets of particular types of animations. Except for any SVG-specific rules explicitly mentioned in this specification, the normative definition for this attribute is the SMIL Animation specification. In particular, see SMIL Animation: Specifying the animation target. Value <url> Default value ...
requiredExtensions - SVG: Scalable Vector Graphics
er agent that go beyond the feature set defined in this specification. Each extension is identified by an URL reference. Usage notes Value <list-of-extensions> Default value None Animatable No <list-of-extensions> The value is a list of references (IRI references in SVG 1, URL References in SVG 2) which identify the required extensions, with the in
dividual values separated by white space. Determines whether all of the named extensions are supported by the user agent. If all of the given extensions are supported, then the attribute evaluates to true; otherwise, the current element and its children are skipped and thus will not be rendered. Note: If a given extension reference contains white space within itself, that white space must be escape...
requiredFeatures - SVG: Scalable Vector Graphics
It determines whether or not all of the named features are supported by the browser; if all of them are supported, the attribute evaluates to true end the element is rendered; otherwise, the attribute evaluates to false and the current element and its children are skipped and thus will not be rendered. This provides a way to design SVG that gracefully falls back when features aren't available. If the attribute is not present, then its implicit evaluated value is true. If a null string or empty string value is given to attribute requiredFeatures, the attribute is evaluate to false. ...
text-anchor - SVG: Scalable Vector Graphics
align (start-, middle- or end-alignment) a string of pre-formatted text or auto-wrapped text where the wrapping area is determined from the inline-size property relative to a given point. It is not applicable to other types of auto-wrapped text. For those cases you should use text-align. For multi-line text, the alignment takes place for each line. The text-anchor attribute is applied to each in
dividual text chunk within a given <text> element. Each text chunk has an initial current text position, which represents the point in the user coordinate system resulting from (depending on context) application of the x and y attributes on the <text> element, any x or y attribute values on a <tspan>, <tref> or <altGlyph> element assigned explicitly to the first rendered character in a text chunk, or...
text-decoration - SVG: Scalable Vector Graphics
Specifications Specification Status Comment CSS Text Decoration Module Level 3The definition of 'text-decoration' in that specification. Candidate Recommendation Defines the property as a shorthand for text-decoration-line, text-d...
u1 - SVG: Scalable Vector Graphics
If a given Unicode character within the set has multiple corresponding <glyph> elements (i.e., there are multiple <glyph> elements with the same unicode attribute value but different glyph-name values), then all such glyphs are included in the set. ...
u2 - SVG: Scalable Vector Graphics
If a given Unicode character within the set has multiple corresponding <glyph> elements (i.e., there are multiple <glyph> elements with the same unicode attribute value but different glyph-name values), then all such glyphs are included in the set. ...
xlink:href - SVG: Scalable Vector Graphics
which therefore will be modified over time. The target element must be part of the current SVG document fragment. The value must point to exactly one target element which is capable of being the target of the given animation. If the xlink:href attribute is not provided, the target element will be the immediate parent element of the current animation element. Refer to the descriptions of the in
dividual animation elements for any restrictions on what types of elements can be targets of particular types of animations. Value <iri> Default value None Animatable No color-profile For <color-profile>, xlink:href defines the location of an ICC profile resource. Value <iri> Default value None Animatable No curs...
SVG Attribute reference - SVG: Scalable Vector Graphics
e attributeType autoReverse azimuth B baseFrequency baseline-shift baseProfile bbox begin bias by C calcMode cap-height class clip clipPathUnits clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering contentScriptType contentStyleType cursor cx cy D d decelerate descent diffuseConstant direction display
divisor dominant-baseline dur dx dy E edgeMode elevation enable-background end exponent externalResourcesRequired F fill fill-opacity fill-rule filter filterRes filterUnits flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight format from fr fx fy G g1 g2 glyph-name glyph-orientation-horizontal ...
<text> - SVG: Scalable Vector Graphics
alue type: <length>|<percentage> ; Default value: 0; Animatable: yes dx Shifts the text position horizontally from a previous text element. Value type: <length>|<percentage> ; Default value: none; Animatable: yes dy Shifts the text position vertically from a previous text element. Value type: <length>|<percentage> ; Default value: none; Animatable: yes rotate Rotates orientation of each in
dividual glyph. Can rotate glyphs in
dividually. Value type: <list-of-number> ; Default value: none; Animatable: yes lengthAdjust How the text is stretched or compressed to fit the width defined by the textLength attribute. Value type: spacing|spacingAndGlyphs; Default value: spacing; Animatable: yes textLength A width that the text should be scaled to fit. Value type: <length>|<percentage> ; D...
<textPath> - SVG: Scalable Vector Graphics
ic shape on which to render the text. If the path attribute is set, href has no effect. Value type: <URL> ; Default value: none; Animatable: yes lengthAdjust Where length adjustment should be applied to the text: the space between glyphs, or both the space and the glyphs themselves. Value type: spacing|spacingAndGlyphs; Default value: spacing; Animatable: yes method Which method to render in
dividual glyphs along the path. Value type: align|stretch ; Default value: align; Animatable: yes path The path on which the text should be rendered. Value type: <path_data> ; Default value: none; Animatable: yes side Which side of the path the text should be rendered. Value type: left|right ; Default value: left; Animatable: yes spacing How space between glyphs should be handled. Value typ...
<tspan> - SVG: Scalable Vector Graphics
e type: <length>|<percentage> ; Default value: none; Animatable: yes dx Shifts the text position horizontally from a previous text element. Value type: <length>|<percentage> ; Default value: none; Animatable: yes dy Shifts the text position vertically from a previous text element. Value type: <length>|<percentage> ; Default value: none; Animatable: yes rotate Rotates orientation of each in
dividual glyph. Can rotate glyphs in
dividually. Value type: <list-of-number> ; Default value: none; Animatable: yes lengthAdjust How the text is stretched or compressed to fit the width defined by the textLength attribute. Value type: spacing|spacingAndGlyphs; Default value: spacing; Animatable: yes textLength A width that the text should be scaled to fit. Value type: <length>|<percentage> ; D...
Getting started - SVG: Scalable Vector Graphics
Take a look at the following code. <svg version="1.1" baseProfile="full" width="300" height="200" xmlns="http://www.w3.org/2000/svg"> <rect width="100%" height="100%" fill="red" /> <circle cx="150" cy="100" r="80" fill="green" /> <text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text> </svg> Copy the code and paste it in a file demo1.svg. Then open the file in Firefox. It will render as shown in the following screenshot. ...
SVG and CSS - SVG: Scalable Vector Graphics
rties and values. Some of them are similar to CSS properties for HTML. Challenge Change the stylesheet so that the inner petals all turn pink when the mouse pointer is over any one of them, without changing the way the outer petals work. See a solution to this challenge. Simplified structure The SVG structure shown above could be written much more concise by referencing the in
dividual parts of the flower via <use> elements. This behavior is standardized, though only a few browsers support the :hover pseudo-class and other more complex CSS selectors on elements referenced via <use> elements, at the moment. There is some discussion about what rules apply to such referenced elements. See below how the structure then looks like. <svg width="600px" height="600px" viewBox="-3...
Using shadow DOM - Web Components
host: The regular DOM node that the shadow DOM is attached to. Shadow tree: The DOM tree inside the shadow DOM. Shadow boundary: the place where the shadow DOM ends, and the regular DOM begins. Shadow root: The root node of the shadow tree. You can affect the nodes in the shadow DOM in exactly the same way as non-shadow nodes -- for example appending children or setting attributes, styling in
dividual nodes using element.style.foo, or adding style to the entire shadow DOM tree inside a <style> element. The difference is that none of the code inside a shadow DOM can affect anything outside it, allowing for handy encapsulation. Note that the shadow DOM is not a new thing by any means -- browsers have used it for a long time to encapsulate the inner structure of an element. Think for exampl...
id - XPath
The returned node set is the nodes corresponding to those ids. ...
position - XPath
l to the context position from the expression evaluation context. Notes Note that a node's position in a context is not zero-based. The first node has a position of 1. The context is determined by the rest of the path. <xsl:template match="//a[position() = 5]"> <!-- this template matches the fifth a element anywhere in the document. --> </xsl:template> <xsl:template match="//
div[@class='foo']/bar[position() = 1]"> <!-- this template matches the first bar element that is a child of a
div element with a class attribute equal to "foo" --> </xsl:template> Defined XPath 1.0 4.1 Gecko support Supported. ...
Transforming XML with XSLT - XSLT: Extensible Stylesheet Language Transformations
XSLT/XPath Reference: XSLT elements, EXSLT functions, XPath functions, XPath axes An Overview The separation of content and presentation is a key design feature of XML. The structure of an XML document is designed to reflect and clarify important relationships among the in
dividual aspects of the content itself, unhindered by a need to provide any indication about how this data should eventually be presented. This intelligent structuring is particularly important as more and more data transfers are automated and take place between highly heterogeneous machines linked by a network. Yet eventually much of the content stored in XML documents will need to be presented to human readers. Because a browser provides a familiar and highly flexible interface, it is an ideal mechanism fo...
Web technology for developers
ps for mobile, desktop, and Firefox OS. Code snippets This is a quick list of useful code snippets (small code samples) available for developers of extensions for the various Mozilla applications. Many of these samples can also be used in XULRunner applications, as well as in actual Mozilla code itself. View All... Web technology references Web APIs Reference material for each of the in
dividual APIs that comprise the Web's powerful scriptability, including the DOM and all of the related APIs and interfaces you can use to build Web content and apps. HTML HyperText Markup Language is the language used to describe and define the content of a Web page. CSS Cascading Style Sheets are used to describe the appearance of Web content. SVG Scalable Vector Graphics let you describe imag...