Final P2 Flashcards
form tag itself has two very important attributes.
- Action which specifies where the form should be sent
2. Method which specifies the HTTP method to be used in the HTTP request sent when the form is submitted
percent-encoding or URL encoding
certain special characters that have a specific meaning within URLs are encoded with other characters
T or F: A GET request will send the same data as POST. But instead of sending it as part of the URL, it is sent in the body of the request.
False: A POST request will send the same data as GET. But instead of sending it as part of the URL, it is sent in the body of the request.
T or F: Unless we use the HTTPS protocol, which encrypts the HTTP communication, an intruder can see the body of a POST request.
True
T or F: even when using HTTPS protocol, we must not use GET for submitting sensitive data, such as passwords. Many web servers log the URL of HTTP requests, and putting sensitive data in the URL with GET requests can result in that data being saved in log files.
True
T or F: Another limitation of POST is that browsers often place a limitation on the length of the query string, whereas no such limits are placed on the body length.
False: GET
Processing a submitted form in ___ requires adding a route for the URL and HTTP method specified in the form. ___ then provides the data submitted in the form as a JSON object to our route handler function
Express
GET route handler example
app.get(“/review”, (req, res) => {
console.log(req.query);
res.send(req.query);
});
POST route handler example
app.post(“/review”, (req, res) => {
console.log(req.body);
res.send(req.body);
});
app.use(express.urlencoded({
extended: true
}));
T or F: CSS is a language for describing the presentation of documents. It allows us to specify rules using which we can selectively style HTML elements. Typically we write these CSS rules into stylesheets which are files containing CSS rules.
True
CSS selector
selects the HTML element to which the rule applies
CSS format
h1 {
color: red;
font-size: 25pt;
}
CSS: The universal selector *
matches all elements
CSS: The ___selector matches elements based on the element ___
type
CSS: The ___ selector selects the single element with a matching __ and is of the form #id
ID
CSS: The ___ selector selects all elements in which the attribute class has that value
class
T or F: IDs are good for anchoring and specifying unique blocks, whereas classes are more about design properties that get used again and again.
True
CSS: Is it possible to specify rules that apply to multiple selectors.?
Yes, This is done by specifying multiple selectors separated by commas.
CSS: We can specify selectors that select elements based on their location in the document
combinator selector
CSS: We can combine selectors to form more complex selectors. A common use is combining a type and a class to specify a selector that applies to tags with that type but only if they have that particular class. The syntax for this is tag.class.
Complex Selector
CSS also supports selectors that are based on the state of an element
CSS Pseudo Selectors
selector:pseudo-class {
property: value;
}
T or F: Common use cases for CSS pseudo-classes are changing the style of an element when the mouse hovers over it, and displaying visited links differently from links that have not been visited.
True
CSS: Rule Precedence
- Later rules overrule earlier rules.
2. Rules with a more specific selector take precedence over those with more general selectors.
Colors in CSS are represented in three ways.
- Hex (hexadecimal) values in the form of #RRGGBB.
- Decimal values in the form of rbg(x, y, z)
- Named colors