HTML & CSS II Flashcards

1
Q

How does CSS3 differ from CSS?

A

CSS3 is the most recent version of CSS. It has introduced a bunch of new tags to give a better user experience. Some of the features are rounded corners, animation, custom layouts, and media queries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does CSS3 support responsive web designing?

A

CSS3 has come up with a media query feature. It supports RWD (Responsive Web Design) and does help in making a website responsive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a CSS selector?

A

A CSS selector is an expression following the CSS rules and is used to select the element we want to style. And, CSS selector syntax means how we write or use those selectors in the CSS editor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the different types of CSS?

A

Below are the different types of CSS.

Embedded – It adds the CSS styles using the <style> attribute; Embedded CSS refers to the use of a <style> element within the <head> section of an HTML document.</style></style>

Inline – It adds CSS to the HTML elements; You use the style attribute within an HTML tag

Linked/External – It adds an external CSS file to the HTML document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an ID selector?

A

The ID selector uses the “ID” attribute of the target HTML element to select it. The constraint to work is that the ID should be unique within a page so that the selector can point it out correctly.

To build an ID selector expression, start with a hash (#) character, followed by the id of the element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Grouping in CSS3?

A

Grouping makes it possible to apply the same style to multiple HTML elements (Classes/Tag/ID) within a single declaration. It happens by specifying all the selectors separated by commas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are Child Selectors in CSS?

A

A child selector looks up for the child of some element. To form a child selector, we need two or more selectors separated by the “greater than” symbol.

Let’s take an example. We have a <ul> tag inside a paragraph. Here, <ul> is the child of the paragraph element. So, to apply the CSS styles, we can use the following syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Webkit in CSS3? And why is it used?

A

Webkit is a core software component that is responsible for rendering HTML and CSS in browsers like Safari and Chrome. There are other similar rendering engines like Gecko for Mozilla, Presto for Opera, and Edge for IE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is CSS Box Model and what are its components?

A

The CSS Box Model represents a box that confines every HTML element such as a text box, a menu, or a button. It has primarily four core components.

Margin – It refers to the topmost layer of the box.
Border – The padding and content options work around the Border. Changing the background color can also affect the Border.
Padding – It defines spacing around the box.
Content – It represents the actual content to be shown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are media queries in CSS3 and why do you use them?

A

Media queries are one of the latest features of CSS3 used to define responsive styles for devices of different shapes and sizes.

They are powerful CSS tool that makes it easy to create a responsive design for tablets, desktop, and mobile devices. They can help to adjust the Height, Width, Viewport, Orientation, and Resolution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are Pseudo-Classes in CSS?

A

A Pseudo-Class is a CSS technique to set the style when the element changes its state.

For example

Edit the style upon mouse hover event.
Set the style when an element gets focused.
Apply different styles for visited/unvisited links.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the use of float property in CSS?

A

With the help of the float property, we can control the position and layout of elements on a web page.

For example, it can define the placement of a <div> either to the right or left side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which property do you use to modify the face of a font in CSS?

A

First of all, please note that both the terms <@font-face> and <font-family> refer to changing the font of an HTML element. However, there is a slight difference between the two.</font-family>

  1. The <@font-face> is a CSS rule that facilitates the use of custom fonts on a web page.
  2. The <font-family> is a CSS property that specifies the font for a web element.</font-family>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is Z-index and how does it work?

A

The z-index is a CSS property that defines the stack order of web elements. Higher-order elements will appear before any lower-order element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does float do?

A

float pushes an element to the sides of a page with text wrapped around it. you can create entire page or a smaller area by using float. if size of a floated element changes, text around it will re-flow to accommodate the changes. You can have float left, right, none or inherit.

if you set, ‘float: left;’ for an image, it will move to the left until the margin, padding or border of another block-level element is reached. The normal flow will wrap around on the right side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you clear sides of a floating element?

A

If you clear a slide of an element, floating elements will not be accepted on that side. With ‘clear’ set to ‘left’, an element will be moved below any floating element on the left side. clear is used to stop wrap of an element around a floating element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Does css properties are case sensitive?

A

no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Why css selectors mixed up with cases don’t apply the styles?

A

html ID and classes are case sensitive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Does margin-top or margin-bottom has effect on inline element?
Does padding-top or padding-bottom has effect on inline element?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Does padding-left or padding-right or margin-left or margin-right has effect on inline element?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Which one would you prefer among px, em % or pt and why?

A

px gives fine grained control and maintains alignment because 1 px or multiple of 1 px is guaranteed to look sharp. px is not cascade, this means if parent font-size is 20px and child 16px. child would be 16px.

em maintains relative size. you can have responsive fonts. em is the width of the letter ‘m’ in the selected typeface. However, this concept is tricky. 1em is equal to the current font-size of the element or the browser default. if u sent font-size to 16px then 1em = 16px. The common practice is to set default body font-size to 62.5% (equal to 10px). em is cascade

% sets font-size relative to the font size of the body. Hence, you have to set font-size of the body to a reasonable size. this is easy to use and does cascade. for example, if parent font-size is 20px and child font-size is 50%. child would be 10px.

pt(points) are traditionally used in print. 1pt = 1/72 inch and it is fixed-size unit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How absolute, relative, fixed and static position differ?

A

absolute, place an element exactly where you want to place it. absolute position is actually set relative to the element’s parent. if no parent available then relatively place to the page itself.

relative, is position an element relative to itself (from where the element would be placed, if u don’t apply relative positioning). for example, if u set position relative to an element and set top: 10px, it will move 10px down from where it would be normally.

fixed, element is positioned relative to viewport or the browser window itself. viewport doesn’t changed if u scroll and hence fixed element will stay right in the same position.

static, element will be positioned based on the normal flow of the document. usually, u will use position static to remove other position might be applied to an element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are the differences between visibility hidden and display none?

A

display:** none removes the element from the normal layout flow and allow other elements to fill in**.

visibility: hidden tag is rendered, it takes space in the normal flow but doesn’t show it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are the differences between inline, block and inline-block?

A

inline, elements do not break the flow. think of span it fits in the line. Important points about inline elements, margin/ padding will push other elements horizontally not vertically. Moreover, inline elements ignores height and width.

block, breaks the flow and dont sits inline. they are usually container like div, section, ul and also text p, h1, etc.

inline-block, will be similar to inline and will go with the flow of the page. Only differences is this this will take height and width.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the properties related to box model?
Technically, **height, width, padding and border** are part of box model and margin is related to it. Everything in a web page is a box where you can control **size, position, background**, etc. Each box/ content area is optionally surrounded by padding, border and margin. When you set height and width of an element, you set content height and width.
26
What are the some pseudo classed u have used?
pseudo class tells you specific state of an element. **allow to style element dynamically**. The most popular one is :hover. Besides i have used **:visited, :focus, :nth-child, nth-of-type, :link, etc.** pseudo classes is better if you don't want to mess up with javaScript however, pseudo-classes is slow to process and apply rules.
27
How do you align a p center-center inside a div?
**text-align: cente**r will do the horizontal alignment but **vertical-align: **middle will not work here. there are couple of different ways to solve this problem and one of them are positioning. You make the parent as relative position and child as absolute positioning. And then define all position parameter as sero and width 50% and height 30% (sounds messy look at the example and read ref)
28
How can you load css resources conditionally?
@import allows you to load/ import stylesheet by using a path (uri) representing the location of the file. You can define one or more media by comma separation for which you want to load the stylesheet. If browser dont support the media stylesheet will not be loaded.
29
Why would you use sprites?
When you have multiple images/ icons, browser makes separate call to the server for each one of them. sprite is a technique to combine all/ some of them (usually similar one in terms of type of image. For example, you will put jpg in one sprite) in one image. To display the icon you set height, width and background position. popular libraries like bootstrap use this technique. If you repeat the image. want to scale you have to be careful with sprite.
30
What is specificity? How do u calculate specificity?
is a process of determining which css rule will be applied to an element. it actually determines which rules will take precedence. inline style usually wins then ID then class value (or pseudo-class or attribute selector), universal selector (*) has no specificity.
31
What is shadow DOM?
encapsulate part of a DOM. hide subtree. you can have same ID in different shadow DOM. Polymers uses it. This way your DOM becomes reusable.
32
What do you know about transition?
transition allows to add an effect while changing from one style to another. You can set the which property you want to transition, duration, how you want to transit (**linear, ease, ease-in, ease-out, cubic-bezier**) and delay when transition will start. you can transition more than one property by comma separation
33
What are the different css filter you can use?
css filter allows u to render DOM element, image, or video. u can choose from: grayscale, blur, opacity, brightness, contrast.
34
What are the reasons to use preprocessor?
you write css in high level with some** special syntax (declaring variable, nested syntax, mathematical operations, etc.)** and that is compiled to css. Preprocessor helps you to speed up develop, maintain, ensure best practices and also confirms concatenation, compression, etc.
35
What is HTML?
HTML stands for HyperText Markup Language. It is a standard text formatting language used for developing web pages released in 1993. HTML is a language that is interpreted by the browser and it tells the browser what to display and how to display.
36
What are tags and attributes in HTML?
Tags are the primary component of the HTML that defines how the content will be structured/ formatted, whereas Attributes are used along with the HTML tags to define the characteristics of the element. For example,

Interview questions

, in this the ‘align’ is the attribute using which we will align the paragraph to show in the center of the view.
37
Can we display a web page inside a web page or Is nesting of webpages possible?
Yes, we can display a web page inside another HTML web page. HTML provides a tag