Tuesday, August 14, 2018

What's the difference between ... and ... in HTML and CSS?

1. margin and padding  
    margin: is the space between the content and the border  
    padding: is the space outside the border

2. selector:nth-of-type(n) and selector:nth-child(n)
    selector:nth-of-type(n): selector matches every element that is the nth child, of a particular                                                 type, of its parent
    selector:nth-child(n): selector to select the element that is the nth child, regardless of type, of                                           its parent

3. .class .class ,  .class > .class and .class.class
    .class .class : (have space between two classes)will target all elements with the class .class which derive from any element which has the class '.class'
    .class > .class : will only target direct children of elements with the class .class
    .class1.class2: (doesn't have space between two classes) means a div or an element having both classes together

4. 
         div, p- : Selects all elements and all elements
         div p- : Selects all elements that are anywhere inside a element
         div > p- : Selects all elements where the immediate parent is a element
         div + p- : Selects all elements that are placed immediately after a element
         div ~ p- : Selects all elements that are anywhere preceded by a element

5. .container div and div.container
    .container div: Select any div element that is a child of any element with a class name of  container
    div.container: Select any div element that has a class name of "container" 

6. visibility:hidden and display:none 
    visibility:hidden,  simply hides the element, while it will still take up space and affect the layout of the document. 
    display:none,  also hides the element, but will not take up space and the page will appear as if the element is not present.   

7.  Select every  element whose href attribute value begins with “https”: a[href^="https"]
    Select every  element whose href attribute value ends with “.pdf”: a[href$=".pdf"]
    Select every  element whose href attribute value contains the substring “css”: a[href*="css"]