Skip to main content

HTML&CSS

Question : Why title element is important?
Answer : This is the element represent, html page in the tab, also when you add this webpage as a bookmark then it will be a default name saved for the bookmark name.

Question : What is the benefit of using the label?
Answer : the for attribute of lable tag will able to associate the name with the element, and clicking on the label itself is good enough to add the focus and and selection to the given element.

Question : Does the box-sizing property affect the overall width or height of the elements?
Answer : Yes, border width, padding and margin is added to the width properties,
e.g.

h1 {
line-height:40px;
    font-weight: bold;
    color: aqua;
    font-size: 40px;
    width: 300px;
    padding: 50px;
    margin: 50px;
    border : 10px dotted;
    text-align: center;
}

This means that the overall of width of the element is width value  + 2 * padding [ right + left ] + 2 * border [ left + right ].

Question : What is box-sizing property?
Answer : if we add the box-sizing property as border-box, then it will try to subtract the padding and border width to make sure the width is equal to 300 px like above example rather than, adding the padding vale + border width value to overall width of the content.

Note that the margin property is not counted as overall width of an element.

Question : What is the main differance between block and inline element.
Answer : All the block level element will take the available space, additionally two adjacent or sibling block elements are stack on each other i.e. they are separated with the line break, the example of block element are div, h1,h2,p.
But on the the other hand the inline elements are separated by space and they will only take space as they need, mostly based on the inner content, e.g. span, addition to that, they completely ignore the width and margin properties and outcome of the page will not have explicit effect of width and margin for the inline elements.

Question : can we convert inline element like span to behave like block element like div?
Answer : Yes, if we add the display property to the span as block, e.g span { display : block }, then it will be to behave like regular block element.

Question : What is descendant selectors?
Answer : this selector applies the rules to any children. e.g.

.content .contentTitle {
font-weight: bold;
    font-style: italic;
}

So that means if we have a parent element with the class 'content' then any child, having the class contentTitle will have this rule applied, addition to that the child can be nested n level deeper and need not have to be immediate child.

<div class="content" id="tab2Content">
<div>
<p>
<span class="contentTitle">I am title</span>
</p>
</div>
Content of TAB 2
</div>

Question : give example of the title and description where the content will float around the title, as we want to start the content as soon as our title is ending, and title text can be as big as 25px, but the content text may be 14px range.
Answer :
.content .contentTitle {
font-size: 25px;
    font-weight: bold;
    font-style: italic;
    float: left;
    margin-right: 5px;
}

So that means the element will float on the left side of screen and preceding or non floating elements will displayed right next to the floating element, even though internally the element is block element like div tag.

Question : Now if you don't want then next element to float around the floated element, can we do anything about it?
Answer : Yes we can use the clear properties, e.g.
.content .contentTitle {
font-size: 25px;
    font-weight: bold;
    font-style: italic;
    float: left;
    margin-right: 5px;
}
.content .contentDescription {
font-weight: normal;
    font-style: normal;
    clear: left;
}

Now the contentDescription will need not have to float, and hence it will behave like regular block element, i.e. it will shown in the next line rather, starting from the end of the contentTitle.

Question : What will happen if we apply float:left, addition to the behavior which move everything towards left, what else happen.
Answer : It start behaving like display:block, hence padding and width property will be start ownered by the elements.


Question : Give an example of @keyframe?
Answer : The below example is for making a image bounce up and down, and finally it will come back to the original position.

<head>
<style>
figure img:target{
animation-name: slideDown;
animation-duration: 5s;
animation-timing-function: linear;
}
@keyframes slideDown {
0% { transform: translateY(-100%)}
10% { transform: translateY(100%)}
20% { transform: translateY(-80%)}
30% { transform: translateY(80%)}
40% { transform: translateY(-50%)}
50% { transform: translateY(50%)}
60% { transform: translateY(-30%)}
70% { transform: translateY(30%)}
80% { transform: translateY(-10%)}
90% { transform: translateY(10%)}
100% { transform: translateY(0%)}

}

</style>
<script>
function backToNormal() {
setTimeout(function (){
var sharkImage = window.location.href.split('#');
window.location.href = sharkImage[0];
},6000);

}

</script>
</head>
<body>
<nav class="grouping">
<figure>
<img id="shark" src="blueShark.jpg" alt="sharky" width="200" height="220" style="float: left">
</figure>
<a href="#shark" onclick="backToNormal()">Click me to animate shark</a>

</nav>
</body>

Question : Write a animation which can cover a picture and show it for some time then hide?
Answer:
<head>
<style>
figure span {
display: inline-block;
transform: translateX(-100%);
background-color: blue;
height: 220px;
width: 200px;
}
figure span:target {
animation-name: slideSide;
animation-duration: 5s;
animation-timing-function: ease;
}

@keyframes slideSide {
0% { opacity: .1 ; background-color: yellow}
10% { opacity: .2 ;background-color: orange}
20% { opacity: .3 ; background-color: green}
30% { opacity: .4 ; background-color: lightblue}
40% { opacity: .5 ;background-color: cyan}
50% { opacity: .6 ; background-color: wheat}
60% { opacity: .5 ;background-color: aqua}
70% { opacity: .4 ; background-color: rosybrown }
80% { opacity: .3 ;background-color: hotpink }
90% { opacity: .2 ;background-color: blue }
100% { opacity: .5; background-color: blue ; }

}
</style>
<script>
function backToNormal() {
setTimeout(function (){
var sharkImage = window.location.href.split('#');
window.location.href = sharkImage[0];
},8000);

}

</script>
</head>
<body>
<nav class="grouping">
<figure>
<span id="cover"></span>
<img id="shark" src="blueShark.jpg" alt="sharky" width="200" height="220" style="float: left">
</figure>
<a href="#cover" onclick="backToNormal()">Cover me with the blue sheet</a>

</nav>
</body>

Comments

Popular posts from this blog

NodeJS

Question : Why You should use Node JS? Answer :  Following are the major factor influencing the use of the NodeJS Popularity : The popularity can be important factor, as it has more user base and hence solution  of any common problem faced by developer can found easily online, without any professional help. JavaScript at all levels of the stack :  A common language for frontend and backend offers several potential benefits: The same programming staff can work on both ends of the wire Code can be migrated between server and client more easily Common data formats (JSON) exist between server and client Common software tools exist for server and client Common testing or quality reporting tools for server and client When writing web applications, view templates can be used on both sides Leveraging Google's investment in V8 Engine. Leaner, asynchronous, event-driven model Microservice architecture Question : example of node JS code? Answer :  const fs = require('fs'); const uti

Kubernetes

What is Kubernetes? Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem.  The name Kubernetes originates from Greek, meaning helmsman or pilot. Google open-sourced the Kubernetes project in 2014. Kubernetes combines over 15 years of Google’s experience running production workloads at scale with best-of-breed ideas and practices from the community. Why you need Kubernetes and what it can do? Containers are a good way to bundle and run your applications. In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime. For example, if a container goes down, another container needs to start. Wouldn’t it be easier if this behavior was handled by a system? That’s how Kubernetes comes to the rescue! Kubernetes provides you with a framework to run distributed systems resi

Spring Interview Question - Version 3.5

Spring Overview Question :   What is Spring? Answer : Spring is an open source development framework for Enterprise Java. The core features of the Spring Framework can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring framework targets to make Java EE development easier to use and promote good programming practice by enabling a POJO based programming model.   Question : What are benefits of Spring Framework? Answer :   Lightweight : Spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 2MB.   Inversion of control (IOC) : Loose coupling is achieved in Spring, with the Inversion of Control technique. The objects give their dependencies instead of creating or looking for dependent objects.   Aspect oriented (AOP) : Spring supports Aspect oriented programming and separates application business logic from system services.   C