Unit - 1 Question and Answer

 

1. Which tag is used to create a hyperlink in HTML?

A) <link>
B) <a>
C) <href>
D) <url>


2. Which HTML5 tag represents self-contained content, such as a blog post?

A) <section>
B) <article>
C) <aside>
D) <header>


3. What is the correct HTML tag for inserting an image?

A) <image>
B) <img>
C) <src>
D) <picture>


4. In HTML5, which tag is used for playing audio?

A) <music>
B) <sound>
C) <audio>
D) <mp3>


5. Which CSS property is used to change the background color of a webpage?

A) color
B) background-color
C) bgcolor
D) background


6. What is the correct way to apply an external CSS file?

A) <css src="style.css">
B) <stylesheet>style.css</stylesheet>
C) <link rel="stylesheet" href="style.css">
D) <style src="style.css">


7. Which CSS3 feature is used to create smooth changes between property values?

A) animation
B) transition
C) transform
D) shadow


8. Which of the following is not a semantic HTML5 tag?

A) <main>
B) <footer>
C) <div>
D) <section>


9. PHP code is enclosed between:

A) { }
B) <php> and </php>
C) <?php ?>
D) <!php>


10. In XAMPP, where should you save your PHP files to run them in the browser?

A) htdocs folder
B) www folder
C) html folder
D) php folder


11. Which of the following is a valid PHP variable name?

A) $1name
B) $name1
C) name$
D) @name


12. Which PHP data type represents true or false values?

A) Integer
B) Boolean
C) String
D) Float


13. What will be the output of the following PHP code?

$x = 10;
$y = 3; echo $x % $y;

A) 3
B) 1
C) 0
D) 10


14. Which PHP control structure is best used when you need to test multiple conditions against one variable?

A) if-else
B) for loop
C) switch
D) while


15. In CSS, which property is used to make the corners of a box rounded?

A) corner-radius
B) border-round
C) border-radius
D) round-corner


Answer Key:

  1. B

  2. B

  3. B

  4. C

  5. B

  6. C

  7. B

  8. C

  9. C

  10. A

  11. B

  12. B

  13. B

  14. C

  15. C


3–4 Marks Questions with Detailed Answers


Q1. Define HTML and list any four basic HTML tags with their purpose.

Answer:
HTML (HyperText Markup Language) is the standard language for creating and designing web pages. It uses tags to define elements on a webpage.
Basic HTML Tags:

  1. <h1>–<h6> → Headings (h1 is largest, h6 is smallest)

  2. <p> → Paragraph text

  3. <a> → Hyperlink to another page or resource

  4. <img> → Embeds images in the page


Q2. Explain the use of semantic HTML5 tags with examples.

Answer:
Semantic tags give meaning to web content, making it more understandable for browsers and search engines.
Examples:

  • <header> → Defines the top section or heading of a webpage.

  • <nav> → Defines a navigation menu.

  • <section> → Groups related content together.

  • <footer> → Contains bottom information like contact or copyright.
    Example:


<header><h1>My Website</h1></header> <nav><a href="#">Home</a></nav> <section><p>About us content...</p></section> <footer>© 2025</footer>

Q3. Differentiate between inline, internal, and external CSS with examples.

Answer:

  • Inline CSS: CSS inside the HTML tag using the style attribute.

    <p style="color: red;">Hello</p>
  • Internal CSS: CSS inside the <style> tag in the <head> section.

    <style>p {color: red;}</style>
  • External CSS: CSS stored in a .css file linked using <link>.

    <link rel="stylesheet" href="style.css">

Q4. List any four new features of CSS3.

Answer:

  1. Rounded Corners: border-radius: 10px;

  2. Box Shadows: box-shadow: 2px 2px 5px gray;

  3. Gradients: background: linear-gradient(to right, red, yellow);

  4. Transitions: transition: all 0.5s ease;


Q5. Explain the working of PHP in web development.

Answer:

  1. A user requests a PHP page via browser (client).

  2. The web server (Apache) identifies .php files.

  3. PHP interpreter executes the PHP code on the server.

  4. The output (HTML) is sent back to the browser.

  5. The browser displays the HTML page to the user.


Q6. Write the steps to install and test PHP using XAMPP.

Answer:

  1. Download and install XAMPP.

  2. Open XAMPP Control Panel and start Apache and MySQL.

  3. Save PHP files in the htdocs folder (e.g., C:\xampp\htdocs).

  4. Open browser and go to http://localhost/filename.php.

  5. If the output displays correctly, PHP is working.


Q7. Write a PHP program to check whether a number is even or odd.

Answer:

<?php
$num = 5; if ($num % 2 == 0) { echo "Even"; } else { echo "Odd"; } ?>

Explanation:

  • % (modulus) checks remainder.

  • If remainder = 0 → number is even; else odd.


Q8. List and explain any four PHP data types with examples.

Answer:

  1. String: Text data. $name = "John";

  2. Integer: Whole numbers. $age = 25;

  3. Float: Decimal numbers. $price = 19.99;

  4. Boolean: True/false values. $isActive = true;


Q9. Describe the types of PHP operators with examples.

Answer:

  1. Arithmetic: +, -, *, /, % → $a + $b

  2. Assignment: =, +=, -= → $a += 5

  3. Comparison: ==, ===, != → $a == $b

  4. Logical: &&, ||, ! → if($a && $b)


Q10. Write a PHP program to print numbers from 1 to 5 using a for loop.

Answer:

<?php
for ($i = 1; $i <= 5; $i++) { echo $i . "<br>"; } ?>

Explanation:

  • for loop runs from $i = 1 to $i = 5.

  • Prints each number with a line break.

Comments

Popular posts from this blog

Short overview on Unit-II

Short Overview on Unit - I