Q1: 32 Pixels font size equals to how many em?
Answer:
Normally in browsers 1em is equal to 16 pixels.
So if we convert 32 pixels into em, we divide 32 by 16.
32 ÷ 16 = 2em
Therefore, 32 pixels equals 2em.
Q2: Write six characteristics of Dynamic URL.
Answer:
A Dynamic URL is a URL that changes according to user input or database content. Some common characteristics are:
- It contains a question mark (?).
- It contains an equal sign (=) to assign values.
- It may contain ampersand (&) to separate parameters.
- It sends parameters or variables to the server.
- It usually retrieves data from a database.
- It is generated using server-side scripting languages such as PHP or ASP.
Q3: How many parts does a URL have? Define each part.
Answer:
A URL normally has four main parts.
- Protocol
The protocol defines the method used to access the resource on the internet. Examples include HTTP, HTTPS, and FTP. - Domain Name
The domain name is the name of the website that identifies the web server. For example, vu.edu.pk. - Path
The path specifies the exact location of a page or file on the server. - Query String or Parameters
The query string is used to pass information or variables to the server in dynamic web pages.
Q4: Write small details of window.open(), window.close(), window.moveTo(), and window.resizeTo().
Answer:
window.open()
This function is used to open a new browser window or tab.
window.close()
This function is used to close the current browser window.
window.moveTo()
This function moves the browser window to a specific position on the computer screen.
window.resizeTo()
This function changes the size of the browser window.
Q5: Write about CSS Selectors.
Answer:
CSS selectors are used to select HTML elements so that styles can be applied to them.
Some common types of CSS selectors include:
- Element Selector – selects elements based on their HTML tag name such as paragraph or heading.
- Class Selector – selects elements that have a specific class attribute.
- ID Selector – selects a unique element that has a specific ID.
- Universal Selector – selects all elements in the document.
Selectors help developers apply styles efficiently to web pages.
Q6: Open and Close Window in JavaScript.
Answer:
In JavaScript, a new browser window can be opened using a function that creates a new window or tab.
Similarly, a window can be closed using another function that closes the current browser window.
These functions are commonly used to control browser windows during web interactions.
Q7: Write about GET and POST methods.
Answer:
GET Method
The GET method is used to request data from the server. The data is sent through the URL, so it is visible in the browser address bar. It is usually used for small amounts of data.
POST Method
The POST method is used to send data to the server. In this method, the data is not displayed in the URL, making it more secure. It is commonly used for sending large or sensitive data.
Q8: Enlist some drawbacks of JavaScript.
Answer:
Some disadvantages of JavaScript are:
- JavaScript code can be viewed by users in the browser.
- It may cause security issues if not handled properly.
- Different browsers may interpret JavaScript differently.
- Errors may occur on the client side.
- It is not suitable for very large and complex applications without additional technologies.
Q9: Name the selector used for selecting all h1 elements and the selector used for selecting elements with class “green”.
Answer:
To select all h1 elements, the Element Selector is used.
To select elements that have the class green, the Class Selector is used.
Q10: Write three different ways to use the border-color property in CSS.
Answer:
The border-color property in CSS is used to define the color of the border around an element.
Three different ways to use it are:
- A single color can be applied to all borders of an element.
- Two colors can be applied, where one color is used for the top and bottom borders and another for the left and right borders.
- Four different colors can be applied to the top, right, bottom, and left borders separately.
Q11: Some input fields and a JavaScript code were given. Describe their purpose.
Answer:
Input fields in a form are used to collect information from users, such as name, email, password, or other details.
The JavaScript code is usually used to process or validate the information entered by the user. For example, it may check whether the user has filled all required fields correctly before submitting the form.
Q12: Write the concept of creating an image element that redirects the user to vu.edu.pk when clicked.
Answer:
An image element can be used as a clickable link. When the user clicks the image, the browser redirects the user to another webpage. In this case, the image acts like a hyperlink and sends the user to the website vu.edu.pk.
Q13: Name four position properties in CSS.
Answer:
The four main position properties in CSS are:
- Static – This is the default position of elements in a webpage.
- Relative – The element is positioned relative to its normal position.
- Absolute – The element is positioned relative to its nearest positioned parent element.
- Fixed – The element stays fixed in one place on the screen even when the page is scrolled.