Podcast
Questions and Answers
What is the primary function of CSS in web development?
What is the primary function of CSS in web development?
- Defining the structure of a webpage
- Managing server-side operations
- Describing the style of a document (correct)
- Adding interactivity to a webpage
Inline CSS is applied by writing CSS in a separate document and linking it with an HTML file.
Inline CSS is applied by writing CSS in a separate document and linking it with an HTML file.
False (B)
In CSS syntax, what does the 'selector' refer to?
In CSS syntax, what does the 'selector' refer to?
the HTML element to be styled
The CSS property used to set the color of text is called ______.
The CSS property used to set the color of text is called ______.
Match the color code with its representation in web design:
Match the color code with its representation in web design:
Which of the following selectors targets all elements on a webpage?
Which of the following selectors targets all elements on a webpage?
The text-align
property in CSS can only be used to align text to the left, right, or center.
The text-align
property in CSS can only be used to align text to the left, right, or center.
What CSS property is used to add a line above, below, or through text?
What CSS property is used to add a line above, below, or through text?
The CSS property that controls the boldness of the text is known as ______.
The CSS property that controls the boldness of the text is known as ______.
Match the font family with its correct description:
Match the font family with its correct description:
How many 'pixels' are in one 'inch'?
How many 'pixels' are in one 'inch'?
The default value for the CSS line-height
property is always specified in pixels.
The default value for the CSS line-height
property is always specified in pixels.
What CSS property can be used to convert text to uppercase or lowercase?
What CSS property can be used to convert text to uppercase or lowercase?
The CSS box model includes margin, border, padding and ______.
The CSS box model includes margin, border, padding and ______.
Match the description to each of the components of the CSS box model:
Match the description to each of the components of the CSS box model:
By default, what area does the CSS height property set?
By default, what area does the CSS height property set?
The CSS property border-radius
is used to create dashed or dotted borders around an element.
The CSS property border-radius
is used to create dashed or dotted borders around an element.
In CSS, what is the shorthand property to assign the following: border-width: 2px
, border-style: solid
, border-color: black
?
In CSS, what is the shorthand property to assign the following: border-width: 2px
, border-style: solid
, border-color: black
?
In the CSS box model, the space between the element's content and its border is called ______.
In the CSS box model, the space between the element's content and its border is called ______.
Match the padding values with what side of the box it represents:
Match the padding values with what side of the box it represents:
What CSS property is generally used to create space between elements?
What CSS property is generally used to create space between elements?
Setting display: none;
and visibility: hidden;
on an element will achieve the same result: the element will not be visible on the page, and the space it would have occupied will collapse.
Setting display: none;
and visibility: hidden;
on an element will achieve the same result: the element will not be visible on the page, and the space it would have occupied will collapse.
In CSS, what does the property opacity
control?
In CSS, what does the property opacity
control?
In CSS, to set the background color with transparency using RGBA, the alpha value ranges from 0 to ______.
In CSS, to set the background color with transparency using RGBA, the alpha value ranges from 0 to ______.
Match the relative units with its definition:
Match the relative units with its definition:
Which CSS property is used to control how an element is positioned within its containing element?
Which CSS property is used to control how an element is positioned within its containing element?
When an element has position: static;
, the top
, right
, bottom
, and left
properties will still affect its position.
When an element has position: static;
, the top
, right
, bottom
, and left
properties will still affect its position.
In CSS, what does the term 'stack level' refer to?
In CSS, what does the term 'stack level' refer to?
The CSS property used to set an image as the background of an element is called ______.
The CSS property used to set an image as the background of an element is called ______.
Match the background-size
property to its definition:
Match the background-size
property to its definition:
What term describes a one-dimensional layout method for arranging items in rows or columns?
What term describes a one-dimensional layout method for arranging items in rows or columns?
In Flexbox, flex-direction: row;
arranges flex items vertically by default.
In Flexbox, flex-direction: row;
arranges flex items vertically by default.
Name a property in Flexbox used to align items along the main axis.
Name a property in Flexbox used to align items along the main axis.
The Flexbox property used to control the alignment of items on the cross axis is called ______.
The Flexbox property used to control the alignment of items on the cross axis is called ______.
Match the Flexbox property for a flex item with its description:
Match the Flexbox property for a flex item with its description:
What is the purpose Media Queries in CSS?
What is the purpose Media Queries in CSS?
CSS Transitions allow you to change property values instantly and without any animated effect.
CSS Transitions allow you to change property values instantly and without any animated effect.
Name a property that could be applied to the CSS transition-timing-function
.
Name a property that could be applied to the CSS transition-timing-function
.
In CSS, transform: rotate(45deg);
will ______ an element by 45 degrees.
In CSS, transform: rotate(45deg);
will ______ an element by 45 degrees.
Match the different CSS Transform functions with its description:
Match the different CSS Transform functions with its description:
Flashcards
What is CSS?
What is CSS?
A language used to describe the style of a document.
CSS basic syntax
CSS basic syntax
The basic syntax consists of a selector, property, and value.
External Stylesheet
External Stylesheet
Writing CSS in a separate document and linking it with an HTML file.
Color Property
Color Property
Signup and view all the flashcards
Background Color Property
Background Color Property
Signup and view all the flashcards
What is RGB?
What is RGB?
Signup and view all the flashcards
Hexadecimal Color
Hexadecimal Color
Signup and view all the flashcards
Universal Selector
Universal Selector
Signup and view all the flashcards
Element Selector
Element Selector
Signup and view all the flashcards
Class Selector
Class Selector
Signup and view all the flashcards
text-align
text-align
Signup and view all the flashcards
text-decoration
text-decoration
Signup and view all the flashcards
font-weight
font-weight
Signup and view all the flashcards
font-family
font-family
Signup and view all the flashcards
Generic font families
Generic font families
Signup and view all the flashcards
CSS Width
CSS Width
Signup and view all the flashcards
CSS Height
CSS Height
Signup and view all the flashcards
CSS Border
CSS Border
Signup and view all the flashcards
border-radius
border-radius
Signup and view all the flashcards
CSS Padding
CSS Padding
Signup and view all the flashcards
CSS Margin
CSS Margin
Signup and view all the flashcards
Display Property
Display Property
Signup and view all the flashcards
CSS Visibility
CSS Visibility
Signup and view all the flashcards
CSS Alpha Channel
CSS Alpha Channel
Signup and view all the flashcards
Relative CSS units
Relative CSS units
Signup and view all the flashcards
Percentage unit (%)
Percentage unit (%)
Signup and view all the flashcards
Em
Em
Signup and view all the flashcards
What is Rem?
What is Rem?
Signup and view all the flashcards
CSS Position
CSS Position
Signup and view all the flashcards
CSS static position
CSS static position
Signup and view all the flashcards
Relative Position
Relative Position
Signup and view all the flashcards
Absolute position
Absolute position
Signup and view all the flashcards
CSS z-index
CSS z-index
Signup and view all the flashcards
Background Image
Background Image
Signup and view all the flashcards
Background Size
Background Size
Signup and view all the flashcards
CSS Flexbox
CSS Flexbox
Signup and view all the flashcards
Flexbox Direction
Flexbox Direction
Signup and view all the flashcards
justify-content
justify-content
Signup and view all the flashcards
align-items
align-items
Signup and view all the flashcards
Media Queries
Media Queries
Signup and view all the flashcards
CSS Transitions
CSS Transitions
Signup and view all the flashcards
Study Notes
- HTML, CSS and Javascript (JS) are fundamental technologies for web development
- HTML is responsible for the structure/layout of the content
- CSS is responsible for the styling of the content
- JS is responsible for the logic and interactivity of the content
CSS - Cascading Style Sheets
- CSS is a language to describe the style of an HTML document
Basic Syntax
- CSS syntax consists of a selector, property, and value
- The selector points to the HTML element you want to style
- The property is the style attribute you want to change
- Each property has a value
Including Style
- Inline styles: Adding styles directly within the HTML element using the "style" attribute,
<h1 style="color: red"> Apna College </h1>
<style>
tag: Defining styles in the<head>
section of HTML using the<style>
tag, useful for internal CSS.
<style>
h1 {
color: red;
}
</style>
- External Stylesheet: Writing CSS in a separate document and linking it with the HTML file
Color Property
- Used to set the color of foreground
- Example foreground colors: red, pink, blue, green;
Background Color Property
- Used to set the color of background
- Example background colors: red, pink, blue, green;
Color Systems
- RGB: Specifies color using the amount of red, green, and blue
- Example RGB colors: rgb(255, 0, 0), rgb(0, 255, 0)
- Hex (Hexadecimal): Specifies color using a hexadecimal value
- Example Hex colors: #ff0000, #00ff00
Selectors
- Universal Selector: Selects all elements on the page, e.g.,
* {}
- Element Selector: Selects HTML elements based on the element name, e.g.,
h1 {}
- Class Selector: Selects HTML elements with a specific class attribute, e.g.,
.myClass {}
- Id Selector: Selects an HTML element with a specific id attribute, e.g.,
#myId {}
Text Properties
text-align
: Specifies the horizontal alignment of text, values are left / right / centertext-decoration
: Specifies decorations added to text, values are underline / overline / line-throughfont-weight
: Specifies the weight or boldness of the font, values are normal / bold / bolder / lighterfont-family
: Specifies the font family for the text, such as arial or roboto
Generic Font Families
- Generic Font Families: Determined by font family properties like serifs or cursive strokes.
- Serif: Traditional typefaces with serifs, often used in printed books.
- Sans-Serif: Fonts without serifs, commonly used in digital formats.
- Cursive: Fonts with connective strokes, resembling handwriting.
- Fantasy: Stylized fonts maintaining characteristics of traditional alphabet glyphs.
- Monospace: Fonts where characters have the same width, resembling a typewriter.
Units in CSS
- Absolute Units: Represent a fixed measurement.
- Pixels (px): A common absolute unit, where
96px = 1 inch
Text Properties - line-height
line-height
: Specifies the height of a line of text.- Example values for line-height:
2px
,3
,normal
Text Properties - text-transform
text-transform
: Controls the capitalization of text.- Example values for
text-transform
:uppercase
,lowercase
,capitalize
,none
Box Model in CSS
- The CSS box model describes the rectangular boxes that are generated for elements in the document tree and used in visual layout.
- Key parts of box model: Height, Width, Border, Padding, Margin
Height
- Sets the content area height of an element, for example
height: 50px;
in CSS set div height
Width
- Sets the content area width of an element, for example
width: 50px;
in CSS set div width
Border
- Used to set an element's border
- Properties:
border-width
: Specifies the width of the border, example2px
border-style
: Specifies the style of the border, examplesolid / dotted / dashed
border-color
: Specifies the color of the border, exampleblack
- Shorthand property:
border: 2px solid black;
- Used to round the corners of an element's outer border
- Example
border-radius: 10px;
orborder-radius: 50%;
Padding
- Used to create space around an element's content, inside of any defined borders.
- Properties:
padding-left
padding-right
padding-top
padding-bottom
- Shorthand property:
padding: 50px;
orpadding: 1px 2px 3px 4px; /* top | right | bottom | left -> clockwise */
Margin
- Used to create space around an element, outside of any defined borders.
- Properties:
margin-right
margin-left
margin-top
margin-bottom
- Shorthand property:
margin: 50px;
ormargin: 1px 2px 3px 4px; /* top | right | bottom | left -> clockwise */
Display Property
- Specifies the display behavior of an element
- Available values:
inline
: Takes only the space required by the element. (no margin/padding)block
: Takes full space available in width.inline-block
: Similar to inline but we can set margin & padding.none
: to remove element from document flow.
Visibility
- Property:
visibility: hidden;
- When visibility is set to hidden, space for the element is reserved.
- If
display
is set to none`no space is reserved for the element
Alpha Channel
- Opacity: Adjusts the transparency of an element (0 to 1)
- RGBA: Specifies color with an alpha channel for transparency
- Example Usage:
color: rgba(255, 0, 0, 0.5);
// Red with 50% transparencycolor: rgba(255, 0, 0, 1);
// Opaque red
Units in CSS - Relative
- Relative Units: Measurements relative to another value
%
- Percentageem
rem
Percentage (%)
- Commonly used to define a size relative to an element's parent object
- Example usage:
width: 33%;
margin-left: 50%;
Em Unit
- Relative to the font size of the parent element
- Used for typographical properties like font-size. Also relative to the font size of the element itself, in the case of other properties like width.
Rem (Root Em) Unit
- Relative to the font size of the root element (e.g.,
<html>
)
Others
vh
: relative to 1% viewport heightvw
: relative to 1% viewport width
Position
- The position CSS property sets how an element is positioned in a document
- Values for
position
:static
/relative
/absolute
/fixed
Position Values
static
: Default position, top, right, bottom, left, and z-index properties have no effectrelative
: Element is relative to itself, top, right, bottom, left and z-index will workabsolute
: Positioned relative to its closest positioned ancestor (removed from the flow)fixed
: Positioned relative to the browser window (removed from flow)sticky
: Positioned based on user's scroll position
z-index
- Decides the stack level of elements, determining which element covers another in case of overlap
- Elements with a larger z-index cover those with a smaller one
- Values for z-index:
auto (0)
,1 / 2 / ...
,-1 / -2 / ...
Background Image
- Used to set an image as the background of an element
- Example:
background-image: url("image.jpeg");
Background Size
- Specifies how background images should be resized to fit their container
- Possible values:
cover
/contain
/auto
Flexbox
- Flexible Box Layout: A one-dimensional layout method to arrange items in rows or columns
The Flex Model
- Key components include the flex container, flex items, main axis, and cross axis
Flexbox Direction
- Sets how flex items are placed in the flex container, along which axis, and which direction.
- Values:
flex-direction: row;
(default)flex-direction: row-reverse;
flex-direction: column;
flex-direction: column-reverse;
Flex Properties (for Flex Container)
justify-content
: Alignment along the main axis- Options:
flex-start
/flex-end
/centre
/space-evenly
/ etc. flex-wrap
: Controls whether the flex items should wrap or not- Options:
nowrap
/wrap
/wrap-reverse
align-items
: Alignment along the cross axisalign-content
: Alignment of space between and around the content along cross-axis
Flex Properties (for Flex Item)
align-self
: Alignment of individual items along the cross axisflex-grow
: How much a flex item will grow relative to the rest of the flex items if space is availableflex-shrink
: How much a flex item will shrink relative to the rest of the flex items if space is available
Media Queries
- Help create a responsive website that adapts to different screen sizes and devices.
- Example:
@media (width: 600px) {
div {
background-color: red;
}
}
- This CSS rule applies only when the screen width is exactly 600px and sets the background color to red for all
div
elements
Transitions
- Transitions enable you to define the transition between two states of an element.
- Properties:
transition-property
: The CSS property you want to animate (e.g., font-size, width, etc.).transition-duration
: Specifies how long the transition should take (e.g.,2s
or4ms
).transition-timing-function
: Specifies the acceleration curve of the transition. Common values areease-in
,ease-out
,linear
orsteps
.transition-delay
: Specifies a delay before the transition starts (e.g.,2s
or4ms
).- Shorthand:
transition: font-size 2s ease-in-out 0.2s;
CSS Transform
- CSS Transform: used to apply 2D & 3D transformations to an element
- Transform functions:
rotate
: Rotates element- Example
transform: rotate(45deg);
scale
: Increase or decrease the size of the element- Example
transform: scale(2);
,transform: scale(0.5)
,transform: scale(1, 2);
- It is also possible to use
scaleX
andscaleY
to specify the direction translate
: Moves an element relative to its current position- Example
transform: translate(20px);
,transform: translate(20px, 50px)
- It is also possible to use
translateX
andtranslateY
to specify the direction skew
: Skews an element in 2D space.- Example
transform: skew (30deg);
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.