Web Design & Development Solved MCQs
Prepare with **100 Web Design and Development solved MCQs** for **B-17 / BS-17 computer-related posts**, including AJKPSC, PPSC, FPSC and other competitive exams. Questions cover **11 major chapters** with correct answers and short explanations.
Chapter 1: Internet, Web and Networking
1. Which protocol is mainly used to transfer web pages between a browser and web server?
A) FTP
B) SMTP
C) HTTP
D) DNS
Answer: C) HTTP
Explanation: HTTP transfers web resources.
2. Which component identifies the server in a URL?
A) Host
B) Path
C) Query
D) Fragment
Answer: A) Host
Explanation: Host identifies the web server.
3. What does DNS primarily translate?
A) Ports to protocols
B) Names to IP addresses
C) Files to URLs
D) Packets to frames
Answer: B) Names to IP addresses
Explanation: DNS resolves domain names.
4. Which DNS lookup converts an IP address into a hostname?
A) Forward lookup
B) Direct lookup
C) Generic lookup
D) Reverse lookup
Answer: D) Reverse lookup
Explanation: Reverse DNS resolves IP addresses.
5. Which protocol is commonly used to transfer files between computers?
A) HTTP
B) FTP
C) SMTP
D) POP3
Answer: B) FTP
Explanation: FTP transfers files.
6. How many separate connections does traditional FTP normally establish?
A) One
B) Two
C) Three
D) Four
Answer: B) Two
Explanation: FTP uses control and data connections.
7. Which protocol provides secure HTTP communication?
A) HTTPS
B) FTPS
C) SFTP
D) SSH
Answer: A) HTTPS
Explanation: HTTPS secures HTTP traffic.
8. Which port is normally associated with HTTPS?
A) 21
B) 25
C) 80
D) 443
Answer: D) 443
Explanation: HTTPS commonly uses port 443.
9. IPv4 addresses contain how many bits?
A) 16 bits
B) 32 bits
C) 64 bits
D) 128 bits
Answer: B) 32 bits
Explanation: IPv4 uses 32 bits.
10. Which device forwards packets between different networks?
A) Switch
B) Hub
C) Router
D) Repeater
Answer: C) Router
Explanation: Routers connect networks.
Chapter 2: HTML Fundamentals
11. What does HTML stand for?
A) Hyperlink Text Markup Language
B) Hyper Text Markup Language
C) High Text Machine Language
D) Hyper Transfer Markup Language
Answer: B) Hyper Text Markup Language
Explanation: HTML structures web pages.
12. Which element defines the largest standard HTML heading?
A) <h6>
B) <head>
C) <heading>
D) <h1>
Answer: D) <h1>
Explanation: <h1> is the largest heading.
13. Which HTML element creates a hyperlink?
A) <a>
B) <link>
C) <href>
D) <url>
Answer: A) <a>
Explanation: <a> creates links.
14. Which attribute specifies the destination of a hyperlink?
A) src
B) link
C) href
D) target
Answer: C) href
Explanation: href contains the URL.
15. Which HTML element inserts an image?
A) <picture>
B) <img>
C) <image>
D) <src>
Answer: B) <img>
Explanation: <img> embeds images.
16. Which attribute provides alternative text for an image?
A) title
B) name
C) alt
D) text
Answer: C) alt
Explanation: alt provides alternative text.
17. Which element creates an unordered list?
A) <ol>
B) <li>
C) <dl>
D) <ul>
Answer: D) <ul>
Explanation: <ul> creates unordered lists.
18. Which element defines an individual list item?
A) <li>
B) <item>
C) <list>
D) <ul>
Answer: A) <li>
Explanation: <li> defines list items.
19. Which HTML element creates a table row?
A) <td>
B) <tr>
C) <th>
D) <row>
Answer: B) <tr>
Explanation: <tr> defines table rows.
20. Which element defines a table header cell?
A) <thead>
B) <header>
C) <th>
D) <td>
Answer: C) <th>
Explanation: <th> creates header cells.
Chapter 3: HTML Forms and Multimedia
21. Which HTML element creates a form?
A) <input>
B) <form>
C) <fieldset>
D) <data>
Answer: B) <form>
Explanation: <form> contains form controls.
22. Which attribute specifies where form data is submitted?
A) action
B) method
C) target
D) submit
Answer: A) action
Explanation: action specifies the destination.
23. Which form method appends submitted data to the URL?
A) POST
B) SEND
C) GET
D) PUT
Answer: C) GET
Explanation: GET places data in the URL.
24. Which input type hides entered characters?
A) hidden
B) secure
C) password
D) protected
Answer: C) password
Explanation: Password fields mask characters.
25. Which input type allows selecting multiple independent choices?
A) radio
B) checkbox
C) select
D) option
Answer: B) checkbox
Explanation: Checkboxes allow multiple selections.
26. Which control normally allows one choice from a group?
A) Checkbox
B) Textbox
C) Radio button
D) List box
Answer: C) Radio button
Explanation: Radio buttons select one option.
27. Which HTML element embeds video content?
A) <movie>
B) <media>
C) <video>
D) <film>
Answer: C) <video>
Explanation: <video> embeds video.
28. Which HTML element embeds audio content?
A) <sound>
B) <music>
C) <audio>
D) <media>
Answer: C) <audio>
Explanation: <audio> embeds audio.
29. Which attribute makes an input field mandatory?
A) required
B) mandatory
C) validate
D) needed
Answer: A) required
Explanation: required prevents empty submission.
30. Which element groups related form controls?
A) <group>
B) <fieldset>
C) <section>
D) <formgroup>
Answer: B) <fieldset>
Explanation: <fieldset> groups controls.
Chapter 4: CSS
31. What does CSS stand for?
A) Computer Style Sheets
B) Cascading Style Sheets
C) Creative Style Syntax
D) Cascading System Sheets
Answer: B) Cascading Style Sheets
Explanation: CSS controls presentation.
32. Which CSS property changes text color?
A) font-color
B) text-color
C) color
D) foreground
Answer: C) color
Explanation: color sets text color.
33. Which property changes an element’s background color?
A) background-color
B) color-background
C) bgcolor
D) background-style
Answer: A) background-color
Explanation: It sets background color.
34. Which selector targets an element by its ID?
A) .
B) #
C) *
D) @
Answer: B) #
Explanation: # selects IDs.
35. Which selector targets elements by class?
A) #
B) @
C) .
D) :
Answer: C) .
Explanation: Dot selects classes.
36. Which CSS property controls the size of text?
A) font-size
B) text-size
C) font-height
D) character-size
Answer: A) font-size
Explanation: font-size sets text size.
37. Which property makes text bold?
A) font-style
B) text-weight
C) font-weight
D) font-bold
Answer: C) font-weight
Explanation: font-weight controls thickness.
38. Which property controls spacing between lines?
A) word-spacing
B) line-height
C) text-spacing
D) letter-spacing
Answer: B) line-height
Explanation: line-height controls line spacing.
39. Which CSS property aligns inline text horizontally?
A) align-text
B) text-align
C) horizontal-align
D) content-align
Answer: B) text-align
Explanation: text-align controls horizontal alignment.
40. Which CSS property controls space inside an element’s border?
A) margin
B) padding
C) spacing
D) inset
Answer: B) padding
Explanation: Padding is inside the border.
Chapter 5: CSS Layout and Responsive Design
41. Which CSS property controls space outside an element?
A) padding
B) border
C) margin
D) spacing
Answer: C) margin
Explanation: Margin creates outer space.
42. Which CSS layout system is designed for one-dimensional layouts?
A) Grid
B) Flexbox
C) Table
D) Float
Answer: B) Flexbox
Explanation: Flexbox handles one-dimensional layouts.
43. Which CSS layout system is designed for two-dimensional layouts?
A) Flexbox
B) Float
C) Grid
D) Inline
Answer: C) Grid
Explanation: Grid handles rows and columns.
44. Which property changes the positioning method of an element?
A) position
B) placement
C) location
D) layout
Answer: A) position
Explanation: position controls positioning.
45. Which position value keeps an element fixed relative to the viewport?
A) absolute
B) relative
C) fixed
D) static
Answer: C) fixed
Explanation: Fixed elements stay relative to viewport.
46. Which CSS rule is commonly used for responsive layouts?
A) @screen
B) @media
C) @responsive
D) @device
Answer: B) @media
Explanation: Media queries adapt layouts.
47. What does responsive web design primarily achieve?
A) Faster servers
B) Device-adaptive layouts
C) Larger databases
D) Automatic coding
Answer: B) Device-adaptive layouts
Explanation: Layout adapts to screen sizes.
48. Which CSS unit is relative to the root element’s font size?
A) em
B) rem
C) px
D) pt
Answer: B) rem
Explanation: rem uses root font size.
49. Which property controls whether an element is displayed?
A) visibility
B) display
C) opacity
D) show
Answer: B) display
Explanation: display controls rendering behavior.
50. Which value removes an element from the layout?
A) hidden
B) none
C) invisible
D) remove
Answer: B) none
Explanation: display: none removes layout space.
Chapter 6: JavaScript Fundamentals
51. Which language is primarily used to add client-side interactivity to web pages?
A) SQL
B) PHP
C) JavaScript
D) XML
Answer: C) JavaScript
Explanation: JavaScript adds browser interactivity.
52. Which object represents the browser window?
A) document
B) window
C) screen
D) browser
Answer: B) window
Explanation: window represents browser context.
53. Which method displays a dialog box with a message?
A) message()
B) alert()
C) display()
D) popup()
Answer: B) alert()
Explanation: alert() displays a message.
54. Which keyword declares a block-scoped variable that can be reassigned?
A) var
B) const
C) let
D) static
Answer: C) let
Explanation: let allows reassignment.
55. Which keyword declares a variable that cannot be reassigned?
A) fixed
B) const
C) final
D) static
Answer: B) const
Explanation: const prevents reassignment.
56. Which JavaScript data type represents true or false?
A) Boolean
B) Binary
C) Logical
D) Bit
Answer: A) Boolean
Explanation: Boolean stores true or false.
57. Which operator checks both value and data type?
A) ==
B) =
C) !=
D) ===
Answer: D) ===
Explanation: Strict equality checks both.
58. Which keyword defines a JavaScript function?
A) method
B) function
C) define
D) procedure
Answer: B) function
Explanation: function declares functions.
59. Which method writes content into the browser document?
A) document.write()
B) document.print()
C) page.write()
D) window.write()
Answer: A) document.write()
Explanation: It writes directly to document output.
60. Which JavaScript event occurs when a user clicks an element?
A) onload
B) onchange
C) onclick
D) onsubmit
Answer: C) onclick
Explanation: onclick responds to clicks.
Chapter 7: DOM and JavaScript Events
61. What does DOM stand for?
A) Document Object Model
B) Data Object Management
C) Document Order Method
D) Digital Object Model
Answer: A) Document Object Model
Explanation: DOM represents document structure.
62. Which method selects an element by its ID?
A) getElementById()
B) getElement()
C) selectById()
D) findElement()
Answer: A) getElementById()
Explanation: It selects a matching ID.
63. Which method selects the first element matching a CSS selector?
A) getElement()
B) querySelector()
C) selectFirst()
D) findSelector()
Answer: B) querySelector()
Explanation: It returns the first match.
64. Which event occurs after a web page finishes loading?
A) onclick
B) onchange
C) onload
D) oninput
Answer: C) onload
Explanation: onload fires after loading.
65. Which event occurs when a form is submitted?
A) onsubmit
B) onform
C) onsend
D) oninput
Answer: A) onsubmit
Explanation: onsubmit handles form submission.
66. Which event occurs when an input value changes?
A) onmodify
B) onchange
C) onedit
D) onvalue
Answer: B) onchange
Explanation: onchange detects value changes.
67. Which method adds an event handler to an element?
A) attachEvent()
B) addEventListener()
C) eventAdd()
D) registerEvent()
Answer: B) addEventListener()
Explanation: It registers event handlers.
68. Which property changes the HTML content of an element?
A) innerHTML
B) htmlText
C) contentHTML
D) elementHTML
Answer: A) innerHTML
Explanation: innerHTML reads or changes HTML.
69. Which property changes only the text content of an element?
A) innerText
B) textHTML
C) textValue
D) HTMLText
Answer: A) innerText
Explanation: innerText handles rendered text.
70. Which JavaScript object represents the HTML document?
A) page
B) browser
C) document
D) html
Answer: C) document
Explanation: document represents the page.
Chapter 8: XML and Web Data
71. What does XML stand for?
A) Extended Markup Language
B) Extensible Markup Language
C) External Markup Language
D) Executable Markup Language
Answer: B) Extensible Markup Language
Explanation: XML stores structured data.
72. Which document defines rules for valid XML structure?
A) HTML
B) CSS
C) DTD
D) HTTP
Answer: C) DTD
Explanation: DTD defines XML structure.
73. XML tags are enclosed within which characters?
A) ()
B) []
C) {}
D) <>
Answer: D) <>
Explanation: XML tags use angle brackets.
74. Which XML feature allows users to create their own tags?
A) Custom elements
B) User-defined tags
C) Flexible syntax
D) All of these
Answer: B) User-defined tags
Explanation: XML supports custom tags.
75. Which markup language is primarily designed for data representation?
A) HTML
B) CSS
C) XML
D) JavaScript
Answer: C) XML
Explanation: XML represents structured data.
76. Which format is commonly used for exchanging structured data in web applications?
A) JPEG
B) JSON
C) MP3
D) CSS
Answer: B) JSON
Explanation: JSON is widely used for data exchange.
77. Which symbol separates key and value in a JSON object?
A) =
B) :
C) =>
D) ;
Answer: B) :
Explanation: JSON uses colon separators.
78. Which symbols represent a JSON object?
A) []
B) ()
C) {}
D) <>
Answer: C) {}
Explanation: JSON objects use braces.
Chapter 9: Web Servers and Server-Side Development
79. What is the primary role of a web server?
A) Create hardware
B) Serve web resources
C) Design databases
D) Compile operating systems
Answer: B) Serve web resources
Explanation: Web servers deliver web content.
80. Which software is commonly used as a web server?
A) Apache
B) MySQL
C) Photoshop
D) Excel
Answer: A) Apache
Explanation: Apache is a web server.
81. Which technology executes code on the server?
A) Server-side scripting
B) CSS styling
C) HTML parsing
D) Client rendering
Answer: A) Server-side scripting
Explanation: Server-side code runs on servers.
82. What does PHP stand for?
A) Personal Home Page
B) Private Hypertext Processor
C) PHP Hypertext Preprocessor
D) Public HTML Processor
Answer: C) PHP Hypertext Preprocessor
Explanation: PHP is a server-side scripting language.
83. Which PHP symbol starts a variable name?
A) #
B) $
C) @
D) %
Answer: B) $
Explanation: PHP variables begin with $.
84. Which ASP technology is based on server-side web scripting?
A) Active Server Pages
B) Advanced Server Program
C) Application Service Pages
D) Active System Pages
Answer: A) Active Server Pages
Explanation: ASP means Active Server Pages.
85. Which ASP.NET feature sends a Web Forms page back to the server?
A) Redirect
B) Postback
C) Callback
D) Refresh
Answer: B) Postback
Explanation: Postback submits page events.
86. Which namespace contains the ASP.NET Web Forms Page class?
A) System.Web
B) System.Web.UI
C) System.Page
D) System.Web.Forms
Answer: B) System.Web.UI
Explanation: Page belongs to System.Web.UI.
Chapter 10: Databases and Web Applications
87. Which language is commonly used to query relational databases?
A) HTML
B) CSS
C) SQL
D) XML
Answer: C) SQL
Explanation: SQL manages relational data.
88. Which SQL command retrieves records?
A) INSERT
B) SELECT
C) UPDATE
D) DELETE
Answer: B) SELECT
Explanation: SELECT retrieves data.
89. Which SQL command adds new records?
A) CREATE
B) INSERT
C) ADD
D) APPEND
Answer: B) INSERT
Explanation: INSERT adds records.
90. Which database object uniquely identifies a table row?
A) Foreign key
B) Primary key
C) Index key
D) Candidate field
Answer: B) Primary key
Explanation: Primary keys uniquely identify rows.
Chapter 11: Cookies, Sessions and Web Security
91. Where are standard browser cookies primarily stored?
A) Web server
B) Browser
C) DNS server
D) Database server
Answer: B) Browser
Explanation: Cookies are stored client-side.
92. Which mechanism is commonly used to maintain user state on the server?
A) Session
B) Cache
C) DNS
D) Cookie
Answer: A) Session
Explanation: Sessions maintain server-side state.
93. Which attack injects malicious SQL through application input?
A) XSS
B) CSRF
C) SQL Injection
D) Session Hijacking
Answer: C) SQL Injection
Explanation: SQL injection manipulates database queries.
94. Which attack injects malicious scripts into web pages?
A) XSS
B) SQL Injection
C) CSRF
D) DNS Spoofing
Answer: A) XSS
Explanation: XSS injects executable scripts.
95. Which attack tricks a logged-in user into sending an unwanted request?
A) XSS
B) CSRF
C) SQL Injection
D) Brute Force
Answer: B) CSRF
Explanation: CSRF abuses authenticated sessions.
96. Which practice helps prevent SQL injection?
A) Larger cookies
B) Prepared statements
C) Longer URLs
D) More HTML
Answer: B) Prepared statements
Explanation: Prepared statements separate data from queries.
97. Which protocol encrypts data between browser and web server?
A) HTTP
B) FTP
C) HTTPS
D) SMTP
Answer: C) HTTPS
Explanation: HTTPS encrypts web traffic.
98. Which HTTP status code means “Not Found”?
A) 200
B) 301
C) 403
D) 404
Answer: D) 404
Explanation: 404 means resource not found.
99. Which HTTP status code indicates a successful request?
A) 200
B) 302
C) 404
D) 500
Answer: A) 200
Explanation: 200 indicates success.
100. Which HTTP status code indicates an internal server error?
A) 301
B) 400
C) 404
D) 500
Answer: D) 500
Explanation: 500 indicates server failure.
