CSS Flashcards

(19 cards)

1
Q

CSS

A
  • Cascading Style Sheet (CSS) is a text file with .css
    extension and is commonly used to define styles and
    layouts of Web pages written in HTML.
  • CSS simplifies the task of maintaining a Web
    document by separating its style information, such
    as font size, text color, line width, and background
    color.
  • This separation allows you to apply the same style
    rules to multiple Web pages.
  • Suppose, you have a Web page that contains multiple
    tables and you want to apply some style on the table
    caption, table header, and table cells.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Advantage of using CSS

A

This reduces the complexity and
redundancy of code in the Web page and
saves our time, as we do not need to write
the same code again and again.

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

A style sheet

A

A style sheet is made up of one or more style instructions
(called rules or rule sets) that describe how an element
or group of elements should be displayed.
* Each rule selects an element and declares how it should
look.

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

syntax for h1

A

h1 { color: green; }
h1 { border: 1px solid blue; }

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

synatx for p

A

p { font-size: small; font-family: sans-serif; }

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

main sections/parts of a rule are

A

– the selector that identifies the element or
elements to be affected

– the declaration that provides the rendering
instructions
* The declaration consists of
– Property - value pair
– a property (such as color) and its value (green) are
separated by a colon and a space.

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

There are three ways that style information can be
applied to an HTML document.

A

– External style sheets
– Embedded style sheets
– Inline style

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

External style sheets

A

– An external style sheet is a separate, text-only document that
contains a number of style rules.
– It must be named with the .css suffix.
– The .css document is then linked to or imported into one or
more HTML documents.
– All the files in a website may share the same style sheet.
– This is the most powerful and preferred method for
attaching style sheets to content.

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

Embedded style sheets

A

– It is placed in a document using the style element,
and its rules apply only to that document.
– The style element must be placed in the head of
the document.

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

Inline styles

A

– We can apply properties and values to a single element using
the style attribute in the element itself, as shown below:
* <h1 style="color: red">Introduction</h1>
– To add multiple properties, just separate them with
semicolons, like this:
* <h1 style="color: red; margin-top: 2em">Introduction</h1>
– Inline styles apply only to the particular element in which they
appear.
– Inline styles should be avoided, unless it is absolutely
necessary to override styles from an embedded or external
style sheet.

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

Parents and children

A

– All the elements contained within a given
element are said to be its descendants.
– For example, the h1, h2, p, em, and img
elements in the document are all descendants of
the body element.
– The elements have parent-child relationship.

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

Document structure

A
  • HTML documents have an implicit structure or hierarchy.
  • For example, every web document has an html root
    element that contains a head and a body.
  • The body contains heading and paragraph elements.

( DIAGRAM IN PRESENTATION)

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

Grouped selectors

A

h1, h2, p, em, img { border: 1px solid blue; }

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

Floating

A

Floating an element moves it to the left or
right, and allows the following text to wrap
around it.

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

Positioning

A

Positioning is a way to specify the location of
an element anywhere on the page with pixel
precision.

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

float example

A

img {
float: right;
margin: 10px;
}
p {
padding: 15px;
background-color: #FFF799;
border: 2px solid #6C4788;
}

17
Q

paragraph float

A

p.float1 {
float: left;
width: 12%;
margin: 0px;
background: #CCC;
}
p.float2 {
float: left;
width: 75%;
margin: 0px;
text-align: center;
background: #CCC;
}

p.float3 {
float: left;
width: 12%;
margin: 0px;
background: #CCC;
}
p
{border: 1px solid red;
}

18
Q

CSS provides several methods for positioning
elements on the page

A

– They can be positioned relative to where they
would normally appear in the flow.
– They can be removed from the flow altogether
and placed at a particular spot on the page.

19
Q

position property

A

Values: static | relative | absolute | fixed |
inherit