![Javascript](assets/m9_sidebar.jpg)
Javascript
Structure, format, and behavior are the three arenas that define web design. Keeping these three arenas separate makes web pages manageable, flexible, and less prone to breakage.
The languages that define these areas -- HTML, CSS, and Javascript -- all work in concert with each other, yet retain their unique identities. Javascript accesses both HTML and CSS through the DOM (Document Object Model).
The DOM is the abstract representation of a web page. It is how the computer understands a web page. It grants both humans and computers an agreed-upon picture of all the parts of a web page and how to access them.
The DOM stores a list of every element on the page. There is a list of all the tags, all the attributes, all the images, everything. We have been using id attributes to grab specific elements on a page and act on them. In some cases, we changed their appearance by adjusting the CSS that defines their look. In other cases, we made elements active by telling them to "listen" for a particular event -- most notably mouse events, when they were clicked.
Color Mixing
Color on the web is declared in RGB -- but what exactly is RGB, and how does it work?
A monitor is a light source. When you design a web page, you are asking your audience to stare directly into a light source. The human eye, however, was designed to perceive reflected light.
Reflected light is created by light bouncing off of a surface. Different pigments on the surface absorb certain wavelengths, subtracting them from the reflected light. The wavelengths that remain are perceived by our eye as color. Reflected light is a subtractive system. The more light that is absorbed, the darker the color. Its primary colors are red, yellow, and blue. Its secondary colors, created when two primaries are mixed, are orange, green, and purple. Its tertiary color is middle gray, or mud.
In an additive system, wavelengths of light are perceived by the eye as color. Light can be bent or filtered to isolate and mix particular wavelengths. This sounds counterintuitive, but the more light, the lighter the color. Less light creates darker colors in an additive system. The primary colors of the additive system are red, green, and blue. The secondary colors are yellow, magenta, and cyan. Its tertiary color is the mix of all light waves -- white. The absence of color is black.