cascading style sheet Flashcards
(31 cards)
what does css stand for
cascading style sheets
what is the main purpose of css
to style and layout web pages
how do you select an html element with the class “menu”
.menu
which selector targets the element with id =”main”
main
write a css rule to make all <h1> text blue
h1 { color : blue;}
what are the three ways to apply css
inline styles, internal document level, external
what is the highest priority style
inline style
how do you comment in css
/* this is comment */
write a rule for <p> elements to have italic text
p { front-style : italic;}
what property sets a space inside the border of an element
padding
which property sets the background color
background - color
what does the * selector mean in css
selects all elements
what is the extension for css file
.css
how do you include an external stylehsheet in html
< link rel =”stylesheet” href=”style.css”>
what does the font- family property do
sets the typeface for the text
what does #header . menu-item select
.menu-item inside an element with id header
What is the role of the rel attribute in <link></link> tag for CSS?
Defines the relationship, like “stylesheet”.
- MCQ: Which of the following correctly links an external CSS file to an HTML document?
A) <style>
B) <stylesheet>
C) <link></link>
D) <css></css></stylesheet></style>
c
To select an element with id=”hero” and apply red text color in CSS, you write:
hero { color : red;}
Write a CSS rule to set the font of all paragraphs to Arial and size 16px.
p {
font-family: Arial;
font-size: 16px;
}
MCQ: Which CSS property is used to center-align text horizontally inside an element?
A) align-text
B) text-center
C) align
D) text-align
d
ul li.special { color: green; }
It selects all <li> elements with class “special” that are inside a <ul>, and sets their text color to green.
What does the term “cascading” in CSS mean?
It refers to how the browser determines which styles to apply when multiple rules target the same element — based on priority: inline > internal > external > browser default.
Consider the following code fragment taken from the body element of an
HTML document.
<h1>Web Technologies</h1>
<p>The following are some <em>key</em> technologies.</p>
<dl>
<dt>CSS</dt>
<dd>Cascading Style Sheets.</dd>
<dt>Javascript</dt>
<dd>A <em>language</em> for scripting web documents.</dd>
</dl>
Write code for a style element containing CSS rules to display the informa
tion in the HTML fragment as follows.
* The text-decoration property of em elements should have a value of
underline.
* The font-weight property of all elements of class important should
have a value of bold.
* The border-style property of the element with an id of “techlist”
should have a value of dotted.
* The word “language” should be rendered with a value of blue for the
background property. The rule you write for this should not affect any
other content
<style>
em { text-decoration: underline; } .important { font-weight: bold; } #techlist { border-style: dotted; } em:contains("language") { background: blue; }</style>