What is CSS?
CSS stands for Cascading Style Sheet. CSS is applied to HTML page to improve the design, color, and attributes of HTML elements.
What are the selectors in CSS?
Selectors are the references to HTML block, on what the CSS rules to be applied. We can have class, id, HTML tag etc.
How to create a style sheet?
Create a plain text file and named it with .css extension, like “style.css”
How can we link a style sheet to an HTML page?
We can link a seperate style sheet in a html page, using LINK tag, inside HEAD of html. For example
What is inline CSS?
When CSS rules applied to elements in the tag itself using style attribute of DOM. This is not a good practice.
Why inline CSS is not good for a website?
It affects the DOM visibility on search engines. In line, CSS is treated as content by search engines and that is not good for the health of site also. Also lowers the page speed.
What are the common attributes of HTML elements?
Most common attributes of HTML elements are :
-style
-title
-height
-width
-src
-alt
-href
-bg-color
What is !important?
It is used to apply the CSS rule forcefully. It ignores any other rule written for the selector.
What is viewport?
The viewport is the screen size of the device, that used to view the webpage. It refers to the visible area or resolution of the screen.
What is a responsive web page?
A webpage which is compatible with all the devices and screen size is responsive. A responsive web page adjusts content according to the screen size and manages the content in the different layout defined for the devices. We have many CSS frameworks that can be used to create a responsive webpage. For example Bootstrap.
What is media query?
A media query is the conditional rules to apply on a webpage. We use @media and some condition, and when the condition occurs, rule starts working. We use @media for printing, responsive, device detection etc.
What are the benefits of external style sheet?
Benefits of External Style Sheet:
– Clean and Clear structure
– A common rule for similar elements
– All the rules are placed in a single file so we can modify it easily or can add new rules.
– Since HTML DOM tree is clear so it will boost the page speed as well as search engine visibility.
What is a class?
A class is an attribute of HTML elements. We can put some value in class attribute and then we can apply CSS rules on these classes. We can reuse these classes in other HTML elements.
What is ID?
ID is an attribute of HTML elements.A web page can have many IDs but no two IDs can be same. ID should be unique.
How to import CSS rules from another style sheet?
Yes, we can import CSS rules from another style sheet. For example :
@import url("assets/css/style.css");
What are most commonly used CSS framework?
There is a number of frameworks available for CSS rules. Some of them are as:
-Bootstrap
-Foundation
-Skeleton
-Kube
In how many ways can we apply the style to HTML?
We can directly write CSS rules in tags, that is inline CSS rule.
We can write CSS rule in “style” tag in an HTML page.
We can add a separate style sheet.
What is z-index in CSS rule?
z-index is the position of an element in the z-axis of coordinate.This specifies which element should appear on top.
What is display in CSS rule?
the display is for visibility and layout options. We can set any type of display options for any element. If we set to display as “none”, It will not render on view, but It will be a part of HTML DOM.