Search This Blog

Q6-Q10

Q6. What are pseudo class in css?
Q7. What are pseudo elements in css?
Q8. What is Doctype in HTML5? What is the requirement of using it?
Q9. Can we have multiple headers and footers in our single html page?
Q10. What is Local Storage in HTML5?


----------------------------------------------------------------------------------------------------------------------
Q6. What are pseudo class in css?

Answer:
A pseudo-class is used to define a special state of an element.
For example, it can be used to:
  • Style an element when a user mouses over it
  • Style visited and unvisited links differently
  • Style an element when it gets focus
Syntax:

selector:pseudo-class {
  property:value;
}


Example:
/* unvisited link */
a:link {
  color: #FF0000;
}

/* visited link */
a:visited {
  color: #00FF00;
}

/* mouse over link */
a:hover {
  color: #FF00FF;
}

/* selected link */
a:active {
  color: #0000FF;
}


https://www.w3schools.com/css/css_pseudo_classes.asp
https://www.youtube.com/watch?v=gtY7VBru06Y

----------------------------------------------------------------------------------------------------------------------
Q7. What are pseudo elements in css?

Answer:
CSS pseudo-element is used to style specified parts of an element.
For example, it can be used to:
  • Style the first letter, or line, of an element
  • Insert content before, or after, the content of an element
  • Notice the double :: for pseudo elements and : for pseudo class. 
Syntax:
selector::pseudo-element {
  property:value;
}

example:
p::first-line {
  color: #ff0000;
  font-variant: small-caps;
}

Must check below link
https://www.w3schools.com/css/css_pseudo_elements.asp
https://www.youtube.com/watch?v=GwAuU45IwoM

----------------------------------------------------------------------------------------------------------------------
Q8. What is Doctype in HTML5? What is the requirement of using it?

Answer:
Declaration of the doctype is the very first thing in your HTML document even before the <html> tag.
Declaring Doctype tells the browser to use "standard" mode to render the document.

Also by looking at syntax of doctype declaration browser knows in which HTML version page is written.
----------------------------------------------------------------------------------------------------------------------
Q9. Can we have multiple headers and footers in our single html page?

Answer:


Yes, we can have multiple headers and footers. Each header, footer will connect to its nearest ancestor section. like declaring header just after "body" tag and then declaring header just after "table" tag.
----------------------------------------------------------------------------------------------------------------------
Q10. What is Local Storage in HTML5?

Answer:
It is a data stored in web browser locally. It is a 5MB storage. Before local storage cache were used. local storage stores data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year..

data stored is in format of key/value pair.
localStorage.setItem(key, value): Stores a value associated with a key.
localStorage.getItem(key): Retrieves the value associated with the key.


Example
<script type="text/javascript">
// Check if the localStorage object exists
if(localStorage){
    // Store data
    localStorage.setItem("first_name", "Peter");
    // Retrieve data
    alert("Hi, " + localStorage.getItem("first_name"));
} else{
    alert("Sorry, your browser do not support local storage.");
}
</script>

https://www.tutorialrepublic.com/html-tutorial/html5-web-storage.php

----------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment