Web Programming Using PHP
Web Programming Using PHP
MODULE 1
MAJLIS ARTS AND SCIENCE COLLEGE, PURAMANNUR
Ans: <style>
Ans: <body>
Ans:
CSS comment is placed inside<style> element and start with /* and end with */
Ans:
CSS Syntax
Each declaration includes a CSS property name and a value, separated by a colon.
Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded
by curly braces.
EXAMPLE:
p{
color: red;
text-align: center;
}
• p is a selector in CSS (it points to the HTML element you want to style: <p>).
• color is a property, and red is the property value
• text-align is a property, and center is the property value
A CSS style sheet is a collection of a number of style definitions, each style definition has two
main components
Declaration: Specifies how the selected element should be styled.Multiple declarations are
seperated by colon(;)
Property: Specfies the feature of the element to be affected. Eg: font-family,color etc.
Ans:
Ans:
They are loaded on the client’s browser as exactly they are stored on the web server.
User can only read the information but can’t do any modification or interact with the
information.
It is possible to change a portion of a web page without loading the entire web page.
An active web page is a page where the browser performs the logic instead of the server.
Example: when you've got a page where you're showing share prices, then you want it
to update e.g. every 5 seconds.
Ans:
or web browser
data
Ans:
Three Ways to Insert CSS
• External CSS
• Internal CSS
• Inline CSS
External CSS
External styles are defined within the <link> element, inside the <head> section of an HTML
page
Eg:
<html>
<head>
<link rel="stylesheet" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
mystyle.css"
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
An external style sheet can be written in any text editor, and must be saved with a .css
extension.
The external .css file should not contain any HTML tags
Internal CSS
An internal style sheet may be used if one single HTML page has a unique style.
The internal style is defined inside the <style> element, inside the head section.
Eg:
<html>
<head>
<style type=”text/css”>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Inline CSS
An inline style may be used to apply a unique style for a single element.
To use inline styles, add the style attribute to the relevant element. The style attribute can
contain any CSS property.
Example
Inline styles are defined within the "style" attribute of the relevant element:
<html>
<body>
<h1 style="color:blue;text-align:center;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
13. Describe how to apply CSS in tables with example.
Ans:
border-collapse
The border-collapse property sets whether the table borders should be collapsed into a single
border
border-collapse: collapse;
text-align
The text-align property sets the horizontal alignment (like left, right, or center) of the content in
<th> or <td>.
th {
text-align: center;
}
padding
To control the space between the border and the content in a table, use the padding property on
<td> and <th> elements.
th{padding:45px;}
border
• border-width
• border-style
• border-color
border: border-width border-style border-color;
border-color: Specifies the color of the border. Default value is the color of the text
eg:
<html>
<head>
<style type=”text/css”>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
14. How is CSS used to create an image gallery? Explain with example.
Ans:
Eg:
<html>
<head>
<style type=”text/css”>
.gallery {
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 180px;
}
div.gallery:hover
{
border: 1px solid #777;
}
div.gallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 15px;
text-align: center;
}
</style>
</head>
<body>
<div class="gallery">
<a target="_blank" href="img_5terre.jpg">
<img src="img_5terre.jpg" alt="Cinque Terre" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="gallery">
<a target="_blank" href="img_forest.jpg">
<img src="img_forest.jpg" alt="Forest" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="gallery">
<a target="_blank" href="img_lights.jpg">
<img src="img_lights.jpg" alt="Northern Lights" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="gallery">
<a target="_blank" href="img_mountains.jpg">
<img src="img_mountains.jpg" alt="Mountains" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</body>
</html>
Ans:
CSS selectors are used to "find" (or select) the HTML elements you want to style.
Five categories:
The element selector selects HTML elements based on the element name.
p{
text-align: center;
color: red;
}
Eg:
#para1
{
text-align: center;
color: red;
}
<p id=”para 1”>welcome</p>
The CSS class Selector
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the class name.
Eg:
.c
{
text-align: center;
color: red;
}
<p class="c ">this paragraph refers to two classes. </p>
The CSS Universal Selector
The universal selector (*) selects all HTML elements on the page.
*{
text-align: center;
color: blue;
}
The grouping selector selects all the HTML elements with the same style definitions.
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p{
text-align: center;
color: red;
}
Eg:
h1, h2, p {
text-align: center;
color: red;
}