- What are functions of CSS?
- Apply same style rules on multiple elements
- Control the presentation of multiple pages of a website with a single style sheet
- Present the same page differently on different devices
- Style dynamic states of elements such as hover, focus, etc. that isn't possible otherwise
- Change the position of an element on a web page without changing the markup
- Alter the display of existing HTML elements
- Transform elements like scale, rotate, skew, etc. in 2D or 3D space
- Create animations and transitions effects without using any JavaScript
- Create print friendly version of your web pages
- Why we should learn CSS well?
- Explain ways to use CSS.
Inline styles — Using the style attribute in the HTML start tag < h1 style="color:red; font
size:30px;">This is a heading< /h1>
Embedded styles — Using the < style> element in the head section of a document
< head>< style>< /style>< /head>
External style sheets — Using the < link> element, pointing to an external CSS file < link rel="stylesheet" href="css/style.css">
- Compare with other ways, what are the benefits of using linking external style sheet?
可以被复用;容易修改编辑;provide browser cache advantages;可以影响不止一个文件
- What are the rules to override any style sheet.
Any inline style sheet takes highest priority. So, it will override any rule defined in < style>...< /style> tags or rules
defined in any external style sheet file. Any rule defined in external style sheet file takes lowest priority, and rules defined in this file will be applied only
when higher priority CSS are not applicable.
- What are the main parts of a style.
Selector − A selector is an HTML tag at which a style will be applied. This could be any tag like < h1> or
< table> etc.
Property − A property is a type of attribute of HTML tag. Put simply, all the HTML attributes are converted
into CSS properties. They could be color, border etc.
Value − Values are assigned to properties. For example, color property can have value either red or #F1F1F1
etc.
- Try to specify major selectors in CSS.(at least 5)
- tag selector
- class selector
- ID selector
- Descendant selector
- attribute selector
- grouping selector
- child selector
- Try to compare with the id selector and class selector.
Class can be reused in the page. ID can only appear once in the page, so it can't be reused. If multiple elements need to use the same style and need to refer to your CSS repeatedly to reduce the workload and
code amount, use class as much as possible. In the module with large page, use ID to distinguish different modules.Since ID is the only one in the page, it is more useful for JavaScript in the page