1
What is CSS?
ans.
Cascading Style Sheet is an open standard developed and maintained by the W3C. It is a Look and Feel formatting scripts used along with HTML Tags.
Presentation: It uses how to control things like the color of text, the fonts you want to use and the size of those fonts, how to add background colors to pages (or parts of a page), and how to add background images.
Layout: How to control where the different elements are positioned on the screen.
2
Can we apply CSS in the <title>tag?
ans.
We can’t apply any CSS.
3
What is the different between ID and Class?
ans.
ID
Class
The id attribute is used for assigning a unique identifier to a specific element on the page. Accessed using CSS or JavaScript for styling or scripting purposes
The class attribute is used in a similar fashion; however, unlike the id attribute, the same class value may be applied to multiple elements on the page for the purposes of specifying that they have something in
common (such as a particular CSS style).
The id attribute may also be used as the target of hyperlinks.
Cannot use
The value may appear once and only once per page so as to identify a single
element.
The value may appear multiple times per page.
One element contains only one unique ID and doesn’t include space.
A particular class attribute value may contain multiple class names, each separated by a space.
4
Can we use class and ID attributes in a single element?
ans.
Yes, a single element can have one ID and more than one Class elements.
5
Define CSS rules.
ans.
A CSS rule contains two parts: a selector and a declaration.
- This rule indicates that all elements should be shown in the Arial typeface.
- Selectors indicate which element the rule applies to. The same rule can apply to more than one element if you separate the element names with commas like p, #main{}
- Declarations indicate how the elements referred to in the selector should be styled.
6
What is Universal Selector in CSS?
ans.
Applies to all elements in the document.
*{} Targets all elements on the page
7
What are the selectors in CSS?
ans.
There are 8 selectors in CSS. That are:
Universal Selector Type Selector Class Selector D Selector Child Selector Descendant Selector Adjacent Sibling Selector General Sibling Selector
8
Define ype Selector in CSS
ans.
Matches element names.
h1, h2, h3 {} Targets the <h1>, <h2> and <h3> elements
9
Define Class Selector in CSS.
ans.
Matches an element whose class attribute has a value that matches the one specified after the period (or full stop) symbol
.container {} Targets any element whose class attribute has a value of container p.container {} Targets only <p> elements whose class attribute has a value of container
10
Define !important in CSS
ans.
If we add !important after any property value to indicate that it should be considered more important than other rules that apply to the same element.
p{color:red !important}