Review for Midterm I

HTML, CSS examples

CSS formatting

What will be the result of formatting the HTML below with the CSS file that follows?



<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
A sample page.
</title>
<link rel="stylesheet" type="text/css" href="question1.css" />
</head>
<body>
<h1>My little page</h1>
<p class="special">
This is the first part to my page. <strong>Welcome,
everyone!</strong> Some things that I like:
</p>
<ul>

<li class="special">biking</li>
<li>reading</li>
<li><strong>sleeping</strong></li>
</ul>
<p id="footer">
I hope you enjoyed <strong>my page!</strong>. You also might
want to visit <a href="http://www.google.com/">Google</a>, just
because.
</p>

</body>
</html>

The CSS file:


p, h1 {
        text-align: center;
}

p strong {
        color: #FF0000; /* red */
}

.special {
        font-style: italic;
}

li.special {
        background-color: #FFFF00; /*yellow*/
}

/* make visited links show in red */

/* add formatting to make <strong> in the first paragraph underlined */

/* make the footer text show up on a yellow background */

Check your answer here: http://csci1101sp10.morris.umn.edu/~elenam/1101_spring10/review1/question1.html


XHTML correctness

Correct all XHTML mistakes in the following page:


<!-- Find and fix XHTML errors in this page -->
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<title>
A sample page.
</title>
<body>
<h1>My little page<h1>
<p />
This is the first part to my page. <strong>Welcome,
everyone!</strong>
</p>
Some things that I like:
<ul>
<li class=special>biking</li>
<li>reading</li>
<li><strong>sleeping</li></strong>
</ul>
<p>
I hope you enjoyed <strong>my page!</strong>
</p>

</body>
</html>

PHP conditionals

Is the following program correct? If nor, please give an example of data for which it gives a wrong result and rewrite the program to fix the issue.


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Conditionals review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/6/08
-->
<?php
$credits = $_GET["credits"];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Review question 2
</title>
</head>
<body>
<h2>Does this work correctly?</h2>
<p>
<?php
if ($credits < 30) {
  print "You are a freshman<br />\n";
} else if ($credits < 90) {
  print "You are a junior<br />\n";
 } else if ($credits < 60) {
  print "You are a sophomore<br />\n";
 } else {
  print "You are a senior<br />\n";
 }
?>
</p>
</body>
</html>

http://csci1101sp10.morris.umn.edu/~elenam/1101_spring10/review1/if_else.php?credits=12

PHP loops

What will be printed by this loop when the input is 4?


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Loops review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/6/08
-->
<?php
$n = $_GET["input"];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Review question 2
</title>
</head>
<body>
<h2>What will be printed?</h2>
<p>
<?php
$m = 2;
for ($i = 0; $i < $n; $i++) {
  print "m = $m<br />\n";
  $m = $m * $m;
 }
?>
</p>
</body>
</html>

http://csci1101sp10.morris.umn.edu/~elenam/1101_spring10/review1/loops.php?input=4

PHP Arrays

Write a loop to print the array as specified in comments.


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Arrays review question
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 3/4/10
-->
<?php
$n = $_GET["input"];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
Arrays review
</title>
</head>
<body>
<h2>Write a loop to print the array as a one-row table</h2>
<?php
$months = array("January", "February", "March", "April");
?>

<h2>Write a loop to print the array as a one-column table</h2>
<?php

?>

</body>
</html>

http://csci1101sp10.morris.umn.edu/~elenam/1101_spring10/review1/array.php


UMM CSci 1101