reading-notes

this repo will contain my reading during the course .

View on GitHub

class-03

Lists

There are three types of HTML lists:

  1. The ordered list is created with the ol element.
    • li Each item in the list is placed between an opening li tag and a closing li tag. (The listands for list item.)
  2. Unordered Lists :The unordered list is created with the ul element.
    • li Each item in the list is placed between an opening li tag and a closing li tag. (The listands for list item.)

  1. Definition Lists:The definition list is created with the dl element and usually consists of a series of terms and their definitions.
    • Inside the dl element you will usually see pairs of dt and dd elements. dt This is used to contain the term being defined (the definition term) dd This is used to contain the definition.

Box Dimensions

width, height By default a box is sized just big enough to hold its contents. To set your own dimensions for a box you can use the height and width properties. The most popular ways to specify the size of a box are to use pixels, percentages, or ems. Traditionally, pixels have been the most popular method because they allow designers to accurately control their size

White space & Vertical Margin

The padding and margin properties are very helpful in adding space between various items on the page.

Shorthand

The border property allows you to specify the width, style and color of a border in one property (and the values should be coded in that specific order).

Padding The padding property allows you to specify how much space should appear between the content of an element and its border. The value of this property is most often specified in pixels (although it is also possible to use percentages or ems). If a percentage is used, the padding is a percentage of the browser window (or of the containing box if it is inside another box)

Article The margin property controls the gap between boxes. Its value is commonly given in pixels, although you may also use percentages or ems. If one box sits on top of another, margins are collapsed , which means the larger of the two margins will be used and the smaller will be disregarded.

Centering Content If you want to center a box on the page (or center it inside the element that it sits in), you can set the left-margin and right-margin to auto. In order to center a box on the page, you need to set a width for the box (otherwise it will take up the full width of the page).

Change Inline/Block The display property allows you to turn an inline element into a block-level element or vice versa, and can also be used to hide an element from the page. The values this property can take are: inline This causes a block-level element to act like an inline element. block This causes an inline element to act like a block-level element. inline-block This causes a block-level element to flow like an inline element, while retaining other features of a block-level element. none This hides an element from the page. In this case, the element acts as though it is not on the page at all (although a user could still see the content of the box if they used the view source option in their browser). If you use this property, it is important to note that inline boxes are not supposed to create block-level elements.

Hiding Boxes The visibility property allows you to hide boxes from users but It leaves a space where the element would have been. This property can take two values: hidden This hides the element. visible This shows the element. If the visibility of an element is set to hidden, a blank space will appear in its place.

CSS3: Border Images

The border-image property applies an image to the border of any box. It takes a background image and slices it into nine pieces.

JavaScript

Arrays

You create an array and give it a name just like you would any other variable (using the var keyword followed by the name of the array).

if … else statements

if … else statements allow you to run one set of code if a condition is true, and another if it is false. switch statements allow you to compare a value against possible outcomes (and also provides a default option if none match).

SWITCH STATEMENTS

A switch statement starts with a variable called the switch value. Each case indicates a possible value for this variable and the code that should run if the variable matches that value.

TYPE COERCION & WEAK TYPING If you use a data type JavaScript did not expect, it tries to make sense of the operation rather than report an error. JavaScript can convert data types behind the scenes to complete an operation. This is known as type coercion.

TRUTHY & FALSY VALUES Due to type coercion, every value in JavaScript can be treated as if it were true or false; and this has some interesting side effects CHECKING EQUALITY & EXISTENCE Because the presence of an object or array can be considered truthy, it is often used to check for the existence of an element within a page. SHORT CIRCUIT VALUES Logical operators are processed left to right. They short-circuit (stop) as soon as they have a result - but they return the value that stopped the processing (not necessarily true or false).

LOOPS

Loops are used in JavaScript to perform repeated tasks based on a condition. Conditions typically return true or false when analysed. A loop will continue running until the defined condition returns false.

The three most common types of loops are:

1- For

If you need to run code a speciific number of times , use a for loop. in a for loop , the condition is usually a counter which is used to tell how many times the loop should run

INITIALIZATION , CONDITION, UPDATE

for loop explain:

2- while

If you do not know how many times the code should run , you can use a while loop. Here the condition can be something other than counter, and the code will continue to loop foras long as the condition is true

using while loops while loop explain

3- do while

The do…while loop is very similar to the while loop, but hasone key difference: itwill always run the statements inside the curly braces at least once, even if the condition evaluates to false.

do while loop explain

Learn more about loops