Explain the purpose of the CSS float property.
The float property places an element on the left or right side of its container.
Write a CSS rule to put any images in the class cartoonImage to the right of the page
.cartonImage{float:right;}
Explain the purpose of the CSS height and width properties.
The CSS height and width properties are used to set the height and width of an element.
Complete the CSS rule below to make a section of the webpage about Newcastle appear on the left hand side of the page with the following dimensions -300px × 200px
#newcastle{
}
newcastle{
width: 300px;
height: 200px;
float:left;
}
Describe the effect of the CSS display:none property.
The element is not displayed.
Describe the effect of the CSS display:inline property.
The element is dislayed on the same line as the preceding element.
Describe the effect of the CSS display:block property.
The element is displayed as a block, generating line breaks before and after.
Write a CSS rule to hide the section of a website shown below?
<div>
<p> Burger </p>
<p> £7.99 </p>
</div>
burgerInfo{display:none;}
The a website contains the following HTML
<section>
<p>Fruits</p>
<p>Vegetables</p>
<p>Animals</p>
</section>
Write a CSS rule (without using float) which will make the content display on website as shown below.
Fruits Vegetables Animals
.categories p{display: inline-block;}
What is the difference between display block and display inline?
Block elements start on a new line and fill the whole width. Inline elements stay in the same line and only take up as much space as needed.
Describe the difference between CSS margins and padding.
The margin property is used to create space around an element outside its border.
The padding property is used to create space around an element inside its border.
What does clear: both; do?
Clear both removes the effect of any floats elements on both sides.
The layout around and image of the the jungle should have 10 pixel gaps above and to the left of the image, there should also be a gap of 20 pixels to the right of the image .
Create a CSS rule for this image.
.jungleImage {}
.jungleImage { margin-top:
10px; margin-left: 10px ;
margin-right: 20px ;}
OR
.jungleImage { padding-top:
10px; padding -left: 10px ;
padding -right: 20px ;}
What does clear: left; do?
Clear left removes the effect of any floats elements on the left side.
What does clear: right; do?
Clear right removes the effect of any floats elements on the right side.
Explain what this code will do
nav ul {
list-style-type: none;
}
Remove Bullet Points from the nav bar
Write a CSS rule to remove the bullet points from the nav bar
nav ul {
list-style-type: none;
}
Explain what this code will do
a:hover {
background-color: green;
}
It will change the background colour to green when the mouse hovers over an anchor (link)
Write a CSS rule which the appearance of the link in the nav bar to have a blue background and red text when the mouse hover overs it
nav ul li a:hover {
background-color: blue;
color: red;
}
The following code has been used to remove the bullet points from the nav bar:
nav ul {
list-style-type: none;
}
Explain why the unordered list in the nav bar will display differently to any other unorder list in the website?
The code uses a descendant selector this code only selects and modifies unordered lists in the nav element therefore other unordered list are not affected.
Write a CSS rule to create a horizontal navigation bar so that:
no bullet points are shown,
each item is placed horizontally with 100 px width for each element and the text in the center, 10 pixels padding in added around each link, when the cursor goes over the the link the background is blue and the text is yellow.
nav ul {
list-style-type: none;
}
nav ul li {
float: left;
width: 100px;
text-align: center;
}
nav ul li a {
display: block;
padding: 10px;
}
nav ul li a:hover {
background-color: blue;
color: yellow;
}
Write a CSS rule to to make all content in the following classes have a red background. Top and Middle
.top, .middle { background-color: red;}
A section of the CSS code for styling a website is shown below:
main {background-color: red;}
#king {background-color: red; padding: 10px;}
p {padding: 10px;}
h1 {color: white; font-size: 22px; padding: 10px;}
main h2 {padding: 10px;}
Use grouping selectors to re-write the code to make it more efficient
Write a CSS rule to to make all margins for images, h2 and h3 headings 20 pixels,
h2,h3,img {margin:20px;}
Make me yellow.
Make me yellow.