CSS Assignment
1.What is CSS and why use it?
Cascading Style Sheets (CSS) is a language that specifies how a document is styled and presented. It's a fundamental technology of the World Wide Web, along with HTML and JavaScript.
CSS is used to add style to a web page by dictating how a site is displayed on a browser. It's unique in that it doesn't create any new elements, like HTML or JavaScript. Instead, it's a language used to style HTML elements.
CSS can be used to:
Adjust content size, spacing, color, and font
Add decorative features, such as animations or split content into columns
Control the layout of multiple web pages all at once
Some reasons to use CSS include:
Faster page speed
Better user experience
Quicker development time
Easy formatting changes
Compatibility across devices
2.What are the different ways to bring CSS into an HTML file?
There are three ways to add CSS to an HTML document:
Inline
Use the style attribute inside HTML elements. Inline styles can apply unique styles to HTML elements or a single HTML element.
Internal
Use a <style> element in the <head> section. Internal CSS allows for quick and easy styling of individual web pages.
External
Use a <link> element to link to an external CSS file. External CSS is the most common method for adding CSS to HTML. One external stylesheet can dictate the style of multiple HTML documents.
3.what do you mean by specificity in css?
In CSS, specificity is a measurement of relevance based on the type and order of CSS selectors in a document. It's a set of rules applied to the CSS selectors to determine which styles are applied to an element.
The rules of CSS specificity tell the web browser which CSS declarations should be applied when an HTML element or a group of elements is targeted by multiple CSS selectors.
The specificity hierarchy determines which selector (i.e. id, class, element) has highest priorities. The order of specificity rule is:
Inline style
ID selector
Classes, pseudo-classes, and attributes
ID selectors are used to target an element using the element's ID. They have higher specificity than classes and elements. In the specificity weight system, they have a value of 100.