The document discusses CSS (Cascading Style Sheets) and how it can be used for web development. It covers some key points:
- CSS is used to define styles and layout of HTML elements. External style sheets allow changing appearance across pages by editing one file.
- CSS rules have selectors that point to HTML elements and declaration blocks with properties and values to style those elements. Common selectors include element, id, class, and grouping selectors.
- Styles can be defined internally, in an external .css file, or inline. The document demonstrates styling text colors, backgrounds, images, and alignment using CSS.
Learn HTML and CSS in few steps . Practice an hour daily for good results in 10 days.
Here I am mentioning basic elements , attributes and tags of HTML with styling them
Learn HTML and CSS in few steps . Practice an hour daily for good results in 10 days.
Here I am mentioning basic elements , attributes and tags of HTML with styling them
Seo is referred as Search Engine Optimization. It has basically four modules Search engine optimization (SEO), Social Media Optimization (SMO), Search Engine Marketing (SEM) and PPC.
We at SKY INFOTECH have a team of professionals dedicated towards SEO and we are also proving LIVE PROJECT TRAINING in SEO and PPC.
This PDF is all about Basic HTML meta tags which are mostly used in SEO on-page practices. These slides will really help students who really want to know about SEO. We provide SEO training in Noida at affordable price. For more information, visit the website.
What is HTML - An Introduction to HTML (Hypertext Markup Language)Ahsan Rahim
What is HTML?
HTML stands for "Hypertext Markup Language". A standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages.
Hypertext Markup Language is the standard markup language for creating the Web pages and Web Applications. With Cascading Style Sheets (CSS) & JavaScript for creating World Wide Web pages.
HTML is a computer language devised to allow website creation. These websites can then be viewed by anyone else connected to the Internet.
HTML is relatively easy to learn & it consists of a series of short codes typed into a text-file by the site author — these are the tags. The text is then saved as a html file, and viewed through a browser.
html example
html tutorial for beginners
html basics
html tutorial pdf
basic html page template
what is html
html tags
basic html tags list
1. 1 Introduction to HTML What is an HTML File? HTML stands for Hyper Text Markup Language An HTML file is a text file containing small markup tags The markup tags tell the Web browser how to display the page An HTML file must have an htm or html file extension An HTML file can be created using a simple text editor If you are running Windows, start Notepad. Type in the following text: <html> <head> <title>Title of page</title> </head> <body> This is my first homepage. <b>This text is bold</b> </body> </html> Save the file as "mypage.htm". Start your Internet browser. Select "Open" (or "Open Page") in the File menu of your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example "C:MyDocumentsmypage.htm". Click OK, and the browser will display the page. Example Explained The first tag in your HTML document is <html>. This tag tells your browser that this is the start of an HTML document. The last tag in your document is </html>. This tag tells your browser that this is the end of the HTML document. The text between the <head> tag and the </head> tag is header information. Header information is not displayed in the browser window. The text between the <title> tags is the title of your document. The title is displayed in your browser's caption. The text between the <body> tags is the text that will be displayed in your browser. The text between the <b> and </b> tags will be displayed in a bold font.
Seo is referred as Search Engine Optimization. It has basically four modules Search engine optimization (SEO), Social Media Optimization (SMO), Search Engine Marketing (SEM) and PPC.
We at SKY INFOTECH have a team of professionals dedicated towards SEO and we are also proving LIVE PROJECT TRAINING in SEO and PPC.
This PDF is all about Basic HTML meta tags which are mostly used in SEO on-page practices. These slides will really help students who really want to know about SEO. We provide SEO training in Noida at affordable price. For more information, visit the website.
What is HTML - An Introduction to HTML (Hypertext Markup Language)Ahsan Rahim
What is HTML?
HTML stands for "Hypertext Markup Language". A standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages.
Hypertext Markup Language is the standard markup language for creating the Web pages and Web Applications. With Cascading Style Sheets (CSS) & JavaScript for creating World Wide Web pages.
HTML is a computer language devised to allow website creation. These websites can then be viewed by anyone else connected to the Internet.
HTML is relatively easy to learn & it consists of a series of short codes typed into a text-file by the site author — these are the tags. The text is then saved as a html file, and viewed through a browser.
html example
html tutorial for beginners
html basics
html tutorial pdf
basic html page template
what is html
html tags
basic html tags list
1. 1 Introduction to HTML What is an HTML File? HTML stands for Hyper Text Markup Language An HTML file is a text file containing small markup tags The markup tags tell the Web browser how to display the page An HTML file must have an htm or html file extension An HTML file can be created using a simple text editor If you are running Windows, start Notepad. Type in the following text: <html> <head> <title>Title of page</title> </head> <body> This is my first homepage. <b>This text is bold</b> </body> </html> Save the file as "mypage.htm". Start your Internet browser. Select "Open" (or "Open Page") in the File menu of your browser. A dialog box will appear. Select "Browse" (or "Choose File") and locate the HTML file you just created - "mypage.htm" - select it and click "Open". Now you should see an address in the dialog box, for example "C:MyDocumentsmypage.htm". Click OK, and the browser will display the page. Example Explained The first tag in your HTML document is <html>. This tag tells your browser that this is the start of an HTML document. The last tag in your document is </html>. This tag tells your browser that this is the end of the HTML document. The text between the <head> tag and the </head> tag is header information. Header information is not displayed in the browser window. The text between the <title> tags is the title of your document. The title is displayed in your browser's caption. The text between the <body> tags is the text that will be displayed in your browser. The text between the <b> and </b> tags will be displayed in a bold font.
Cascading Style Sheets is a style sheet language used for specifying the presentation and styling of a document written in a markup language such as HTML or XML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
2. What is CSS?
• CSS stands for Cascading Style Sheets
• Styles define how to display HTML elements
• Styles were added to HTML 4.0 to solve a problem
• External Style Sheets can save a lot of work
• External Style Sheets are stored in CSS files
2Copyright - Anjan Mahanta
5. CSS Demo
CSS Style Sheet
• CSS saves a lot of work
• It defines how HTML
elements are to be displayed
• They are normally saved in
external .css files
• External style sheets enable
you to change the appearance
and layout of all the pages in a
Web site, just by editing one
single file
Copyright - Anjan Mahanta 5
6. CSS Syntax
A CSS rule set consists of a selector and a declaration block:
Copyright - Anjan Mahanta 6
• The selector points to the HTML element you want to style.
• The declaration block contains one or more declarations separated by
semicolons.
• Each declaration includes a property name and a value, separated by a colon.
7. CSS Example
• A CSS declaration always ends with a semicolon, and declaration groups
are surrounded by curly brackets:
Copyright - Anjan Mahanta 7
p {color:red;text-align:center;}
<!DOCTYPE html>
<html>
<head>
<style>
p {color:red; text-align:center;}
</style>
</head>
<body>
<p> Hello..!!</p>
<p> Welcome to IEI..</p>
</body>
</html>
Code:
Output:
8. CSS Comment
• Comments are used to explain your code.
• It may help you when you edit the source code at a later date.
• Comments are ignored by browsers.
• A CSS comment starts with /* and ends with */.
Copyright - Anjan Mahanta 8
Example :
/*This is a multiple
lines comment*/
p
{
color:red;
/*This is another comment*/
text-align:center;
}
9. CSS Selectors
• CSS selectors allow you to select and manipulate HTML
element(s).
• CSS selectors are used to "find" (or select) HTML elements
based on their :
– Id
– Classes
– Types
– Attributes
– values of attributes and much more.
Copyright - Anjan Mahanta 9
10. The element selector
• The element selector selects elements based on the element name.
• You can select all <p> elements on a page like this: (all <p> elements
will be center-aligned, with a red text color)
Copyright - Anjan Mahanta 10
<!DOCTYPE html>
<html>
<head>
<style>
p {color:red; text-align:center;}
</style>
</head>
<body>
<p> Hello..!!</p>
<p> Welcome to IEI..</p>
<p> Lampang, Thailand..</p>
</body>
</html>
Code:
Output:
11. The id Selector
• The id selector uses the id attribute of an HTML tag to find the
specific element.
• An id should be unique within a page, so you should use the id
selector when you want to find a single, unique element.
• To find an element with a specific id, write a hash character, followed
by the id of the element.
• The style rule below will be applied to the HTML element with
id="para1":
Copyright - Anjan Mahanta 11
13. The Class Selector
• The class selector finds elements with the specific class.
• The class selector uses the HTML class attribute.
• To find elements with a specific class, write a period character,
followed by the name of the class:
• In the example below, all HTML elements with class="center" will be
center-aligned:
Copyright - Anjan Mahanta 13
15. Grouping Selector
• In style sheets there are often elements with the same style.
• To minimize the code, you can group selectors.
• To group selectors, separate each selector with a comma.
Copyright - Anjan Mahanta 15
17. CSS How To .. ??
• There are three ways of inserting a style sheet:
– External style sheet
– Internal style sheet
– Inline style
Copyright - Anjan Mahanta 17
18. External Style Sheet
• An external style sheet is ideal when the style is applied to many pages.
• With an external style sheet, you can change the look of an entire Web site
by changing one file.
• Each page must link to the style sheet using the <link> tag. The <link> tag
goes inside the head section.
• An external style sheet can be written in any text editor.
• The file should not contain any html tags.
• The style sheet should be saved with a .css extension.
Copyright - Anjan Mahanta 18
19. External Style Sheet
Copyright - Anjan Mahanta 19
Example:
Create a CSS file save as, external.css
h1 {color:sienna;}
h2 {color:blue;}
p {color:red;}
Create a html file save as, External.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css"
href="external.css">
</head>
<body>
<h1> LCCT </h1>
<h2 > Hello..!!</h2>
<p> Welcome to IEI..</p>
<p> Lampang, Thailand..</p>
</body>
</html>
OUTPUT:
20. Internal Style Sheet
• An internal style sheet should be used when a single document has a
unique style.
• We define internal styles in the head section of an HTML page, by using the
<style> tag.
Copyright - Anjan Mahanta 20
<!DOCTYPE html>
<html>
<head>
<style>
p {color:red;}
</style>
</head>
<body>
<p> International Education Institute</p>
</body>
</html>
Example: OUTPUT:
21. Inline Styles
• To use inline styles you use the style attribute in the relevant tag.
• The style attribute can contain any CSS property.
Copyright - Anjan Mahanta 21
<!DOCTYPE html>
<html>
<body>
<p> International Education Institute</p>
<p style="color:blue";>Lampang Thailand</p>
</body>
</html>
Example:
OUTPUT:
22. CSS Background
• The background-color property specifies the background color of an
element.
• The background color of a page is defined in the body selector.
Copyright - Anjan Mahanta 22
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:#ffff00;}</style>
</head>
<body>
<h3>International Education Institute</h3>
<p>Lampang Thailand</p>
</body>
</html>
Example 1: OUTPUT:
23. CSS Background
Copyright - Anjan Mahanta 23
<!DOCTYPE html>
<html>
<head>
<style> h1{background-color:#ffff00;}</style>
<style> h3{background-color:#ff0022;}</style>
<style> div{background-color:#ffff77;}</style>
<style> p{background-color:#ffff33;}</style>
</head>
<body>
<h1> LCCT</h1>
<h3>International Education Institute</h3>
<div>
This is Div Element 1
<p>Lampang Thailand</p>
This is Div Element 2
</div>
</body>
</html>
Example 2:
OUTPUT:
24. CSS Background Image
Copyright - Anjan Mahanta 24
<!DOCTYPE html>
<html>
<head>
<style>
body {background-image:url("background1.jpg");}
</style>
</head>
<body>
<h1> Hello</h1>
</body>
</html>
Example: OUTPUT:
Note: Save an image as background1.jpg in the same folder as the html file
25. Background Image
Repeat Horizontally or Vertically
Copyright - Anjan Mahanta 25
<!DOCTYPE html>
<html>
<head>
<style>
body {background-image:url("background3.jpg");}
</style>
</head>
<body>
<h1> Hello</h1>
</body>
</html>
Example: OUTPUT:
Note: Save an image as background3.jpg in the same folder as the html file
By default, the background-image property repeats an image both horizontally and vertically.
Some images should be repeated only horizontally or vertically, or they will look strange, like this:
26. Background Image
Repeat Horizontally or Vertically
Copyright - Anjan Mahanta 26
<!DOCTYPE html>
<html>
<head>
<style>
body {background-image:url("background3.jpg");
background-repeat:repeat-x;}
</style>
</head>
<body>
<h1> Hello</h1>
</body>
</html>
Example: OUTPUT:
Note: Save an image as background3.jpg in the same folder as the html file
If the image is repeated only horizontally (repeat-x), the background will look better:
27. Background Image
Set position and no-repeat
Copyright - Anjan Mahanta 27
<!DOCTYPE html>
<html>
<head>
<style>
body
{background-image:url("Web.png");
background-repeat:no-repeat;}
</style>
</head>
<body>
<h1> Hello</h1>
</body>
</html>
Example: OUTPUT:
Note: Save an image as Web.png in the same folder as the html file
Showing the image only once is specified by the background-repeat property:
28. Background Image
Set position and no-repeat
Copyright - Anjan Mahanta 28
<!DOCTYPE html>
<html>
<head>
<style>
body
{background-image:url("Web.png");
background-repeat:no-repeat;
background-position: right top;
margin-right:200px;}
</style>
</head>
<body>
<h1> Hello</h1>
</body>
</html>
Example:
OUTPUT:
Note: Save an image as Web.png in the same folder as the html file
The position of the image is specified by the background-position property:
29. Background Image
Shorthand Property
Copyright - Anjan Mahanta 29
<!DOCTYPE html>
<html>
<head>
<style>
body
{background:#ffffff url("Web.png") no-repeat right top;
margin-right:200px;}
</style>
</head>
<body>
<h1> Hello</h1>
</body>
</html>
Example:
OUTPUT:
Note: Save an image as Web.png in the same folder as the html file
The position of the image is specified by the background-position property:
30. Text Color
Copyright - Anjan Mahanta 30
Example: OUTPUT:
• The color property is used to set the color of the text.
• With CSS, a color is most often specified by:
• a HEX value - like "#ff0000"
• an RGB value - like "rgb(255,0,0)"
• a color name - like "red"
<!DOCTYPE html>
<html>
<head>
<style>
body {color:red;}
h1 {color:#00ff00}
p.ex {color:rgb(0,0,255);}
</style>
</head>
<body>
<h1> Welcome..to</h1>
<p>International Education Institute</p>
<p class="ex"> Lampang Thailand</p>
</body>
</html>
31. Text Alignment
Copyright - Anjan Mahanta 31
OUTPUT:
• The text-align property is used to set the horizontal alignment of a text.
• Text can be centered, or aligned to the left or right, or justified.
32. Text Alignment
Copyright - Anjan Mahanta 32
CODE:
<!DOCTYPE html>
<html>
<head>
<style>
h1,h2 {text-align:center;}
p.date {text-align:right;}
p.main {text-align:justify);}
</style>
</head>
<body>
<h1> LCCT</h1>
<h2>International Education Institute</h2>
<p class="date"> April 17, 2014 </p>
<p class="main"> LCCT has been a greatly successful institution
over the time of <b>43 years </b>.We are proud to be one of the foremost
Vocational Colleges in Northern Thailand. We have served young
people in Northern Thailand with a variety of vocational programs
successfully developing to provide high <b>quality</b> education.</p>
</body>
</html>
33. Text Decoration
Copyright - Anjan Mahanta 33
OUTPUT:
• The text-decoration property is used to set or remove decorations from text.
• The text-decoration property is mostly used to remove underlines from links
for design purposes.
34. Text Decoration
Copyright - Anjan Mahanta 34
Code:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {text-decoration: overline;}
h2 {text-decoration: line-through;}
h3 {text-decoration: underline;}
a {text-decoration: none;}
</style>
</head>
<body>
<h1> LCCT</h1>
<h2> International Education Institute</h2>
<h3> Lampang, Thailand</h3>
<p> Link to our: <a href="http://www.lcct.ac.th"> LCCT Website </a></p>
</body>
</html>
35. Text Transformation
Copyright - Anjan Mahanta 35
Code:
• The text-transform property is used to specify uppercase and lowercase letters
in a text.
• It can be used to turn everything into uppercase or lowercase letters, or
capitalize the first letter of each word.
<!DOCTYPE html>
<html>
<head>
<style>
p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}
</style>
</head>
<body>
<p class="uppercase"> Welcome to Lampang</p>
<p class="lowercase"> Welcome to Lampang</p>
<p class="capitalize"> Welcome to Lampang</p>
</body>
</html>
Output:
36. Text Indent
Copyright - Anjan Mahanta 36
Code:
• The text-indent property is used to specify the indentation of the first line of a
text.
<!DOCTYPE html>
<html>
<head>
<style>
p {text-indent:50px;}
</style>
</head>
<body>
<p> We are now expanding to global quality education. All courses have proved popular
with students from all over Northern Thailand and students from other countries
giving them opportunities to develop language and vocational skills which meet the
needs of modern businesses. </p>
</body>
</html>
Output:
37. CSS Font
Copyright - Anjan Mahanta 37
• CSS font properties define the font family, boldness, size, and the style of a
text.
• In CSS, there are two types of font family names:
– generic family - a group of font families with a similar look (like "Serif" or "Monospace")
– font family - a specific font family (like "Times New Roman" or "Arial")
39. CSS Font Style
Copyright - Anjan Mahanta 39
• The font-style property is mostly used to specify italic text.
• This property has three values:
– normal - The text is shown normally
– italic - The text is shown in italics
– oblique - The text is "leaning" (oblique is very similar to italic, but less supported)
<!DOCTYPE html>
<html>
<head>
<style>
p.normal {font-style:normal;}
p.italic {font-style:italic;}
p.oblique {font-style: oblique;}
</style>
</head>
<body>
<p class="normal"> Welcome to LCCT..!!<p>
<p class="italic"> International Education Institute</p>
<p class="oblique"> Lampang, Thailand</p>
</body>
</html>
Output:
40. CSS Font Size
Copyright - Anjan Mahanta 40
• Setting the text size with pixels gives full control over the text size:
Output:
<!DOCTYPE html>
<html>
<head>
<style>
h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:20px;}
</style>
</head>
<body>
<h1> Welcome to LCCT..!!<h1>
<h2> International Education Institute</h2>
<p> Lampang, <b>Thailand</b></p>
</body>
</html>
Example:
41. All font properties in one declaration
Copyright - Anjan Mahanta 41
• This example demonstrates how to use the shorthand property for
setting all of the font properties in one declaration.
Output:Example:
<!DOCTYPE html>
<html>
<head>
<style>
p.ex1 {font: 40px arial, sans-serif;}
p.ex2 {font: italic bold 30px Georgia, Serif;}
p {font-size:20px;}
</style>
</head>
<body>
<p class="ex1"> Welcome to LCCT..!!<p>
<p class="ex2"> International Education Institute</p>
<p> Lampang, <b>Thailand</b></p>
</body>
</html>
42. CSS Links
Copyright - Anjan Mahanta 42
• Links can be styled with any CSS property (e.g. color, font-family, background, etc.).
• In addition, links can be styled differently depending on what state they are in.
• The four links states are:
– a:link - a normal, unvisited link
– a:visited - a link the user has visited
– a:hover - a link when the user mouses over it
– a:active - a link the moment it is clicked
<!DOCTYPE html>
<html>
<head>
<style>
a:link {color:#FF0000;} /*unvisited link*/
a:visited {color:#00FF00;} /*visited link*/
a:hover {color:#FF00FF;} /*mouse over link*/
a:active {color:#0000FF;} /*selected link*/
</style>
</head>
<body>
<p><a href="http://www.lcct.ac.th" target="_blank"> Visit LCCT Website </a></p>
</body>
</html>
Example:
43. CSS Links – Text Decoration
Copyright - Anjan Mahanta 43
• The text-decoration property is mostly used to remove underlines from links:
<!DOCTYPE html>
<html>
<head>
<style>
a:link {text-decoration: none;} /*unvisited link*/
a:visited {text-decoration:none;} /*visited link*/
a:hover {text-decoration:underline;} /*mouse over link*/
a:active {text-decoration:underline;} /*selected link*/
</style>
</head>
<body>
<p><a href="http://www.lcct.ac.th" target="_blank"> Visit LCCT Website </a></p>
</body>
</html>
Example:
44. CSS Links – Background Color
Copyright - Anjan Mahanta 44
• The background-color property specifies the background color for links:
<!DOCTYPE html>
<html>
<head>
<style>
a:link {background-color:#FFFFFF;} /*unvisited link*/
a:visited {background-color:#FFFF85;} /*visited link*/
a:hover {background-color:#FF704D;} /*mouse over link*/
a:active {background-color:#FF704D;} /*selected link*/
</style>
</head>
<body>
<p><a href="http://www.lcct.ac.th" target="_blank"> Visit LCCT Website </a></p>
</body>
</html>
Example:
45. Different Styles of Hyperlink
Copyright - Anjan Mahanta 45
Example Part I:
<!DOCTYPE html>
<html>
<head>
<style>
a.one:link {color:#ff0000;}
a.one:visited {color:#0000ff;}
a.one:hover {color:#ffcc00;}
a.two:link {color:#ff0000;}
a.two:visited {color:#0000ff;}
a.two:hover {font-size:150%;}
a.three:link {color:#ff0000;}
a.three:visited {color:#0000ff;}
a.three:hover {background:#66ff66;}
47. CSS List
Copyright - Anjan Mahanta 47
• The CSS list properties allow you to:
– Set different list item markers for ordered lists
– Set different list item markers for unordered lists
– Set an image as the list item marker
48. CSS List
Copyright - Anjan Mahanta 48
Example Part I
<!DOCTYPE html>
<html>
<head>
<style>
ul.a {list-style-type:circle;}
ul.b {list-style-type:square;}
ol.c {list-style-type:upper-roman;}
ol.d {list-style-type:lower-alpha;}
</style>
</head>
<body>
<p>Examples of Unordered Lists</p>
<ul class="a">
<li>Coffee</li>
<li>Tea</li>
<li>Cola</li>
</ul>
<ul class="b">
<li>Coffee</li>
<li>Tea</li>
<li>Cola</li>
</ul>
<p>Examples of Ordered Lists</p>
<ol class="c">
<li>Coffee</li>
<li>Tea</li>
<li>Cola</li>
</ol>
<ol class="d">
<li>Coffee</li>
<li>Tea</li>
<li>Cola</li>
</ol>
</body>
</html>
Example Part II
49. CSS Tables
Copyright - Anjan Mahanta 49
• The look of an HTML table can be greatly improved with CSS:
Example:
50. CSS Table Borders
Copyright - Anjan Mahanta 50
• To specify table borders in CSS, use the border property.
• The example below specifies a black border for table, th, and td elements:
Example: <!DOCTYPE html>
<html>
<head>
<style>
table,th,td {border: 1px solid black;}
</style>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Maliwan</td>
<td>16</td>
</tr>
<tr>
<td>Saengduan</td>
<td>17</td>
</tr>
</table>
</body>
</html>
Output:
51. CSS Border Collapse
Copyright - Anjan Mahanta 51
• The border-collapse property sets whether the table borders are collapsed into a
single border or separated:
Example:
<!DOCTYPE html>
<html>
<head>
<style>
table{border-collapse:collapse;}
table,th,td {border: 1px solid black;}
</style>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Maliwan</td>
<td>16</td>
</tr>
<tr>
<td>Saengduan</td>
<td>17</td>
</tr>
</table>
</body>
</html>
Output:
52. Table Width & Height
Copyright - Anjan Mahanta 52
• Width and height of a table is defined by the width and height
properties.
• The example below sets the width of the table to 100%, and the
height of the th elements to 50px:
Output:
56. Table Padding
Copyright - Anjan Mahanta 56
• To control the space between the border and content in a table, use the
padding property on td and th elements:
Output:
Example:
<!DOCTYPE html>
<html>
<head>
<style>
table,th,td {border: 1px solid black;}
td {padding:15px;}
</style>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
</tr>
<tr>
<td>Maliwan</td>
<td>16</td>
<td>Lampang</td>
</tr>
<tr>
<td>Saengduan</td>
<td>17</td>
<td>Chiangmai</td>
</tr>
</table>
</body>
</html>
57. Table Color
Copyright - Anjan Mahanta 57
• The example below specifies the color of the borders, and the text and
background color of th elements:
Output:
Example:
<tr>
<td>Maliwan</td>
<td>16</td>
<td>Lampang</td>
</tr>
<tr>
<td>Saengduan</td>
<td>17</td>
<td>Chiangmai</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
table,th,td {border: 1px solid green;}
th {background: green;
color:white;}
</style>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
</tr>
62. CSS Box Model
Copyright - Anjan Mahanta 62
• All HTML elements can be considered as boxes. In CSS, the term "box model" is used
when talking about design and layout.
• The CSS box model is essentially a box that wraps around HTML elements, and it
consists of: margins, borders, padding, and the actual content.
• The box model allows us to place a border around elements and space elements in
relation to other elements.
• The image below illustrates the box model:
63. CSS Box Model
Copyright - Anjan Mahanta 63
Explanation of the different parts:
• Margin - Clears an area around the border. The margin does not have a
background color, it is completely transparent
• Border - A border that goes around the padding and content. The border is
inherited from the color property of the box
• Padding - Clears an area around the content. The padding is affected by the
background color of the box
• Content - The content of the box, where text and images appear
The total width of the element in the example is 300px:
width:250px;
padding:10px;
border:5px solid gray;
margin:10px;
Let's do the math:
250px (width)
+ 20px (left + right padding)
+ 10px (left + right border)
+ 20px (left + right margin)
= 300px
64. CSS Box Model
Copyright - Anjan Mahanta 64
• Assume that we have only 250px of space. Let's make an element with a total
width of 250px:
Code:
<!DOCTYPE html>
<html>
<head>
<style>
div.example
{ width:220px;
padding: 10px;
border:5px solid red;
margin:0;}
</style>
</head>
<body>
<div class="example"> This is an example of css box</div>
</body>
</html>
Output
65. CSS Box Model
Copyright - Anjan Mahanta 65
• Assume that we have only 200px of space. Let's make an element with a total
height of 200px:
Total element height = height + top padding + bottom padding + top border + bottom border + top margin + bottom margin
Code: Output
<!DOCTYPE html>
<html>
<head>
<style>
div.example
{ height:170px;width:220px;
padding: 10px;
border:5px solid red;
margin:0;}
</style>
</head>
<body>
<div class="example"> This is an example of css box</div>
</body>
</html>
66. CSS Border
Copyright - Anjan Mahanta 66
• The CSS border properties allows to specify the style and color of an element's border.
• The border-style property specifies what kind of border to display.
Example:
68. CSS Border Width
Copyright - Anjan Mahanta 68
• The border-width property is used to set the width of the border.
• The width is set in pixels, or by using one of the three pre-defined values: thin, medium,
or thick.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
p.one {border-style:solid; border-width:5px;}
p.two {border-style:solid; border-width:medium;}
p.three {border-style:solid; border-width:1px;}
</style>
</head>
<body>
<p class="one"> First Example</p>
<p class="two"> Second Example</p>
<p class="three">Third Example</p>
</body>
</html>
Output:
69. CSS Border Color
Copyright - Anjan Mahanta 69
• The border-color property is used to set the color of the border.
• The color can be set by:
– name - specify a color name, like "red"
– RGB - specify a RGB value, like "rgb(255,0,0)"
– Hex - specify a hex value, like "#ff0000"
• We can also set the border color to "transparent"
Example: Output:
<!DOCTYPE html>
<html>
<head>
<style>
p.one {border-style: solid; border-color:red;}
p.two {border-style: solid; border-color:#98bf21;}
</style>
</head>
<body>
<p class="one"> A solid red border</p>
<p class="two"> A solid green border</p>
</body>
</html>
70. CSS Border Individual Sides
Copyright - Anjan Mahanta 70
• In CSS it is possible to specify different borders for different sides:
Example:
Output:
<!DOCTYLE html>
<html>
<head>
<style>
p
{
border-top-style:solid;
border-right-style:dotted;
border-bottom-style:solid;
border-left-style:dotted;
}
</style>
</head>
<body>
<p>Bordering Individual Sides</p>
</body>
</html>
71. CSS Border Individual Sides
Copyright - Anjan Mahanta 71
Example using single property:
Output:
<!DOCTYLE html>
<html>
<head>
<style>
p.one
{
border-top-style:solid;
border-right-style:dotted;
border-bottom-style:solid;
border-left-style:dotted;
}
p.two {border-style:solid dotted;}
</style>
</head>
<body>
<p class="one">Bordering Individual Sides</p>
<p class="two">Bordering Individual Sides Using Single Property</p>
</body>
</html>
72. CSS Border Short Hand Property
Copyright - Anjan Mahanta 72
Example: Output:
The border property is a shorthand for the following individual border properties:
•border-width
•border-style (required)
•border-color
<!DOCTYPE html>
<html>
<head>
<style>
p {border:3px solid red;}
</style>
</head>
<body>
<p> Border Using Short Hand Property </p>
</body>
</html>
73. CSS Outline
Copyright - Anjan Mahanta 73
• An outline is a line that is drawn around elements (outside the borders) to
make the element "stand out".
• However, the outline property is different from the border property.
• The outline is not a part of an element's dimensions; the element's total
width and height is not affected by the width of the outline.
75. CSS Margin
Copyright - Anjan Mahanta 75
• The margin clears an area around an element (outside the border).
• The margin does not have a background color, and is completely transparent.
• The top, right, bottom, and left margin can be changed independently using separate
properties.
• A shorthand margin property can also be used, to change all margins at once.
The margin property can have from one to four values.
margin:25px 50px 75px 100px;
top margin is 25px
right margin is 50px
bottom margin is 75px
left margin is 100px
margin:25px 50px 75px;
top margin is 25px
right and left margins are 50px
bottom margin is 75px
margin:25px 50px;
top and bottom margins are 25px
right and left margins are 50px
margin:25px;
all four margins are 25px
77. CSS Padding
Copyright - Anjan Mahanta 77
• The padding clears an area around the content (inside the border) of an element.
• The padding is affected by the background color of the element.
• The top, right, bottom, and left padding can be changed independently using
separate properties.
• A shorthand padding property can also be used, to change all paddings at once.
The padding property can have from one to four values.
padding:25px 50px 75px 100px;
top padding is 25px
right padding is 50px
bottom padding is 75px
left padding is 100px
padding:25px 50px 75px;
top padding is 25px
right and left paddings are 50px
bottom padding is 75px
padding:25px 50px;
top and bottom paddings are 25px
right and left paddings are 50px
padding:25px;
all four paddings are 25px
79. CSS Dimension – Height & Width
Copyright - Anjan Mahanta 79
• The CSS dimension properties allows to control the height and width of an element.
Example
<html>
<head>
<style>
p.dimension
{
background-color: yellow;
height:100px;
width:100px;
}
p.nodimension
{
background-color:green;
}
</style>
</head>
<body>
<p class="dimension"> With Dimension </p>
<p class="nodimension"> Without Dimension </p>
</body>
</html>
Output
80. CSS Display & Visibility
Copyright - Anjan Mahanta 80
• Hiding an element can be done by setting the display property to "none" or the
visibility property to "hidden".
• Visibility:hidden hides an element, but it will still take up the same space as before.
The element will be hidden, but still affect the layout.
• Display:none hides an element, and it will not take up any space. The element will
be hidden, and the page will be displayed as if the element is not there.
Example
Output
<!DOCTYPE html>
<html>
<head>
<style>
h4.display_none{display:none;}
h4.visibility_hidden{visibility:hidden;}
</style>
</head>
<body>
<h3> Welcome to LCCT...</h3>
<h4 class="display_none"> Welcome to LCCT..</h4>
<h4 class="visibility_hidden"> Lampang Thailand </h4>
<h3> Lampang Thailand</h3>
</body>
</html>
81. CSS Display – Block & Inline Element
Copyright - Anjan Mahanta 81
• A block element is an element that takes up the full width available, and has
a line break before and after it.
• Examples of block elements:
– <h1>
– <p>
– <div>
• An inline element only takes up as much width as necessary, and does not
force line breaks.
• Examples of inline elements:
– <span>
– <a>
82. CSS Display – Block & Inline Element
Copyright - Anjan Mahanta 82
• Changing How an Element is Displayed
• Changing an inline element to a block element, or vice versa, can be useful for
making the page look a specific way, and still follow web standards.
Example: Display Inline
<!DOCTYPE html>
<html>
<head>
<style>
li{display:inline;}
</style>
</head>
<body>
<p> Display the link list as horizontal menu </p>
<ul>
<li><a href="http://www.google.com" target="_blank">GOOGLE</a></li>
<li><a href="http://www.hotmail.com" target="_blank">HOTMAIL</a></li>
<li><a href="http://www,facebook.com"target="_blank">FACEBOOK</a></li>
</ul>
</body>
</html>
Output
83. CSS Display – Block & Inline Element
Copyright - Anjan Mahanta 83
Example: Display Block Output
<!DOCTYPE html>
<html>
<head>
<style>
span{display:block;}
</style>
</head>
<body>
<h2> LCCT </h2>
<span> Vocational College </span>
<span> Established in 1971 </span>
<h2> LIT </h2>
<span> Degree College </span>
<span> Established in 2003 </span>
</body>
</html>
84. CSS Positioning
Copyright - Anjan Mahanta 84
• The CSS positioning properties allow you to position an element. It can also place an
element behind another, and specify what should happen when an element's
content is too big.
• Elements can be positioned using the top, bottom, left, and right properties.
However, these properties will not work unless the position property is set first.
They also work differently depending on the positioning method.
• There are four different positioning methods.
– Static Positioning
• HTML elements are positioned static by default.
– Fixed Positioning
• An element with fixed position is positioned relative to the browser window.
– Relative Positioning
• A relative positioned element is positioned relative to its normal position.
– Absolute Positioning
• An absolute position element is positioned relative to the first parent element that has a position
other than static.
86. CSS Relative Positioning
Copyright - Anjan Mahanta 86
Example
Output<!DOCTYPE html>
<html>
<head>
<style>
p.relative1
{
position:relative;
left:-30px;
}
P.relative2
{
position:relative;
left:30px;
}
</style>
</head>
<body>
<p> This Paragraph doesn't have any Relative Position </p>
<p class="relative1"> This Paragraph is the Relative Example 1</p>
<p class="relative2"> This paragraph is the Relative Example 2</p>
</body>
</html>
88. Show Overflow in an element using scroll
Copyright - Anjan Mahanta 88
Example Part I
<!DOCTYPE html>
<html>
<head>
<style>
div.scroll
{
background-color: yellow;
width:100px; height:100px;
overflow:scroll;
}
div.hidden
{
background-color:blue;
width:100px; height:100px;
overflow:hidden;
}
div.auto
{
background-color:green;
width:100px; height:100px;
overflow:auto;
}
</style>
</head>
Output
89. Show Overflow in an element using scroll
Copyright - Anjan Mahanta 89
Example Part II
<body>
<p> Overflow Scroll </p>
<div class="scroll">You can use the overflow property when
you want to have better control of the layout.
The default value is visible. </div>
<p> Overflow Hidden </p>
<div class="hidden"> You can use the overflow property when
you want to have better control of the layout.
The default value is visible.</div>
<p> Overflow Auto </p>
<div class="auto"> You can use the overflow property when
you want to have better control of the layout.
The default value is visible.</div>
</body>
</html>
90. Changing Cursor on Mouse over
Copyright - Anjan Mahanta 90
Example
<!DOCTYPE html>
<html>
<body>
<p>Mouse over the words to change the cursor.</p>
<span style="cursor:auto">auto</span><br>
<span style="cursor:crosshair">crosshair</span><br>
<span style="cursor:default">default</span><br>
<span style="cursor:e-resize">e-resize</span><br>
<span style="cursor:help">help</span><br>
<span style="cursor:move">move</span><br>
<span style="cursor:n-resize">n-resize</span><br>
<span style="cursor:ne-resize">ne-resize</span><br>
<span style="cursor:nw-resize">nw-resize</span><br>
<span style="cursor:pointer">pointer</span><br>
<span style="cursor:progress">progress</span><br>
<span style="cursor:s-resize">s-resize</span><br>
<span style="cursor:se-resize">se-resize</span><br>
<span style="cursor:sw-resize">sw-resize</span><br>
<span style="cursor:text">text</span><br>
<span style="cursor:w-resize">w-resize</span><br>
<span style="cursor:wait">wait</span><br>
</body>
</html>
91. CSS Float
Copyright - Anjan Mahanta 91
• With CSS float, an element can be pushed to the left or right, allowing other
elements to wrap around it.
• Float is very often used for images, but it is also useful when working with layouts.
• Elements are floated horizontally, this means that an element can only be floated left
or right, not up or down.
Example If an image is floated to the right, a following text flows around it, to the left:
92. CSS Float
Copyright - Anjan Mahanta 92
Code
<!DOCTYPE html>
<html>
<head>
<style>
img { float:right;}
</style>
</head>
<body>
<h4> This is an example of Image with style Float:Right </h4>
<p> <img src="logocss.gif" width="95" height="84"/>
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>
</body>
</html>
Save a picture as, logocss.gif in
the same folder as at html file
93. CSS Float – Image gallery I
Copyright - Anjan Mahanta 93
Example
94. CSS Float – Image gallery I
Copyright - Anjan Mahanta 94
Code Part I
<!DOCTYPE html>
<html>
<head>
<style>
.thumbnail
{
float:left;
width:110px;
height:90px;
margin:5px;
}
</style>
</head>
100. CSS Float – Right, Border & Margin
Copyright - Anjan Mahanta 100
Code
<!DOCTYPE html>
<html>
<head>
<style>
img
{
float:right;
border:1px dotted black;
margin:0px 0px 15px 30px;
}
</style>
</head>
<body>
<h4> This is an example of Image with style Float:Right, Border & Margin </h4>
<p> <img src="logocss.gif" width="95" height="84"/>
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>
</body>
</html>
102. CSS Float – Right, Caption, Border & Margin
Copyright - Anjan Mahanta 102
Code Part I
<!DOCTYPE html>
<html>
<head>
<style>
div
{
float:right;
width:120px;
margin:0px 0px 15px 30px;
border:1px solid black;
padding:15px;
text-align: center;
}
</style>
</head>
<body>
<h4> This is an example of Image with style Float:Right,Caption, Border & Margin </h4>
<div>
<img src="logocss.gif" width="95" height="84" <br> CSS is Fun!
</div>
103. CSS Float – Right, Caption, Border & Margin
Copyright - Anjan Mahanta 103
Code Part II
<p>
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</p>
</body>
</html>
104. CSS Float
Copyright - Anjan Mahanta 104
First letter of the a paragraph floats to the left and style the letter
Example
105. CSS Float
Copyright - Anjan Mahanta 105
First letter of the a paragraph floats to the left and style the letter
Code
<!DOCTYPE html>
<html>
<head>
<style>
span
{
float:left;
width:0.7em;
font-size:400%;
font-family:algerian,courier;
line-height:80%;
}
</style>
</head>
<body>
<p>
<span>T</span>his is some text.
This is some text. This is some text.This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text.
</p>
</body>
</html>
106. CSS Float – Horizontal Menu
Copyright - Anjan Mahanta 106
Code<!DOCTYPE html>
<html>
<head>
<style>
ul
{
float:left;
width:100%;
padding:0;
margin:0;
line-style-type:none;
}
a
{
float:left;
width:6em;
text-decoration:none;
color:white;
background-color:purple;
padding:0.2em 0.6em;
border-right:1px solid white;
}
a:hover {background-color:#ff3300;}
li {display:inline;}
</style>
</head>
<body>
<ul>
<li><a href="#"> Link One </a></li>
<li><a href="#"> Link Two </a></li>
<li><a href="#"> Link Three </a></li>
<li><a href="#"> Link Four </a></li>
</ul>
<p>
Example of a Horizontal Menu
</p>
</body>
</html>
111. Aligning Block Elements
Center Aligning Using the margin Property
• Block elements can be center-aligned by setting the left and right
margins to "auto".
• Using margin:auto; will not work in IE8 and earlier, unless a !DOCTYPE
is declared.
• Center alignment has no effect is the width is 100%.
Copyright - Anjan Mahanta 111
112. Aligning Block Elements
Code
Copyright - Anjan Mahanta 112
<!DOCTYPE html>
<html>
<head>
<style>
.center
{
margin:auto;
width:70%;
background-color:gray;
color:white;
}
</style>
</head>
<body>
<div class="center">
<p>LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.</p>
<p>We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.</p>
</div>
</body>
</html>
113. Right & Left Align
Copyright - Anjan Mahanta 113
114. Right & Left Align
Copyright - Anjan Mahanta 114
<!DOCTYPE html>
<html>
<head>
<style>
.right
{
position:absolute;
right:0px;
width:300px;
background-color:gray;
color:white;
}
</style>
</head>
<body>
<div class="right">
<p>LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.</p>
<p>We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.</p>
</div>
</body>
</html>
Code
115. Crossbrowser Compatibility Issues
Copyright - Anjan Mahanta 115
• When aligning elements like this, it is always a good idea to predefine
margin and padding for the <body> element. This is to avoid visual
differences in different browsers.
<!DOCTYPE html>
<html>
<head>
<style>
body
{
margin:0;
padding:0;
}
.container
{
position:relative;
width:100%;
}
Code Part I
Output
116. Crossbrowser Compatibility Issues
Copyright - Anjan Mahanta 116
.right
{
position:absolute;
right:0px;
width:300px;
background-color:gray;
color:white;
}
</style>
</head>
<body>
<div class="container">
<div class="right">
<p>LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.</p>
<p>We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.</p>
</div>
</div>
</body>
</html>
Code Part II
117. CSS Combinators
Copyright - Anjan Mahanta 117
• A combinator is something that explains the relationship between the
selectors.
• A CSS selector can contain more than one simple selector. Between the
simple selectors, we can include a combinator.
• There are four different combinators in CSS3:
– descendant selector
– child selector
– adjacent sibling selector
– general sibling selector
118. Descendant Selector
Copyright - Anjan Mahanta 118
• The descendant selector matches all element that are descendants of a specified
element.
• The following example selects all <p> elements inside <div> elements:
<!DOCTYPE html>
<html>
<head>
<style>
div p
{
background-color:yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph1 in the div</p>
<p>Paragraph2 in the div</p>
</div>
<p>Paragraph3 outside the div</p>
<p>Paragraph4 outside the div</p>
</body>
</html>
Output
119. Child Selector
Copyright - Anjan Mahanta 119
• The child selector selects all elements that are the immediate children of a specified
element.
• The following example selects all <p> elements that are immediate children of a
<div> element:
Output
<!DOCTYPE html>
<html>
<head>
<style>
div>p
{
background-color:yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph1 in the div</p>
<p>Paragraph2 in the div</p>
</div>
<p>Paragraph3 outside the div</p>
<p>Paragraph4 outside the div</p>
</body>
</html>
120. Adjacent Sibling Selector
Copyright - Anjan Mahanta 120
• The adjacent sibling selector selects all elements that are the adjacent siblings of a specified
element.
• Sibling elements must have the same parent element, and "adjacent" means "immediately
following".
• The following example selects all <p> elements that are placed immediately after <div>
elements:
Output
<!DOCTYPE html>
<html>
<head>
<style>
div+p
{
background-color:yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph1 in the div</p>
<p>Paragraph2 in the div</p>
</div>
<p>Paragraph3 outside the div</p>
<p>Paragraph4 outside the div</p>
</body>
</html>
121. General Sibling Selector
Copyright - Anjan Mahanta 121
• The general sibling selector selects all elements that are siblings of a specified element.
• The following example selects all <p> elements that are siblings of <div> elements:
Output
<!DOCTYPE html>
<html>
<head>
<style>
div~p
{
background-color:yellow;
}
</style>
</head>
<body>
<div>
<p>Paragraph1 in the div</p>
<p>Paragraph2 in the div</p>
</div>
<p>Paragraph3 outside the div</p>
<p>Paragraph4 outside the div</p>
</body>
</html>
122. CSS Pseudo-classes
Copyright - Anjan Mahanta 122
• CSS pseudo-classes are used to add special effects to some selectors.
• Syntax
• The syntax of pseudo-classes:
– selector:pseudo-class {property:value;}
• CSS classes can also be used with pseudo-classes:
– selector.class:pseudo-class {property:value;}
• Types of Pseudo-classes
– The :first-child Pseudo-class
– The :lang Pseudo-class
– The :focus pseudo-class
123. CSS The :first-child Pseudo-class
Copyright - Anjan Mahanta 123
Example - I
<!DOCTYPE html>
<html>
<head>
<style>
p:first-child
{
color:blue;
}
</style>
</head>
<body>
<p> Hello.. How are you, today?</p>
<p> I'm doing fine, thanks..!!</p>
</body>
</html>
Output
124. CSS The :first-child Pseudo-class
Copyright - Anjan Mahanta 124
Example - II
<!DOCTYPE html>
<html>
<head>
<style>
p>i:first-child
{
color:blue;
}
</style>
</head>
<body>
<p> <i>Hello..</i>.. How are you, <i>today</i>?</p>
<p> I'm <i>doing</i> fine, <i>thanks</i>..!!</p>
</body>
</html>
Output
125. CSS The :first-child Pseudo-class
Copyright - Anjan Mahanta 125
Example - III
<!DOCTYPE html>
<html>
<head>
<style>
p:first-child i
{
color:blue;
}
</style>
</head>
<body>
<p> <i>Hello..</i>.. How are you, <i>today</i>?</p>
<p> I'm <i>doing</i> fine, <i>thanks</i>..!!</p>
</body>
</html>
Output
126. CSS The :lang Pseudo-class
Copyright - Anjan Mahanta 126
Example - III
<!DOCTYPE html>
<html>
<head>
<style>
q:lang(no)
{
quotes:"~" "~";
}
</style>
</head>
<body>
<p> Welcome to <q lang="no"> Lampang </q>,Thailand </p>
</body>
</html>
Output
127. CSS Pseudo-elements
Copyright - Anjan Mahanta 127
• CSS pseudo-elements are used to add special effects to some selectors.
Syntax
• The syntax of pseudo-elements:
– selector::pseudo-element {property:value;}
• CSS classes can also be used with pseudo-elements:
– selector.class::pseudo-element {property:value;}
• Types of Pseudo-classes
– The ::first-line Pseudo-element
– The ::first-letter Pseudo-element
– The ::before Pseudo-element
– The ::after Pseudo-element
128. The ::first-line Pseudo-element
Copyright - Anjan Mahanta 128
Example
<!DOCTYPE html>
<html>
<head>
<style>
p::first-line
{
color:red;
font-variant:small-caps;
}
</style>
</head>
<body>
<p> LCCT has been a greatly successful institution
over the time of 42 years.We are proud to be one of
the foremost Vocational Colleges in Northern Thailand.
</p>
</body>
</html>
Output
129. The ::first-letter Pseudo-element
Copyright - Anjan Mahanta 129
Example
<!DOCTYPE html>
<html>
<head>
<style>
p::first-letter
{
color:red;
font-size:xx-large;
}
</style>
</head>
<body>
<p> LCCT has been a greatly successful institution
over the time of 42 years.We are proud to be one of
the foremost Vocational Colleges in Northern Thailand.
</p>
</body>
</html>
Output
130. Multiple Pseudo-element
Copyright - Anjan Mahanta 130
Example
<!DOCTYPE html>
<html>
<head>
<style>
p::first-letter
{color:red;
font-size:xx-large;}
p::first-line
{color:blue;
font-variant:small-caps;}
</style>
</head>
<body>
<p> LCCT has been a greatly successful institution
over the time of 42 years.We are proud to be one of
the foremost Vocational Colleges in Northern Thailand.
</p>
</body>
</html>
Output
131. Before & After Pseudo-element
Copyright - Anjan Mahanta 131
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1::before {content:url(lcct_logo.gif);}
h2::after {content:url(web1.png);}
</style>
</head>
<body>
<h1> Welcome to LCCT ..!!</h1>
<h2>International Education Institute</h2>
</body>
</html>
Output
132. CSS Navigation Bar
Copyright - Anjan Mahanta 132
Example
A navigation bar needs standard HTML as a base.
In our examples we will build the navigation bar from a standard HTML list.
A navigation bar is basically a list of links, so using the <ul> and <li> elements makes
perfect sense:
Output
<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
</style>
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</body>
</html>
133. CSS Navigation Bar
Copyright - Anjan Mahanta
133
Example with border
Output
<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
a
{
display:block;
width:60px;
background-color:#dddddd;
}
</style>
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</body>
</html>
135. CSS Navigation Bar
Copyright - Anjan Mahanta 135
Example of horizontal navigation bar
Output
<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
li
{
display:inline;
} </style>
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</body>
</html>
136. CSS Navigation Bar
Copyright - Anjan Mahanta
136
Example of horizontal navigation bar with floating list items
Output
<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
li
{
float:left;
}
a
{
display:block;
width:60px;
background-color:#dddddd;
}
</style>
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</body>
</html>
137. CSS Navigation Bar
Copyright - Anjan Mahanta
137
Example of horizontal navigation bar with full style
<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
a:link, a:visited
{
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
width:120px;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover, a:active
{
background-color:#7A991A;
}
li
{
float:left;
}
</style>
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</body>
</html>
138. CSS Image Gallery
Copyright - Anjan Mahanta
138
• CSS can be used to create an image gallery.
Note: Save 8 pictures in a folder named image_gallery_1 (four pictures for thumbnails and
four pictures for enlargement) Give the name of the picture files as per the give example.
142. CSS Image Opacity/Transparency
Copyright - Anjan Mahanta
142
• IE9, Firefox, Chrome, Opera, and Safari use the property opacity for
transparency. The opacity property can take a value from 0.0 - 1.0. A
lower value makes the element more transparent.
• IE8 and earlier use filter:alpha(opacity=x). The x can take a value
from 0 - 100. A lower value makes the element more transparent.
• Example – I Transparent Image with Hover Effect
145. CSS Image Opacity/Transparency
Copyright - Anjan Mahanta
145
• Example – II Text in Transparent Box :: Code Part I ::
<!DOCTYPE html>
<html>
<head>
<style>
div.background
{
width:500px;
height:250px;
background:url(image_gallery_1/klematis_small.jpg)repeat;
border:2px solid black;
}
div.transbox
{
width:400px;
height:180px;
margin:30px 50px;
background-color: #ffffff;
border:1px solid black;
opacity:0.6;
filter:alpha(opacity=60);
}
146. CSS Image Opacity/Transparency
Copyright - Anjan Mahanta
146
• Example – II Text in Transparent Box :: Code Part II ::
div.transbox p
{
margin:30px 40px;
font-weight:bold;
color:#000000;
}
</style>
<body>
<div class="background">
<div class="transbox">
<p>LCCT has been a greatly successful institution over
the time of 42 years.We are proud to be one of the foremost
Vocational Colleges in Northern Thailand. </p>
</div>
</div>
</body>
</head>
</html>
147. CSS Image Sprites
Copyright - Anjan Mahanta
147
• An image sprite is a collection of images put into a single image.
• A web page with many images can take a long time to load and generates
multiple server requests.
• Using image sprites will reduce the number of server requests and save
bandwidth.
• Instead of using three separate images, we use this single image
(“nav_sprites.gif"):
151. CSS Attribute Selectors
Copyright - Anjan Mahanta
151
• It is possible to style HTML elements that have specific attributes, not just class and id.
• The [attribute] selector is used to select elements with the specified attribute.
• The following example selects all <a> elements with a target attribute:
<!DOCTYPE html>
<html>
<head>
<style>
a[target]
{
background-color:yellow;
}
</style>
</head>
<body>
<p> The links with an attribute gets an yellow background </p>
<a href="http://www.lcct.ac.th">LCCT</a>
<a href="http://www.lit.ac.th" target="_blank">LIT College</a>
<a href="http://www.google.com" target="_top">Search</a>
</body>
</html>
Output
152. CSS Attribute Selectors
Copyright - Anjan Mahanta
152
• The following example selects all <a> elements with a target attribute: _blank
<!DOCTYPE html>
<html>
<head>
<style>
a[target="_blank"]
{
background-color:yellow;
}
</style>
</head>
<body>
<p> The links with an attribute gets an yellow background </p>
<a href="http://www.lcct.ac.th">LCCT</a>
<a href="http://www.lit.ac.th" target="_blank">LIT College</a>
<a href="http://www.google.com" target="_top">Search</a>
</body>
</html>
Output
153. CSS Attribute Selectors
Copyright - Anjan Mahanta
153
• The following example gives yellow borders with image title “flower”
Output
<!DOCTYPE html>
<html>
<head>
<style>
[title~="flower"]
{
border: 5px solid yellow;
}
</style>
</head>
<body>
<p> All images with a flower title gets yellow border </p>
<img src="image_gallery_1/klematis.jpg" title="klematis flower" width="150" height="113">
<img src="image_gallery_1/img_flwr.gif" title="flower" width="224" height="162">
<img src="image_gallery_1/img_tree.gif" title="tree" width="200" height="358">
</body>
</html>
154. CSS Attribute Selectors
Copyright - Anjan Mahanta
154
• The [attribute|=value] selector is used to select elements with the specified attribute
starting with the specified value.
• The following example selects all elements with a class attribute value that begins with
"top":
• Note: The value has to be a whole word, either alone, like class="top", or followed by a
hyphen( - ), like class="top-text"!
Output<!DOCTYPE html>
<html>
<head>
<style>
[class|="top"]
{
background:yellow;
}
</style>
</head>
<body>
<h1 class="top-header"> Welcome to LCCT</h1>
<p class="top-text"> International Education Institute </p>
<p class="topcontent">Lampang, Thailand</p>
</body>
</html>
155. CSS Attribute Selectors
Copyright - Anjan Mahanta
155
• The [attribute^=value] selector is used to select elements whose attribute value begins
with a specified value.
• The following example selects all elements with a class attribute value that begins with
"top":
• Note: The value does not have to be a whole word!
Output
<!DOCTYPE html>
<html>
<head>
<style>
[class^="top“]
{
background:yellow;
}
</style>
</head>
<body>
<h1 class="top-header"> Welcome to LCCT</h1>
<p class="top-text"> International Education Institute </p>
<p class="topcontent">Lampang, Thailand</p>
</body>
</html>
156. CSS3 Borders
Copyright - Anjan Mahanta
156
• With CSS3, you can create rounded borders, add shadow to boxes, and use an
image as a border - without using a design program, like Photoshop.
• In this chapter you will learn about the following border properties:
– border-radius
– box-shadow
– border-image
The border-radius Property - Rounded Corners
<!DOCTYPE html>
<html>
<head>
<style>
div
{
border:2px solid gray;
padding:10px 40px;
background:#dddddd;
width:300px;
border-radius:25px;
}
</style>
</head>
<body>
<div> Hello..!! Welcome to LCCT.</div>
</body>
</html>
Output
160. CSS3 The Border Image Property
Copyright - Anjan Mahanta
160
The Border Image Property
</style>
</head>
<body>
<div id="round">Here, the image is tiled (repeated) to fill the area.</div>
<br>
<div id="stretch">Here, the image is stretched to fill the area.</div>
<p>Here is the image used:</p>
<img src="image_gallery_1/border.png"
</body>
</html>
161. CSS3 – Background Size Property
Copyright - Anjan Mahanta
161
• The background-size property specifies the size of the background image.
• Before CSS3, the background image size was determined by the actual size of the image.
In CSS3 it is possible to specify the size of the background image, which allows us to re-
use background images in different contexts.
OutputExample: 1
162. CSS3 – Background Size Property
Copyright - Anjan Mahanta
162
<!DOCTYPE html>
<html>
<head>
<style>
body
{
background: url("image_gallery_1/img_flwr.gif");
background-size:80px 60px;
background-repeat:no-repeat;
padding-top:40px;
}
</style>
</head>
<body>
<p> LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand. </p>
<p> Oridinal Image <img src="image_gallery_1/img_flwr.gif" alt="flowers"
width="224" height="162"></p>
</body>
</html>
Example: 1 CODE
163. CSS3 – Background Size Property
Copyright - Anjan Mahanta
163
• Example 2: Stretch the background image to completely fill the content area:
Output
164. CSS3 – Background Size Property
Copyright - Anjan Mahanta
164
Example: 2 CODE
<!DOCTYPE html>
<html>
<head>
<style>
body
{
background: url("image_gallery_1/img_flwr.gif");
background-size:100% 100%;
background-repeat:no-repeat;
}
</style>
</head>
<body>
<p> LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.
We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.</p>
</body>
</html>
165. CSS3 – Background Origin Property
Copyright - Anjan Mahanta
165
• The background-origin property specifies the positioning area of the
background images.
• The background image can be placed within the content-box, padding-box, or
border-box area.
166. CSS3 – Background Origin Property
Copyright - Anjan Mahanta
166
• Example : Position the background image within the content-box and border box:
167. CSS3 – Background Origin Property
Copyright - Anjan Mahanta
167
• Code : Position the background image within the content-box and border box:
<!DOCTYPE html>
<html>
<head>
<style>
div
{
border:1px solid black;
padding:35px;
background-image:url('image_gallery_1/smiley.jpg');
background-repeat:no-repeat;
background-position:left;
}
#div1
{
background-origin:border-box;
}
#div2
{
background-origin:content-box;
}
</style>
168. CSS3 – Background Origin Property
Copyright - Anjan Mahanta
168
• Code : Position the background image within the content-box and border box:
</head>
<body>
<p> Background-Origin Border Box</p>
<div id="div1"> LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.
We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.</div>
<p> Background-Origin Content Box</p>
<div id="div2"> LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.
We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.</div>
</body>
</html>
169. CSS3 – Multiple Backgrounds
Copyright - Anjan Mahanta
169
• Example : CSS3 allows you to use several background images for an element
170. CSS3 – Multiple Backgrounds
Copyright - Anjan Mahanta
170
• Example : Code
<!DOCTYPE html>
<html>
<head>
<style>
body
{
background:url('image_gallery_1/img_tree.gif'),
url('image_gallery_1/img_flwr.gif');
background-size:100% 100%;
background-repeat:no-repeat;
}
</style>
</head>
<body>
<p> LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.
We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.<p>
</body>
</html>
171. CSS3 – Text Shadow
Copyright - Anjan Mahanta
171
• In CSS3, the text-shadow property applies shadow to text.
<!DOCTYPE html>
<html>
<head>
<style>
h1
{
text-shadow: 5px 5px 5px #FF0000;
}
</style>
</head>
<body>
<h1> Text Shadow Effect </h1>
</body>
</html>
• Example : Code
Output
172. CSS3 – Word Wrapping
Copyright - Anjan Mahanta
172
• If a word is too long to fit within an area, it expands outside.
• In CSS3, the word-wrap property allows to force the text to wrap - even if it means
splitting it in the middle of a word.
• Example : Code
Output<!DOCTYPE html>
<html>
<head>
<style>
p
{
width:11em;
border:1px solid #000000;
word-wrap:break-word;
}
</style>
</head>
<body>
<p>
This paragraph contains a very
long word: thisisaveryveryveryveryveryverylongword.
The long word will break and wrap to the next line.
</p>
</body>
</html>
173. CSS3 – Multiple Columns
Copyright - Anjan Mahanta
173
• With CSS3, we can create multiple columns for laying out text - like in
newspapers!
• Multiple column has the following properties:
– column-count
– column-gap
– column-rule
Output
175. CSS3 – Multiple Columns
Copyright - Anjan Mahanta
175
• Example : Code – Part II
</head>
<body>
<h1>Pride in Excellence</h1>
<div class="newspaper">
LCCT has been a greatly successful institution over the time of 42 years.
We are proud to be one of the foremost Vocational Colleges in Northern Thailand.
We have served young people in Northern Thailand with a variety of vocational
programs successfully developing to provide high quality education.
We are now expanding to global quality education.
All courses have proved popular with students from all over Northern Thailand
and students from other countries giving them opportunities to develop language
and vocational skills which meet the needs of modern businesses.
</div>
</body>
</html>