CSS Flashcards
What are block elements, and how do they behave in terms of placement and height?
Block elements occupy full horizontal space within their parent and stack vertically. Their height usually depends on their content. Examples include p
, div
, and section
.
What are inline elements, and how are they placed on the page?
Inline elements flow left-to-right horizontally Examples are span
, em
, a
, and single letters.
Inheritance of Rules
Do CSS rules for parent elements apply to their children?
Yes, a CSS rule for a parent element automatically matches its children. For instance, a rule for the body
will apply to all text inside or outside <p>
tags.
Efficient Styling
How does inheritance help in writing efficient styles?
Inheritance allows you to apply styles to parent elements and have those styles automatically affect their children.
This reduces the need to write repetitive rules for every individual element.
What does the media
attribute indicate in the <style>
tag?
The media
attribute indicates the target media types/devices for which the CSS rules.
Used to specify that the style is for special devices (like iPhone), screen, speech or print media.
What methods can be used to change the appearance of HTML elements using CSS?
Three basic methods for adding code to HTML elements:
* Write it directly within the element’s tag. (inline)
* Place it in a separate section of the page’s source code. (section)
* Store it in an external file and reference it in the HTML page. (external)
Why is it not recommended to use the style
attribute of the <p>
tag if there are sibling paragraphs that should look the same?
The CSS declaration will need to be replicated in the other <p>
tags, which is time consuming, increases the file size, and it is prone to errors.
What is the default placement policy for placing a div
element?
The div
element is treated as a block element by default, so it will occupy all the horizontal space of its parent element and its height will depend on its contents.
What attribute of the <link>
tag indicates the location of an external CSS file?
The href
attribute.
What is the correct section to insert the link
element inside an HTML document?
The link
element should be in the head
section of the HTML document.
What happens if you start a comment with /*
in the middle of a CSS file, but forget to close it with */
?
All the rules after the comment will be ignored by the browser.
The default way the browser renders the document tree is called?
normal flow
True or False?
The basic element flow is from top to bottom and left to right.
True
True of false
Normal flow is simple and sequential.
True
What happens to automatic margins in a floated box?
Automatic margins are ignored in a floated box.