Upload
lamkiet
View
229
Download
8
Embed Size (px)
Citation preview
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 1 - HTML
1. Internet
Internet គឺ��រត�� ប់�� រ�ងកុំ ព�ួ ទ័រ�ប់�នជុំវ ិញពិ ភពេ �ក�មរយ: Protocol TCP/IP
េដ ម� ីទំ �ក់ ទំ នង�� េផ�រធន�នឬ ឯក�រ េផ�រ�រ ជែជកកំ � ន� ។ ល។ �រ�� ប់ពី PC េ��ន់
Internet គឺេយ ង�ចេ�ប� �ស់ វ ិធី�េ�ច ន �� ស័យេ �េ ល�ក �មហ៊ុនផ � ល់ េស� Internet (ISP) ។
បច� ុប�ន�េនះ �ន� ក�មហ៊ុន�េ�ច នកំ ពុ ងផ�ល់េស� Internet េ�ក� ុង �ពះ ���ច� កកម � ុ�
�ក�មហ៊ុននី មួ យៗ�ន �បព័ន� និ ងវ ិធី ផ�ល់េស� Internet ខុ សៗ�� ចំ េ �ះតៃម�វ ិញ ក៏ ខុ ស�� ែដរ េ�យ
�ត�វ�នេគែបងែចកេ��មវ ិធី ៃនរេប�បទទួ ល េស� ឬគិតេ��ម េល ��ន ឬ�ក�� ប់េស� ។
ស� �ប់អ�កេ �បគិត�មចំ នួ ន Kilobyte, ឬគិត�េល��ន តៃម ��ន�ពខុ ស�� េ�ច នគួរសម ។
េដ ម� ីឲ� �ន�ព�យ� ស� លក� ុ ង�រសេ�ម ចចិត� និ ងេ�ជ សេរ សេស �របស �់ក�មហ៊ុន�
មួ យមកេ�បេ�ះ ស ូមពិ និត�េម ល េ� េលេស �េផ�ង ៗរបស �់ក�មហ៊ុននី មួ យៗ និ ងប�� បេច �កេទស
ខ�ះៗ�ក់ ទង ដល់�រេ�បេស� Internet របស �់ក�មហ៊ុន�ំងេ �ះ ។
វ ិធី��ស �ៃន�រផ�ល់ េស� Internet
េស� Internet �ត�វ�ន ផ�ល ែ់ច ក�យេ� យវ ិធី�េ�ច នរួម�ន:
- ែខ ��បអុបទិ ច
- ែខ �ទូរស័ព� (ែខ�ទូរស័ព�អ ចល័ត)
- េ�បអង់ែតន
- ែខ � Cable digital
- �មរយៈ wifi (�បព័ន� wireless)
- �មរយៈ Mobile Broad band (េ�ប�បព័ ន �ទូរស័ព �ចល័ត)
- �មរយៈ Lease line និ ង�មវ ិធី េ�ចនេ ទ�ត
�ក�មហ៊ុនខ�ះ �នផ�ល់វ ិធី េ�ច នែបបស��ប់អ�ក�វឲ��ចេ� ជ សេរ ស�នេ � �មេ សចក �ី
�ត�វ�រ ។ ចំ ែណ ក�ក �មហ៊ុនខ �ះេទ �ត�ន េរ�ប�ក�� ប់េស�រួច�េ�សច េ� យរួម�ន�ំង�រ
កំ ណត់តៃម� និ ងកំ ណត់ចំ នួ នៃន�រេ�ប��ស់េ��មតៃម �ែដ លេគ�ន េរ�បចំេហ យ ។ មុ នេ ពល
�វេស �� មួ យសូម ពិ និត�េម លប�� �ងេ��មៈ
* ចំ នួ ន Kilobyte ែដ លេយ ងទទួ ល�នេត�ត�វ�នេគគិត��រេ�បេ� យ�នកំ ណត់ ឬ�� ន
កំ ណត់ ។ ឧ� ហរណ៍ េបេគកំ ណត់ឲ�េយងចំ នួ ន 1500 Mb ឲ�េយ ងស� �ប់រយៈេពល ១ែខ េយង
�ំ �ច់ �ត�វេធ ��រគណ�មួ យពី ចំ នួ នែដ លេយ ងេ �ប��ស់ េតេ�ច ន ឬតិច�ងចំ នួ នកំ ណត់របស េ់គ
េ�ះែដរឬេទ េបសិន��រេ�ប��ស់ របស់េយងេ �ច ន�ងចំ នួ នែដ ល េគ�នកំ ណត់េ�ះ េយង
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 2 - HTML
�ំ �ច់ �ត�វេ�ជ សេរ សយក ក�� ប់េស� ឬេ �ជ សយក�រេ�បេ� យ�� ន កំ ណត់�ជំ នួ សវ ិញ េដ ម� ី
�រ�រ�រេ�ប េលសពី ចំ នួ នកំ ណត់ ។
�ន �ក �មហ៊ុន�េ�ច ន�ន កំ ពុ ងេធ � Promotion ផ�ល់េស� Internet �� ន កំ ណត់ �រេ�ប��ស់
�ប�ំែខ េ�យ�នប�� ុ ះតៃម ��៉ ង�ប មកេ � �តឹមែតេ��ម ៣៥ដុ �� រ ក� ុ១ែខ ចំ ែណ កេល ��នៃន
�រេ�ប��ស់វ ិញគឺចេ �� ះ 128kb/64kb (ទំ ហំេន ះ�ត�វយកមក ែចកនឹ ង៨ េ�ះេយងនឹ ង�នតួេលខ
េល��ន ពិត��កដមិ ន�ន ) ។
- 128kb៖8= 16kb (upload) (�ចតិចឬ េ�ច ន�ងេន ះ)
- 64kb៖8= 8kb (Download) (�ចតិចឬេ�ច ន�ងេន ះ)
េ�ះ�េល��នកំ ណត់េគ�ន �ក់ មកចំ នួ នបុ៉�� នក៏ េ�យ �នឹ ងមិ នពិតេទ េដ ម� ីឲ� ដឹ ងពី
ចំ នួ នពិត គឺ�ត�វែច កចំ នួ នេល��ន េ�ះ�មួយ ៨ េ� ះេយ ងនឹ ង�នតួេលខេ ល ��នមិ ន�ន ែត�
មិ នែម នស�ិតេ�ក� ុ ងក�មិតេល��ន ែដលេ យងែច កេឃញេ�ះ �ំង� ស�ង េឡយ គឺ�េឡង�ចុ ះេ�ច ន
�ង ឬតិច�ងេ�ះរកកំ ណត់មិ ន�ន េឡយ ។ េយងពិ �ក កំ ណត់� �នឹ ង�នេ ល ��ន មួ យេស �
�ន �ស់ ពី េ��ះ េល��នរបស់ Internet �� ស័យេល ក�� េ�ច ន�៉ ង�ស់ ។
�ងេ ��មេន ះគឺ��ក�មហ៊ុនផ�ល េ់ស� Internet
2. History of Internet
�រ�ប់កំេណ តដំបូងរបស់អុី នេធ េណត គឺេ�េដ មទសវត�ទី ៧០េ� យ�ក�ម�� ក់ �រ
��វ��វ គំេ�ង�ន់ ខ�ស់ស�តិេ�ក � ុង� កស ួង�រ�រ�តិរបស់ សហរដ��េមរ ិចែដល េយ ងេ�
�ត់� DARPA (Defense Advanced Research Projects Agency) ពី ដំបូងពួ កេគ��ន់ ែតសិក�
សុវត�ិ�ពបេច�កវ ិទ� ទំ �ក់ ទំ នងពី កុំ ព� ួ ទ័រមួយេទ�ត ែតបុ៉េ�� ះ។
២០ �� ំេ ��យមក អុី នេធ េណត�ត�វ� នេគ�� ប់�ប�� ញ Network សំ�ប់េ�ប�� ស់ែផ�ក
េ�� �កលវ ិទ�ល័យ និ ង �� ប័ន ��។ �រ�� ប់ប�� ញអុី នេ ធ េណត�ដំបូងគឺេ�ក� ុង
�បេទសបុ៉ែន�េ ��យមកក៏ �នព� ងី កទូ �ំពិ ភពេ �កែដ លេធ � េ�យ�� យេ��អុី នេធ េណតពិត
��កដមួ យ�នអ �កេ �ប��ស់ េ�ច ននិ ងល�ី សុះ �យ�សេពញពិ ភពេ � ក។
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 3 - HTML
3. �រ�បេ�ជន៏ៃន�រេ�ប���ស់អុីនេធ�េណត
- ��វ��វឯក�រ
េ�េល អុី ន េធ េណតផ� ុ កនូ វពត័�ន�េ�ច ន�គប់ែផ�ក�ំងអ ស់ ដូ ច�ឯក�រែដល�ក់ ទង េ�នឹ ងមុ ខ
វ �ិ� នី មួ យៗ�មឯ កេទសរបស់ អ�កសិ ក� ��វ��វ �ពិ េសស េ�េទ�ត�ក៏ ផ�ល់ ធន �ន�េ�ច នដូ ច�
Software សំ �ប់េ�យេយ ង Download េ� យបង់ លុយ ឬ Download េ�យឥតលុយ ។
ឯក �រេ� េល អុី នេធ េណត�នលក�ណះទូ លំទូ �យនិ ង�ក់ ចិត��ង ឯក�រែដលេ�ះពុ ម� េ�យ
�ក�ស់ េ��ះ េ�ះបី�អ�ក��វ��វេ�ទី �ក៏ េ� យ ក៏ �ច��វ��វ�នេពញ ២៤ េ�៉ ង េ�យែត
កុំ ព� ួ ទ័រេ� ះ�� ប់�មួ យ�បព័ ន�អុី នេធ េណត។
- កំ �ន� (Entertainment)
អុី នេធ េណតមិ ន�តឹមែតផ�ល់ ពត៏�នេ�យេយ ងបុ៉េ�� ះ េទែថម�ំ ង�ចេ�យេយ ងេលង Game
េ�យឥតគិតៃថ�ដូ ច� េលង អុ ក �ល់ �ត់ �ប�ំ ង �ន ម៉ូតូ ទស��យ �� ប់បទចំេរ�ង �� ប់វ ិទ� ុ
េម លឈុតខ�ះៗៃនែខ��ពយន� និ ង របូ�ព �សស់ �� ត់�េ�ច ន។ ល។
- េផ�រ�រ
�រ�� ប់ប�� ញអុី នេធ េណត �ចេ�យ េយងេផ�រ�រេ�មនុ ស �ជុំ វ ិញពិ ភព េ�កេ�យ��ន់ ែត
�� ល់ Email address របស់ អ�ក ែដលេយ ងេផ�រេ�។ បច� ុប�ន��រេផ�រ�ចេ�យ េយ ងេផ�រពី Email Address
មួ យេ� Email address មួ យេទ�តរឺេ�ទូរស័ ព�ៃដ។ Web Site បេង�ត Email Address េ�យឥតគិតបងៃថ�
�នដូ ច�ៈ
http://www.yahoo.com http://www.hotmail.com http://www.gmail.com http://www.mail.com
- �រពិ�ក� (Discussion)
អុី នេធ េណត�ចេ�យេ� កអ �ក េធ��រពិ�ក��មួយ�ប�ជនជុំ វ ិញពិ ភ ពេ� ក អំ ពី
ប�� អ�ី មួ យ េ�យ�រេ�ប��ស់ ប�� ញសង�មដូ ច�ៈ Facebook, twitter រឺក៏ Video Calling
(Skype) ។
- បំេរេស�កម�
េ��បេទសេជ�នេល�នអុី នេ ធ េណតជួយសំរួល�រ�រ�េ�ច នដូ ច��រេ�ប�� ស់នូ វ�បព័ន�
E_Commerce, Online Shopping, E_business, E_learning…... �ំ ងេនះ�ច�ត់បន�យ ក� ុង�រេធ� ដំ េណ រ
េ�យមេធ ��យ�មួ យ។
4. �ក�បេច�កេទស
- Web Browser គឺ�កម�វ ិធី សំ�ប់ប�� ញ Web Page
Internet Explorer Internet Explorer (IE) is a web browser from Microsoft. It was released in 1995 and is one of the most popular browsers today.
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 4 - HTML
Firefox Firefox is a web browser from Mozilla. It was released in 2004 and is one of the most popular browsers today.
Netscape Netscape was the first commercial web browser. Netscape was released in 1994, but gradually lost its popularity to Internet Explorer. The development of Netscape officially ended in February 2008.
Opera Opera is a free, fast, small, and standards-compliant web browser. Opera is the preferred browser for a number of small devices like mobile phones and hand-held computers.
Google Chrome Google Chrome is a free, open-source web browser developed by Google. It was released in 2008, and has grown to be one of the most popular browsers today.
Apple Safari Safari is the default web browser for Mac systems. Safari is known for its sleek design.
- Web site គឺ�អសយ�� ន (Address) ែដលស�ិតេ�េល Internet ឧ�ហរណ៏ http://www.usea.edu.kh
។ �ល់ Website �ំ ងអ ស់ កំ ណត់េ�យេ�ប ��ស់ �សយ�� នពិត��កដ �ត�វ�នេ�� Uniform
Resource Locator (URL) ។
Uniform Resource Locator (URL) គឺសំ េ�េ� េលទី �ំ ង (path) របស់ ឯក�រេ�េល �បព័ ន�
Internet ។ េ�េពលអ�កេ �ប ��ស់ ចង់ ចូ ល េ� Website �មួ យ រ ឺចងរក ឯក �រ�មួ យេ�េល Internet
េ� ះ�ត�វ�យ នូ វ Address (http://www.google.com/) ែដល Address េនះ េយ ងេ�� URL ។
scheme - defines the type of Internet service. The most common type is http host - defines the domain host (the default host for http is www) domain - defines the Internet domain name, like w3schools.com :port - defines the port number at the host (the default port number for http is 80) path - defines a path at the server (If omitted, the document must be stored at the root
directory of the web site) filename - defines the name of a document/resource
Common URL Schemes
The table below lists some common schemes:
Scheme Short for.... Which pages will the scheme be used for...
http HyperText Transfer Protocol
Common web pages starts with http://. Not encrypted
https Secure HyperText Transfer Protocol
Secure web pages. All information exchanged are encrypted
ftp File Transfer Protocol For downloading or uploading files to a
Server Name File Name
http://www.google.com/path/file.html Scheme Path
scheme://host.domain:port/path/filename
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 5 - HTML
website. Useful for domain maintenance
file A file on your computer
- Home Page គឺ� Page ែដលប�� ញដំបូងេគ េ�េពលែដ លេយ ង�យ Web site ។ �ទូ េ���
Page ដំបូងែដលប�� ញអំ ពី ពត័�ន សំ�ន់ ៗសំ �ប់េធ� េ�យ អ�ក��វ��វ�ន�រ�ប់�រម�ណ៏ និ ង
�ចចូ លេ��ន់ Page បន�ប�� ប់េទ�ត។
- Web Page គឺ� Page នី មួ យៗែដលស�ិតេ�ក� ុ ង Web Site ។ �� File ែដ ល�នេ�� ះនិ ង
extension �៉ ងច�ស �់ស់ សំ�ប់ផ� ុ កនូ វពត័�ន និ � យរួមេ ��េ�ប�ប�នេ�នឹ ងទំ ព័រ
នី មួ យៗេ�ក� ុ ងេស�វេ�។
- Web Server គឺ�កម�វ ិធី ែដលដំេណ រ�រេ�េល Server េដ ម� ីរង់ �ំទទួ លសំេណ រពី browser
និ ងផ�ល់លទ��ពេ� េ�យ browser វ ិញ។
- Intranet គឺ��រត�� ប់�� រ�ង កុំ ព� ូ ទ័រ�េ�ច ន�ម TCP/IP ែដ ល�នលក�ណ : �ឯកជន
- Internet Service Provider គឺ��ក�មហ ៊ុនសំ�ប់ផ�លេស�អុី នេធ ែណត។
- E-Mail មក ពី �ក �� Electronic Mail �នន័ យ�គឺ��រេអឡតិ�ត�និត។
- Host :គឺ�កុំ ព� ូរទ័រមួ យែដលេធ ��រត�� ប់�មួ យ�បព័ ន�អុី នេធ ែណត។
- File Transfer Protocol គឺ� Protocol េ�បសំ�ប់េផ�រ File េ� និ ង មករ�ង Client និ ង
Remote Server េ� យឆ�ង�ត់ប�� ញ Network មួ យេ�ប TCP/IT
- What is the World Wide Web? The Web is a network of computers all over the world. All the computers in the Web can communicate with each other. All the computers use a communication protocol called HTTP.
How does the WWW work?
Web information is stored in documents called web pages. Web pages are files stored on computers called web servers. Computers reading the web pages are called web clients. Web clients view the pages with a program called a web browser. Popular browsers are Internet Explorer and Firefox.
- What is a Domain Name គឺ� A domain name is a unique name for a web site ដូ ច�
usea.edu.kh, fbis.edu.kh, khmerweekend.com ។
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 6 - HTML
1. េត HTML គឺ�អ�ី្?
HTML គឺ��� សំ �ប់បេង�តេគហទំ ព័រ (Website) ។ HTML មកពី �ក � Hyper Text Markup
Language �មិ នែមន� �� Programming Language េទ ែត���� Markup Language ។ Markup
Language គឺ�សំនុំ ៃន Markup Tags េហ យែដល HTML េ�ប ��ស់ markup tags េដ ម�ីក�ងេគហទំ ព័រ
េហយេធ ��រប�� ញេ �យ Web Browser ។ Web page េកតេឡងេ� យទំ �កទំ នងរ�ង Page
�េ�ច ន Link េ� វ ិញេ� មកសំ�ប់ប�� ញ Contents ។ HTML ���មួ យែដ ល �យ�ស� ល
ក� ុ ង�រសិក� និ ង េ�ប��ស់ ។
2. HTML Syntax and Rules
2.1 អ�ី� HTML Tag?
HTML Tag ឬ HTML Markup គឺ�កំរង�ក� (keywords) ែដលរុ ំព័ ទ�េ �យ angle brackets “<”
និ ង “>” ។
ឧ�ហរណ៏ <html>,<head>,<body> …..
Tag �នពីរ�បេភទ គឺ
- Empty tag : �នែត tag �ប់េផ� មពុំ �ន tag ប�� ប់េទ
ឧ�ហរណ៏ : <br />, <hr />, <img />...
Tip: In XHTML, all elements must be closed. Adding a slash inside the start tag, like <br />, is
the proper way of closing empty elements in XHTML (and XML).
- Containers tag � tag េពញេលញែដ ល�ន tag �ប់េផ� ម និ ង ប�� ប់
ឧ�ហរណ៏ ៈ <p> This is a paragraph </p>
- <p> tag �ប់េផ� ម
- </p> tag ប�� ប់
Tip: េ�ប��ស អ់ក�រតូចសំ�ប់ Tags
HTML tags មិ ន�ប�ន់ តួអក�រេទ : <P> �នន័ យ េស � <p>។ web sites �គេ�ច នគឺេ�ប��ស់
HTML tags អក�រធំ។ េយ ងគួរែតេ�ប��ស់ tag អក �រតូច េ��ះ World Wide Web Consortium (W3C)
�នផ �ល់អនុ ��ស �េ �យេ�បអក �រតូចក� ុ ង HTML 4, េហយក៏ � ម�រេ�យេ�ប tag អក�រតូច ក� ុ ង
XHTML ។
2.2 លក �ណៈរបស់ tag (Attribute)
Attribute �ស �តិែតេ�ក� ុ ង Empty ឬ Beginning tag(Start tag) ែតបុ៉េ�� ះ ។ �គប់�បេភទរបស់
tag សុទ �ែត�ន លក �ណ ៈ (attribute) េដ ម� ីេធ��រែកតំរូវ�ទង់ ��យ �មតំរូវ�រែដល េគចង់ �ន។
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 7 - HTML
ឧ�ហរណ៏ <a href="http://www.usea.edu.kh/"> USEA Website </a>
name = “value”
Tip: េ�ប��ស អ់ក�រតូចសំ�ប់ Attributes
Attribute គឺ�និ ច��លមក �ពម�� រ�ង name និ ង value
Attribute names and attribute values are មិ ន�ប�ន់ តួអក�រ . However, the World Wide
Web Consortium (W3C) �នផ �ល់ អនុ �សន៍ េ�យេ�ប� �ស់ អក �រតូចសំ�ប់ attributes និ ង
attribute values ក� ុ ង HTML 4 ។
Attribute Values ស�ិតក� ុ ង Quote
2.3 Element Content: ចំ �ច់ �ត�វែត�ន start tag និ ង ending tag ។ ព ត៌�នេ�ចេ �� ះ tag
�ំងពី រេយងេ�� Element Content ។
Ex:
3. �រ�ប់េផ� មសរេសរកូដ�� HTML
�� HTML េគសរេសរេ�ក� ុ ង Text Editor ដូ ច� Notepad , Wordpad, ConTEXT … ។
Text Editor ែដលេគចូ លចិត�េ�ប និ ង �ន�ព�យ�ស � លគឺ Notepad ។ េយ ងក៏ �ច
ក�ង េគហទ័ ព�ម Web Editor ែដល�ន�ព�យ� ស� លេ��ះ �� ន Tool ��ប់ៗេ�យមិ ន
�ំ �ច់ ចង�ំកូ ដ េ� ះេទ Web Editor �នដូ ច� Microsoft Frontpage, Macromedia Dreamweaver
and Visual Studio …..
រេប�បេបកក ម�វ ិធី Notepad
ចុ ច Start Programs Accessories Notepad
<tag syntax: name = “value”> ………………..........……………............…….</tag>
<b> This is text Bold </b> Element Content
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 8 - HTML
សរេសរ�� HTML �ម កម �វ ិធី ConTEXT Editor (http://www.contexteditor.org/)
រេប�បរក�ឯក�រថ�ី េដ ម� ី ប�� ញេ ល Browser
េ�ក� ុង Program Notepad or ConTEXT ចុ ចFile ចុចេល Save As
- េ�ជ ស េរ សទី �ំងសំ�ប់េ�យ File ស�ិតេ�
- េ� ក� ុង�បអប់ File Name: �យេ�� ះ File និ ង extension .html ឬ .htm
ឧ �ហរណ៏ index.html
- ចុ ច Save
ប�� ញ web page េល Browser
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 9 - HTML
4. Structure of HTML
<html> គឺ� Tag ដំបួងែដលេយ ងេ�ប��ស់ េ� ក� ុ ង HTML Document ។ �គប់ HTML
Document �ត�វ�ប់េផ� មេ�យ <html> និ ងប�� ប់េ�យ </html>
<head> section �កែន�ងសំ�ប់ ផ� ុ កចំ ណងេជ ងៃន Page និ ងបេង�តទំ �ក់ ទំ នងរ�ង HTML
Document និ ង file ដូ ច� Script និ ង CSS ។ ��ប់េផ� មេ�យ <head> និ ង ប�� ប់េ�យ
</head>
ឧ�ហរណ៍ ៈ <link href=”main.css” rel=”stylesheet” type=”text/css” /> សំ �ប់�� ប់ េ��ន់
Stylesheet �ងេ��។
<body> section �ែផ�កខ� ួ នៃន HTML Document សំ�ប់ផ� ុក នូ វៈ
- អត�បទ (text)
- Link
- របូ�ព picture,
- វ ីេដអូ (video)
- ចំ េរ�ង (mp3) .......។
<html> <head> ...... ...... ...... ...... ...... ...... .................................. </head> <body> ...... ...... ...... ...... ...... ...... ................................... </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 10 - HTML
1. �របេង�ត អត�បទ HTML
1.1 �រេ�ប��ស់ Header
ក� ុ ង HTML េយ ង�ច�ក់ ចំ ណង�ន ៦�៉ ងគឺ <hn> ែដល n �នតំៃល�ប់ពី ១ ដល់ ៦
n: �ន់ ែតតូច អត�បទ�ន់ ែតធំ
ឧ�ហរណ៌ ៈ
ចំ �ំ : Browsers automatically add some empty space (a margin) before and after each heading.
1.2 �រេ�ប��ស់ Paragraph
�ធម��េ�ក� ុ ងអត�បទ���អង់ េគ�សេគែចក េចញ� paragraph ែដ ល �នន័ យ���
ែខ�រ� ក�ខ័ណ� ចំ ែណកឯ េ�ក� ុង�� HTML វ ិញ ក៏ អនុ �� តេ�យេ យ ងែបងែច កអត�បទ
េ�េល website � paragraph �នផ ងែ ដរេ�យេ �ប��ស់ tag <p> ។
Syntax: <p align=”left | right | center | justify”> ……………………..</p>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Untitled Document</title>
</head> <body>
<h1>Welcome to Study HTML</h1>
<h2>Welcome to Study HTML</h2>
<h3>Welcome to Study HTML</h3>
<h4>Welcome to Study HTML</h4>
<h5>Welcome to Study HTML</h5>
<h6>Welcome to Study HTML</h6>
</body> </html>
Syntax: <hn align=”left | right | center”> ………………………..</hn>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 11 - HTML
ឧ�ហរណ៌ ៈ
1.3 �រចុះេដ មប�� ត់
<br /> េយ ងេ�បសំ�ប់ចុះប�� ត់េ�ក� ុ ងអត�បទ។ េពលសរេសរអត�បទេ�កែ ន�ង HTML
Code រួចចុ ះប�� ត់ែតម�ងេ�ះពុំ �នឥទ �ិ ពលេ �េព លប�� ញេ �ះ េទ េ��ះ Web Browser េធ ��របក
ែ�បអត�បទេ�យមិ នគិត�រចុះប�� ត់េទ�នឹ ងប�� ញអត�បទបន�ប�� ប់។
ឧ�ហរណ៏
<nobr> Tag
<nobr>...............</nobr> �មិ នអ នុ �� តិេ�យ ចុ ះប�� ត់េ�ះបី��បែវង អត�បទរបស់
េយងែវង��បែវងរប ស់ Window ក៏ េ� យ ។
1.4 �រគូសប�� ត ់
េដ ម�ីគូសប�� ត់េដកេយ ងេ�ប��ស់ <hr /> tag
Attributes របស់ <hr /> tag
- align = “left | right | center”
- size = “x” ែដល x គឺ�កំ �ស់ប�� ត់ គិត� pixel
- width = “y” ែដ ល y គឺ��បែវងប�� ត់ គិត� pixel រឺ �គរយ (%)
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Break line test</title>
</head> <body> Welcome to Study HTML<br/> Welcome to Study HTML </body> </html>
<html> <head> <title>Using Paragraph</title> </head> <body> <h1>C# Coding Standards and Best Programming Practices</h1> <p> If you have a team of different skills and tastes, you are going to have a tough time convincing everyone to follow the same standards. The best approach is to have a team meeting and developing your own standards document. You may use this document as a template to prepare your own document. </p>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 12 - HTML
- color = “color_name” | “color_code” េ�បសំ�ប់�ក់ ពណ៌ េ�យប�� ត់
Ex: <hr size=”10” width=”50%” color=”blue” align=”right” />
Note: �បែវងប�� ត់ Default របស់ �េស � នឹ ង�បែវង paragraph(គិត� pixel ឬ % េ�យេ�ប�បេធ�ប
�មួ យ�បែវង Window)
1.5 �រេ�ប��ស់ PREFORMATTED TEXT(PRE)
<pre>………………</pre> េ�បសំ�ប់េរ�បចំ ទំ ព័រៃនអត�បទ�ម HTML file ។ េ�េពលែដល
browser ជួប�បទះ tag េនះ �បកែ�បអត�បទេ�យរក�នូ វ�ពេដមដ៏ ែដល។
ឧ�ហរណ៍
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Using PRE Tag</title>
</head> <body> <h1>Using PRE TAG</h1> <pre> =============== =============== == == == == == =============== =============== </pre> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 13 - HTML
1.6 �រេ�ប��ស់ Center
� tag សំ �ប់កំ នត់ Element content របស់ �េ� យេ �ចំ ក�� លទំ ព័រ
ឧ�ហរណ៌ ៈ <center> this paragraph is center on web page </center>
1.7 �រេ�ប��ស់ ដក�� (space)
�មួយ�� HTML េយ ងមិ ន�� ស់ប� ូរ�រប�� ញេ�េល browser េ� យបែន�ម ដក��
(Space) េ� យេ�ច ន �នេឡយ។ browser និ ងលុប Space �េ�ច នេ �យទុ កែត ១ space េ�
េពលប�� ញ។ េដ ម� ីេ�យ browser �� ល់�រដក�� (space) េ�ច នេ យង�ត�វេ�ប HTML Entity:
“ ” ។
1.8 HTML Comments
Comment �ត�វ�នប�� ូ លក� ុ ង HTML Code េដ ម�ី�យ�ស� ល�ន និ ង យល់ ។ Comment
មិ ន�ត�វ�ន web browser េធ ��របកែ�ប និ ង ប�� ញេល browser េទ។
ឧទហរណ៌ ៈ <!-- This is a comment -->
1.9 �រេ�ប��ស់ HTML Text Formatting
HTML Text Formatting Tags
Tag Description
<b> Defines bold text
<big> Defines big text
<em> Defines emphasized text
<i> Defines italic text
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Using Space Tag</title>
</head> <body> <h1> I am </h1> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 14 - HTML
HTML "Computer Output" Tags
Tag Description
<code>
Defines computer code text
<kbd>
Defines keyboard text
<samp>
Defines sample computer code
<tt>
Defines teletype text
<var>
Defines a variable
<pre>
Defines preformatted text
HTML Citations, Quotations, and Definition Tags
Tag Description
<abbr>
Defines an abbreviation
<acronym>
Defines an acronym
<address>
Defines contact information for the author/owner of a document
<bdo> Defines the text direction
<blockquote> Defines a long quotation
<q> Defines a short quotation
<cite> Defines a citation
<dfn> Defines a definition term
1.10 HTML Fonts
ក� ុ ង�� HTML version 4 និ ង េ��ម 4 tag <font> �ត�វ�នេគេ�ប សំ �ប់�� ស់ ប� ូរ�បេភទអក�រ,
ទំ ហំ អក�រ, ពណ៌ អក�រ។ ចំ េ�ះ HTML ជំ �ន់ 5 tag <font> �ត�វ�នលុបេ�ល។ ក� ុ ង HTML 4, style
sheets (CSS) �ត�វ�នេ�ប �� ស់ កំ នត់ទំរង់ website និ ង�រប�� ញដូ ច� �រ�� ស់ ប�ូរអក�រ font, text color,
size, text align… �េដ ម។
ឧ�ហរណ៌ ៈ
- face = “font_name” កំ នត់�បេភទអក�រដូ ច� “Arial”, “Times New Roman”
- size = n សំ�ប់កំ នត់ទំ ហំអក�រែដល�ន�ប់ពី 1 ដល់ 7 ទំ ហំធំ�ងេគគឺ 7
- color = color_name or color_code កំ នត់ពណ៌ អក �រ
color_name = “red”, “blue” ……… color_code = “#FFFFFF”, “#000000” ………
1.11 Page Layout �ងេ��មេនះគឺ� Attribute សំ�ប់កំ នត់េ�យ Page �ំងមូ ល
<body bgcolor="color_name" | “color_code” background = "image_url” bgproperties = "fixed | scroll"
<font face="arial" size="5" color="red"> This paragraph is in Arial, size 5, and in red text color. </font>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 15 - HTML
leftmargin = "x" topmargin = "y" marginwidth = "x" marginheight = "y" text = "color_name" | “color_code” link = "color_name" | “color_code” vlink = "color_name" | “color_code” alink = "color_name" | “color_code” >
…………………………………………………………………………….. </Body>
bgcolor = "color_name" | “color_code” កំ នត់ពណ័ ៃផ�េគហទំ ព័រ
background = "image_url” កំ នត់ៃផ�េគហទំ ព័រ�រូប�ព
bgproperties = "fixed | scroll"
fixed : កំ នត់ទី �ំងៃនៃ ផ�ទំ ព័រេ�យេ�មួ យកែន� ងេ �ះបីបំ�ស់ ទី Scrollbar ក៏ េ�យ
scroll : (default) ៃផ�ទំ ព័រចលត័េ�េព លេយ ងបំ�ស់ ទី Scrollbar
leftmargin = "x" តំរិមទំ ព័រែផ�ក�ងេឆ�ងគិត� Pixel
topmargin = "y" តំរិមទំ ព័រែផ�ក�ងេលគិត� Pixel
marginwidth = "x" កំ នត់�បែវងប�� យទំ ព័រគិត� Pixel
marginheight = "y" កំ នត់�បែវងទទឹ ងទំ ព័រគិត� Pixel
text = "color_name" | “color_code” កំ នត់ព ណ៌ េ�យអត�បទ
េ� ក� ុ ង ទំ ព័រ�ំងមូល
link = "color_name" | “color_code” កំ នត់ព ណ៌ េ�យ Hypertext
vlink = "color_name" | “color_code” កំ នត់ព ណ៌ េ�យ Hypertext
េ��យពី េយ ង�នចុ ចេ ល �រួចេហ យ។
alink = "color_name" | “color_code” កំ នត់ព ណ៌ េ�យ
Hypertext ក� ុ ងខណៈេពលកំពុ ងចុ ច។
Deprecated Tags and Attributes
ក� ុ ង�� HTML 4 �ន tags និ ង attributes �េ�ច ន�ត�វ�ន លបុេ� ល។ Deprecated
�នន័ យ��នឹ ងែលងដំ េណ រ�រ�មួយជំ �ន់ ថ�ីរបស់�� HTML ។
ចំ �ំ : េជ� ស�ង�រេ�ប��ស់ deprecated tags and attributes!
�ងេ ��មេន ះគឺ� tags and attributes ែដ លគួរេជ�ស�ង កុំ េ�ប :
Tags Description
<center> Deprecated. កំ នត់ centered content
<font> and <basefont> Deprecated. កំ នត់ HTML fonts
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 16 - HTML
<s> and <strike> Deprecated. កំ នត់ strikethrough text
<u> Deprecated. កំ នត់ underlined text
Attributes Description
align Deprecated. កំ នត់ the alignment of text
bgcolor Deprecated. កំ នត់ the background color
color Deprecated. កំ នត់ the text color
For all of the above: Use styles instead!
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 17 - HTML
Lists ��តុមួ យ�៉ ង សំ�ន់ េ�ប សំ�ប់េរ�បចំ អត�បទរបស់ េយង �នរេប�បេរ�បរយ
�ន�រែបងែចក�ម�បេភទ ទិ ន �ន័ យេដ ម�ីេ� យ អ�ក �ន� យយ ល់ �យេម ល អត�បទ។ េ�ក� ុង
HTML េគែចក List សំ�ន់ ៗ�នបី�បេភទ គឺ
- Definition List
- Order List : List �នេ លខេរ�ង
- Unorder List : List �បេភទ�និមិត�ស��
1. Definition Lists : េយងេ�ប Definition List េ�េពលែដ លេយងេ ធ��រ េ�យ និ យមន័ យ
េ�យេ ��� រឺក៏ �ក��មួ យ េ ��ះេ �េព លែ ដលេយងេ �ប <dl> tag អ�ី ែដលេ�ប�� ប់ពី <dl> tag
គឺ�ត�វចូ លេដ ម ប�� ត់ ែដលទំរង់ ែបបេនះគឺេ យងេ �បេ�ច ន�មួ យនឹ ង�រេ�យនិ យមន័ យ។ េគ�ច
េ�ម�៉ ងេទ �ត�� Glossary List េ� �ះ �ផ �ល់ទំរង់ ដូ ច� អត�បទក� ុ ង��នុ �កម ។
រច�សម�័ន ៃនគំរូ្ List �នដូ ច�ងេ ��ម
- <dl> : Definition List - <dt> : Definition term - <dd> : Definition data
ឧ�ហរណ៏
<dl> <dt>…………………</dt>
<dd>………………..</dd> <dt>…………………</dt> <dd>………………..</dd>
</dl>
<html> <head><title>Test Definition List </title></head> <body> <h1>Dictionary of Computer</h1> <dl> <dt> HTML </dt> <dd> Hyper Text Markup Language </dd> <dt> FTP </dt> <dd> File Tranfer Protocol </dd> <dt> ASP </dt> <dd> Active Server Pages </dd> </dl> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 18 - HTML
2. Order List
<OL> េ�បចំ េ�ះ List �នេលខេរ�ង ឬ លំ �ប់ ។
រច�សម�័ នៃ នគំរូ្ Order List �នដូ ច�ងេ��ម
Attribute េ� ក� ុង Order list �នដូ ច�ងេ ��ម
type = “x”
x = 1 កំ នត់េលខេរ�ង�មលំ �ប់ 1,2,3,……….., n (Default)
x =A កំ នត់លំ�ប់�អក�រ�កមធំ A, B, C, .........., Z
x = a កំ នត់លំ�ប់�អក�រ�កមធតូច a, b, c,…….., z
x = I កំ នត់លំ�ប់េលខេរ�ង រ ៉ូ�ុ ំង I, II, III, ………..
x = i កំ នត់លំ�ប់េលខេរ�ង រ ៉ូ�ុ ំង i, ii, iii, ………….
start = “n” កំ នត់�រ�ប់េផ� មដំបូង �ម�បេភ ទ។
value = “m” កំ នត់ទី �ំង តំៃល របស់ Item �មតំរូវ�ររបស់េយង។
<ol type = “x” start =“ n” > <li type = “x” value = “m”> Item 1 </li> <li type = “x” value = “m”> Item 2 </li> ………………………………………… ………………………………………… <li type = “x” value = “m”> Item N </li> </OL>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 19 - HTML
ឧ�ហរណ៏
3. Unordered List
�រេ�ប��ស់ <ul> tag �នលក�ណះដូ ច�� េ�នឹ ង �រេ�ប��ស់ Ordered List ែដ រ
ខុ ស�� �តង់ �បេភទល ំ�ប់ Item េ��ះ <ul> tag េ�ប��ស់ និ មិត�ស�� ជំ នួ សេល ខវ ិញ ។
រច�សម�័ន ៃនគំរូ្ List �នដូ ច�ងេ ��ម
Attribute េ� ក� ុង Unorder List �នដូ ច�ងេ ��ម
type = “value”
value �នដូ ច�ងេ��ម
- square រូប�ព��េរ ៉
- circle រូប�ព�រង�ង់ ទេ ទ
- disc រូប�ព�រង�ង់ េព ញ
<html> <head> <title>Test Order List</title> </head> <body> <ol> <li> Lesson 1 </li> <li> Lesson 2 </li> <li value= 10> Lesson 3 (start from 10) </li> </ol> </body> </html>
<ul type = “value”> <li type = “value”> Item 1 </li> <li type = “value”> Item 2 </li> ……………………………….. ……………………………….. <li type = “value”> Item N </li> </ul>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 20 - HTML
ឧ�ហរណ៏
<html> <head> <title>
Example Unorder List </title> </head> <body> <h2>Subject List</h2> <ul type="circle"> <li> HTML </li> <li> Javascript </li> <li type="square"> CSS </li> <li type="square">JQuery </li> <li type="disc"> ASP </li> <li type="disc"> ASP.NET </li> <li type="disc"> PHP </li> </ul> <body> <html>
List Order disc
circle
square
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 21 - HTML
4. បេង�ត List ក� ុង List (Nested List )
ទំរង់ ទូ េ�ៈ
ឧ�ហរណ៌ ៈ
<ol type= “1 | A | a | I | I” start= “n” > <li> -------------------- </li> <ul type= “disc | square | circle”> <li> -------------------- </li> <li> -------------------- </li> <li> -------------------- </li> </ul>
<li> -------------------- </li> <ol type= “1 | A | a | I | I” start= “n” > <li> -------------------- </li> <li> -------------------- </li> <li> -------------------- </li> </ol> </ol>
<html> <head><title>Nested List </title> </head> <body> <ol type="I"> <li>Introduction to HTML</li> <ol> <li>What is HTML?</li> <li>HTML Tag</li> <ol type="a"> <li>Markup Tag</li> <li>Attribute</li> <li>Content</li> </ol> </ol> <li>Create a Webpate</li> <ul type="square"> <li>Format Text</li> <li>Page Layout</li> </ul> <li>List</li> <ol type="i"> <li>Definition List</li> <li>Order List</li> <li>Unorder List</li> </ol> </ol> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 22 - HTML
Links គឺេឃញ�នេ ស �រ�គប់ web pages �ំ ងអស់ ។ links អនុ �� តេ�យអ�កទ ស� �
(visitor) ចុ ចេល Links េដ ម� ីេ��ន់ page �មួ យេ ផ�ង េទ�ត។ A Hyperlink or Link គឺ� �ក�,
បណ� ុំ ៃន �ក� រ�ឺ រូប�ពែដល �ចេ �យេ យ ងចុ ចេ ល� េហយ�ំេ ��ន់ េគហទំ ព័រថ�ី ឬ new
section ក� ុ ង current document។
Links គឺ� ចំ នុ ចដ៏ សំ� ន់ មួ យេ�ក� ុ ង�ររច� េគហទំ ព័រ គឺ �អនុ �� តេ�យេយ ង េធ��រ�� ប់ពី
ចំ នុ ចមួ យ េ�ចំ នុ ចមួ យេទ�តេ�ក� ុ ង Page ែតមួ យ មិ នែតបុ៉េ�� ះ េយ ង�ចេ ធ��រ link េ��ន់ website
មួ យ ឬក៏ ចំ នុ ច�មួ យេ�ក� ុង website មួ យេផ�ងេទ�ត�ន។ េដ ម�ី�ចេ�ប��ស់ Links េ�ក� ុ ង
HLML �នេ យង�ត�វ�រេ�� ះ File ឬ URL ែដ លេយង ចង់ Link េ� �ន់ ។
Syntax
Link �នបីែផ�ក សំ�ន់ គឺ
- Destination: គឺ� URL រ ឺFile ែដ ល�� ប់េ�េ�េ ពលអ �កេ�ប��ស់ចុ ច
- Label: �ែផ�កមួ យែដល អ�កេ�ប��ស់េឃញ និ ង �ចចុ ច�នេដ ម� ីេ�យ�
�� ប់េ��ន់ Destination ។ ��ច�អត�បទ រ ឺរូប�ព
- Target : កំ នត់ទីកែ ន�ងែដល Destination នឹ ងប�� ញ
1 េ�ប��ស់ HTML Link Tag <a>
1.1 �រ Link េ��ន់ page
េ�ក� ុ ង�រ Link េ��ន់ page �មួ យ ចំ នុ ចសំ �ន់ ែដលេយ ង�ត�វគិតដំបូងគឺ េត page ែដល�ត�វ
link េ��នេ�� ះអ�ី? �នទី �ំ ងេ�កែន�ង�? េ��ះេបសិ ន�េយ ងមិ ន�� ល់ េ�� ះ និ ង ទី �ំ ងេទេ�ះ
េយ ង��ក ដ�មិ ន�ច link េ��ន់ page េ� ះ� នេឡយ។
<a href = “filename.html” > Zone Click</a>
ឧ�ហរណ៏
<a href = “aboutus.html”> About Us </a>
href = “aboutus.html” �នន័ យ� link េ��ន់ page មួ យ�នេ�� ះ� aboutus.html ។
<a href="url" target= “frame_name”> Label </a>
Destination Target Label
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 23 - HTML
1.2 �រ Link េ��ន់ េគហទំ ព័រ�មួយ
គឺ��រ link េ��ន់ េគហទំ ព័រ�ងេ��។
ឧ�ហរណ៏
1.3 �រ Link េ�ក� ុង page
Anchor �ចជួ យេយងេ�យេធ��រ link េ��ន់ តំបន់ �មួ យ�ក់ �ក់ ក� ុង page ែតមួ យ�ន
�៉ ងេល�ន េ� ះបី��រ link េ� ះពី េល ចុ ះមកេ��ម ឬក៏ ពី េ��មេឡងេល�៉ ង�ក៏ េ�យ។ �បសិនេប
េយ ង�នអត�បទេ�ច ន េហ យេយ ងមិ ន�នេ�ប��ស់ anchor �ជំនួ យេ�ះេទ �នឹ ង�ំ េ� យ អ �កទ ស��
�ន�រពិ�កក� ុ ង�រេម លព័ត៌�ន ែដល�េហតុេធ� េ�យ អ�កទស��េ�ះបង់ ែលងចូ លមក េម ល
េគហទំ ព័ររបស់ េយ ងេទ�ត។
<html> <head><title>Links </title> </head> <body> <a href="index.html">HOME </a> | <a href="contactus.html">CONTACT US </a> | <a href="/aboutus.html">ABOUT US </a> </body> </html>
<html> <head><title>Test Links </title> </head> <body> <a href="http://www.usea.edu.kh/"> Visit USEA Website </a> <br/> <a href="http://www.microsoft.com"> Visit Microsoft Site </a> <br/> <a href="http://www.google.com/"> Google </a> <br/> <a href="http://www.w3schools.com/"> Learn Website </a> <br/> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 24 - HTML
ក� ុ ង�រេ�ប anchor េយ ង�ំ � ច់ បេង�ត�ពីរដំ �ក់ �ល៖
ក. បេង�តនូ វចំ នុ ច (anchor) េដ ម�ីទុ កសំ�ប់ link មក�ន់
<a name= “anchor_name”> Label </a>
anchor_name : �េ�� ះចំ នុ ច
ឧ�ហរណ៏
<a name=”top”> Top Menu </a>
ខ. បេង�ត link េ��ន់ ចំ នុ ច (anchor)
<a href= “#anchor_name”> Label </a>
#anchor_name: កំ នត់េ�� ះែដល�នបេងត anchor សំ �ប់ link
ឧ�ហរណ៏
<a href= “#top”> go to Top </a>
1.4 �រេ�ប��ស់ Target Attribute
េយងេ�ប Target េដ ម�ីកំ នត់ទី កែ ន�ង ែដ ល URL �ត�វ ប�� ញ។
<a href= “url” target= “window_name”>
target= “_seft” ប�� ញ URL េ� េល Current window
target= “_blank” ប�� ញ URL េ� េល Window ថ�ី
1.5 �រេ�ប��ស់ title Attribute
Title គឺ��� ែដ ល�នឹ ងប�� ញេ�េព លែដលអ�កទស��យក mouse មក �ក់ ចំ េ ល�� ែដល�ត�វ
link ។
ឧ�ហរណ៏
<a href="http://www.usea.edu.kh/" title= “Visit USEA Website”> USEA</a> <br/>
2. �រេ�ប��ស់ Relative Link
េយ ងេ�ប��ស់ Relative Link គឺ�យ�ស� លក� ុ ង�រ link េ�យមិ ន�ច់ េ�ប� �ស់ នូ វ Path
េពញេ�ះេទេយង��ន់ ែតេ�បនិ មិត�ស�� “../” �នន័ យ�ថយមួ យ Folder ។ េន ះ�ចំនុ ចសំ�ន់
បំផុតេ�េពលយក Files េ� Upload ឬ េបកេ�េល �៉ សុីនកុំ ព� ទ័រេផ�ង េទ�ត េ��ះេបសិន�េយង
មិ នេ�បវ ិធី េន ះេ ទ េពលេ�ះ�មិ ន �� ល់ Path េទ េ� េពលេ យង link ។
ឧ�ហរ ណ៍ ៈ េយ ង �ន រច�សម�័ ន � ែដ ល�ន ទំ រង់ ដូ ច�ងេ �� មៈ
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 25 - HTML
វ ិធី Link:
+ េយងេ�េល Wed Page index.html េដ ម� ី Link េ��ន់ aboutus.htm, contactus.html,
software.html, static.html និ ង dynamic.html
<a href = “about/aboutus.html”> About Us </a> <a href = “contact/contactus.html”> Contact Us </a> <a href = “services/software.html”> Software </a> <a href = “services/ website/static.html”> Static Page </a> <a href = “services/website/dynamic.html”> Dynamic Page </a>
+ េយងេ�េ ល Wed Page aboutus.html េដ ម� ី Link េ��ន់ index.html, contactus.html,
software.html, static.html និ ង dynamic.html
<a href = “../index.html”> Home </a> <a href = “../contact/contactus.html”> Contact Us </a> <a href = “../services/software.html”> Software </a> <a href = “../services/ website/static.html”> Static Page </a> <a href = “../services/website/dynamic.html”> Dynamic Page </a>
+ េយងេ�េ ល Wed Page contactus.html េដ ម� ី Link េ��ន់ index.html, aboutus.html,
software.html, static.html និ ង dynamic.html
<a href = “../index.html”> Home </a> <a href = “../about/aboutus.html”> About Us </a> <a href = “../services/software.html”> Software </a> <a href = “../services/ website/static.html”> Static Page </a> <a href = “../services/website/dynamic.html”> Dynamic Page </a>
+ េយងេ�េ ល Wed Page software.html េដ ម�ី Link េ��ន់ index.html, aboutus.html,
contactus.html, static.html និ ង dynamic.html
<a href = “../index.html”> Home </a> <a href = “../about/aboutus.html”> About Us </a> <a href = “../contact/contactus.html”> Contact Us </a> <a href = “website/static.html”> Static Page </a>
index.html
C:\webpage\
about
aboutus.html
contact
contactus.html
services
software.html
dynamic.html
website
static.html
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 26 - HTML
<a href = “website/dynamic.html”> Dynamic Page </a>
+ េយងេ�េល Wed Page static.html េដ ម� ី Link េ��ន់ index.html, aboutus.html,
contactus.html, software.html និ ង dynamic.html
<a href = “../../index.html”> Home </a> <a href = “../../about/aboutus.html”> About Us </a> <a href = “../../contact/contactus.html”> Contact Us </a> <a href = “../software.html”> Software </a> <a href = “dynamic.html”> Dynamic Page </a>
+ េយងេ�េ ល Wed Page dynamic.html េដ ម�ី Link េ��ន់ index.html, aboutus.html,
contactus.html, software.html និ ង static.html
<a href = “../../index.html”> Home </a> <a href = “../../about/aboutus.html”> About Us </a> <a href = “../../contact/contactus.html”> Contact Us </a> <a href = “../software.html”> Software </a> <a href = “static.html”> Static Page </a>
3. �របេង�ត Link េផ�ងៗ
3.1 �រ link េ��ន់ FTP(File Transfer Protocol)
េ�េពលែដ លេយ ងកំ នត់យក FTP � protocol េ�ក� ុ ង URL េ� ះ browser នឹ ង�ប់េផ� ម�� ប់
េ�យស�័យ �បវត�ិ េ��ន់ ទី �ំងែដល�នកំ នត់ និ ងប�� ូ ននូ វ request file ។
ទំរង់ ទូ េ�
ftp://hostname/directory_name/filename
ឧ�ហរណ៏
<a href= “ftp://snsolution.net/link.html”> FTP Link </a>
3.2 �រ link េ��ន់ mail
េយ ងេ�ប� េដ ម�ីេធ��រេផ�រ email េ��ន់ នរ��� ក់ ។ េពលែដលេយ ងចុ ចេល Label ស��ប់ link
�� មៗ េ�ះ�នឹ ងេធ��រេ� កម�វ ិធី ស��ប់េផ�រ�រ�� ម។
ទំរង់ ទូ េ�
mailto:username@hostname
ឧ�ហរណ៏
<a href = “[email protected]”> Mail to Seriya </a>
3.3 �រ link េ��ន់ Image File (Gif , JPEG, រ ឺ�ពយន� )
េគ�ច link េ��ន់ រូប�ព េ�យេ�ប <a href=“image_name”> …………………..</a>
េ�េពលេគចុ ច �នឹ ងប�� ញ រូប�ព ។ លទ �ផលៃន�រ ប�� ញ �ខុ ស�� �� ស័យេ� និ ង Browser
ែដលេ�ប��ស់។
ឧ�ហរណ៏
<a href = “mypic.gif”> View my picture </a>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 27 - HTML
4. �រ�� ស់ ប�រូពណ៌ េ�េពល Link
េដ ម� ីេធ ��រ �� ស់ប� ូរពណ៌ អក �ររបស់ link ដូ ច� មុ នេព ល link, កំ ពុ ង link និ ង េ��យេពល
link េយ ងេ�ប� �ស់ Attributes link, alink, vlink េ�ក� ុង tag <body> ។ សូ មេម លទំរង់ �ងេ��មៈ
<body link = “rrggbb” alink = “rrggbb” vlink = “rrggbb”> .............................................................................................................
</body>
- link : �ព ណ៌ ដំបូងរបស់ អត�បទ link េ� េពលែដ លអ�ក ទស� �មិ ន�ន់ េបកេ ម ល
(Default ព ណ៌ េខ� វ )
- alink : �ព ណ៌ ក� ុ ងខណះ េពលែដ លអ �កទស��ចុ ចេ �េល អត�បទ link (Default
ព ណ៌ �ក ហម )
- vlink : �ព ណ៌ អត�បទ េ��យពី អ �កទស��េបកេ ម លរួច link េហ យ (Default
ព ណ៌ �� ឈូក )
Keyboard Shortcuts for Links <a href = “url” accesskey=“char” > Label </a>
េយង�ចេ�ប�� ស់ Character � Shortcut key សំ�ប់ Link េ� យអ�កេ �ប�� ស់ ��ន់ ែត
ចុ ច ALT �មួ យ Character ែដលេយងេផ�រតំៃលេ�យ (ALT+char) ។
<a href = “http://www.microsoft.com/” accesskey=“m” > Microsoft site </a>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 28 - HTML
រូប�ព� �តុមួ យដ៏ពិ េស សែដ ល េគចូ លចិត�េ�បេ�ក� ុង � របេង�តេគហទំ ព័រេដ ម�ីតុបែតង
េ�យ�នេ�ភ័ ណ� �ពល � និ ង �ក់ �ញ �រម� ណ៌ �៉ ង�� ំងពី អ�ក ទស� �។ រូប�ពែដល
េយងេ�បក� ុងេ ពលបច� ុប�ន��នេ�ច ន�បេភទ�ស់ ចំ ែណ ក�បេភទ និ មួយៗ�ន លក �ណះ
ពិ េសសខុ សៗ�� ែដរ ដូ ច� រូប�ពខ�ះ �ន ចល� ។ េយ ង �ចសំ�ល �់បេភទ និ មួ យៗ
�នេ �យ�រ extension សូមេ ម ល��ង �ងេ��មៈ
Description Extension
GIF image .gif
JPEG image .jpg or .jpeg
Portable Network Graphic .png
Windows Bitmap Image .bmp
TIFF image .tiff
Encapsulate PostScript .eps
ទំរង់ ទូ េ�ៈ
- src = “url” : កំ នត់រូប�ពែដលចង់ ប�� ញ
- border = “n” : កំ នត់កំ �ស់ប�� ត់ជុំ វ ិញរបូ�ព គិត� pixel
- alt = “Alternate Text” : កំ នត់អត�បទេដ ម�ីេរ�ប�ប់ពីរូប�ពេពលែដលយក mouse
�ក់ េល �
- width = “x” : កំ នត់�បែវងបេ�� យៃនរបូ�ពគិត� pixel
- height = “y” : កំ នត់�បែវងទ ទឹ ងៃនរបូ�ពគិត� pixel
- align = “left | right” : កំ នត់ទី �ំងអ ក�រេ�ជុំ វ ិញរបូ�ព
- hspace = “a” : កំ នត់ចំ �យ horizontal space រ�ងរបូ�ព និ ង អត�បទ
- vspace = “b” : កំ ន ត ់vertical space រ�ងរបូ�ព និ ង អត�បទ
<img src = “url” border = “n” alt = “Alternate Text” width = “x” height = “y” align = “left | right” hspace = “a” vspace = “b” />
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 29 - HTML
ឧ�ហរណ៌ ៈ
1. �រកំនត់ទី�ំងអក�រេ�ជុំ វ ិញរបូ�ព
align = “top | middle | bottom | left | right”
- top: កំ នត់ទី �ំង ៃនអត�បទេ�ពី េលរបូ�ព
- middle: កំ នត់ទី �ំងៃនអត�បទេ�ក�� លរបូ�ព
- bottom: កំ នត់ទី �ំង ៃនអត�បទេ�យេស �េ�នឹ ងជួរប�� ត់របស់របូ�ព (default)
- left: កំ នត់េ�យទី �ំ ងៃនរបូ�ពេ� ែផ�ក�ងេឆ�ងៃន�� ំ ង Window
- right: កំ នត់េ�យទី �ំ ងៃនរបូ�ពេ� ែផ�ក�ង�� ំៃន�� ំ ង Window
សូ មេម ល�រសរេសរដូ ច�ងេ��មៈ
<html> <head><title>Using Image </title> </head> <body> <img src="img8.jpg" width="400" height="300"> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 30 - HTML
<html> <head><title>Using Image </title></head> <body> <img src="img8.jpg" width="200" height="150" align="left"> Google SEO Tips SEO is an acronym for "search engine optimization" or "search engine optimizer." Deciding to hire an SEO is a big decision that can potentially improve your site and save time, but you can also risk damage to your site and reputation. <br clear="all"/> <br/> <img src="img8.jpg" width="200" height="150" align="right"> Google SEO Tips SEO is an acronym for "search engine optimization" or "search engine optimizer." Deciding to hire an SEO is a big decision that can potentially improve your site and save time, but you can also risk damage to your site and reputation. <br clear="all"/> <br/> <img src="img8.jpg" width="200" height="150" align="left"> <img src="img8.jpg" width="200" height="150" align="right"> Google SEO Tips SEO is an acronym for "search engine optimization" or "search engine optimizer." Deciding to hire an SEO is a big decision that can potentially improve your site and save time, but you can also risk damage to your site and reputation. </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 31 - HTML
2. �រកំនត់ទំហំរបូ�ព
េ�េពលែដ លេយ ងយករបូ�ពេ��ក់ ក� ុ ង page េ�យមិ ន�នកំ នត់នូ វ ទទឹ ង ឬក៏បេ�� យ
របស់ របូ�ពេទ េ�ះ browser នឹ ងប�� ញ�មទំ ហំ េដ មរបស់ �។ ទំ ហំ េដ ម�នន័ យ��ទំ ហំ
ពិតរបស់ របូ�ព ក�ុ ង�� HTML េយ ងក៏ �ចេធ��រែកែ�បទំ ហំ �នផ ង ែដរេ�យេ�ប ��ស់ attribute
width និ ង height របស់ <img> tag ។
ឧ�ហរណ៌ ៈ
3. �រកំនត ់Alternate Text
េយ ង�បែហល��� ប់ជួបេហ យេ�េពលែដលេយ ងចូ ល េ��ន់ web site �មួ យេ ហយ យក
mouse េ��ក់ េលរបូ�ព��ប់ែតេឃញអក�រេលចេចញមក អក�រេ�ះេយ ងេ �� Alternate Text ។
េដ ម�ីបេង�ត Alternate Text េយ ង�ត�វេ�ប��ស់ Attribute alt របស់ <img> tag
<html> <head><title>Using Image </title> </head> <body> <img src="img0.jpg" width="300" height="250" alt="WOW Window 7 widht:300 height:250" align="left" /> Google SEO Tips SEO is an acronym for "search engine optimization" or "search engine optimizer." Deciding to hire an SEO is a big decision that can potentially improve your site and save time, but you can also risk damage to your site and reputation. </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 32 - HTML
<img src="img8.jpg" alt="Best Place" />
Alternate Text ក៏ប�� ញផងែដរ េ�េពលែដលរបូ�ពមិ ន�នប�� ញ
4. �រកំនត់ចំ�យពីរបូ�ពេ�អត�បទ
�រេធ� េ� យរបូ�ព នឹ ងតួអក�រ�នគំ�តពី�� �ចជួ យេ�យ�រេរ�បចំ អត�បទរបស់ េយ ង
េ�ក� ុ ង page �ន�ព�� តគួរេ�យ�ក់ �ញ។
- hspace = “a” : កំ នត់ចំ�យ horizontal space រ�ងរបូ�ព និ ង អត�បទ
- vspace = “b” : កំ នត់ vertical space រ�ងរបូ�ព និ ង អត�បទ
<html> <head><title>Using Image </title> </head> <body> <img src="img0.jpg" width="300" height="250" hspace="20" align="left" /> Google SEO Tips<br/>Google SEO Tips<br/>Google SEO Tips<br/>Google SEO Tips<br/> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 33 - HTML
5. Border and Image Links
�ធម�� browser បកែ�ប Link �មួ យ Text េ�យបេង�តេ�យ�នពណ៍ េផ�ងៗ េ��ម
events និ ង�រគូសប�� ត់ពី េ��ម ឥឡ ូវេនះេយ ង�នលទ��ព Link �មរយះ image ។
�បសិ នេបេយងប�� ូ លរបួ�ពេ�ច េ�� ះ Anchor Container �នឹ ង�ច�វត� ុមួ យ�ច link េ��ន់ URL ។
េ�េពលែដ លេយ ង link េ�យេ�ប ��ស់ របូ�ព �ធម�� browser នឹ ងបក ែ�បេ�យ �ន Border
េ�ជុំ វ ិញរបូ�ព�នកំ �ស់ 2pixels និ ង�នពណ៍ ដូ ច�� េ�នឹ ងព ណ៍ Link text ។ �ទូ េ� Default
ពណ៍ របស់ Border គឺ Blue ។
hspace= “20”
vspace= “20”
<html> <head><title>Using Image Link </title> </head> <body> <a href="http://www.microsoft.com/"> <img src="img0.jpg" width="150" height="100" border="0" /> </a> <a href="http://www.microsoft.com/"> <img src="img0.jpg" width="150" height="100" border="2" /> </a> <a href="http://www.microsoft.com/"> <img src="img0.jpg" width="150" height="100" border="4" /> </a> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 34 - HTML
6. Zone Click Image
េយ ងេ�ប Zone Click Image េដ ម�ីកំ នត់តំបន់ េ�េលរបូ�ពេដ ម�ី�� ប់េ��ន់ URL
�មួ យ។
Syntax
ឧ�ហរណ៌ ៈ
<map name="MAPNAME"> <area shape="rect" coords="x0,y0,x1,y1" href="url" alt="Text"> <area shape="circle" coords="x0,y0,r" href="url" alt="Text"> <area shape="poly" coords="x0,y0,x1,y1,x2,y2……………………….,xn,yn" href="url" alt="Text"> </map> <img src="Image_File" usemap="#MAPNAME" />
<html> <head><title>Image Map</title> </head> <body> <map name="microsoft"> <area shape="rect" coords="36,31,156,128" href="http://www.microsoft.com/" alt="Visit Microsoft"> <area shape="circle" coords="302,102,50" href="http://www.google.com/" alt="Visit Google"> </map> <img src="img1.jpg" width="400" height="350" border="0" usemap="#microsoft" /> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 35 - HTML
��ង គឺ��តុមួ យ�៉ ងសំ �ន់ េហ យេយ ងេ�ប ��ស់ �ញឹ ក�ប់សំ�ប់ បេង�តេគហទំ ព័រ ម�៉ ង
វ ិញេទ�តេគ�ចយក ��ងមកេធ�� ទំរង់ (layout) របស់ page ផង ែដរេ��ះ��ន�ព�យ �ស �ល
េហ យពុំ សូ វ�ន�ព�ុ ំ� ុ ំ �ពម�ំង�នេ�ភ័ ណ�ពល�េ ទ�តផង។ េយ ង�ចេ�ជ សេរសយក Table
មក េ�ប េដ ម�ីផ� ុ ក ឬ េរ�បចំ ទិ ន�ន័ យេផ�ងៗេ��មតំរូវ�រ �នេ�យ�យ។
��ងេកតេឡងេ�យ�រផ�ំ�� រ�ងជួរេដក (Row) និ ងជួរឈរ (Column) ។ េយ ងបំែបកទិ ន�ិ ន័ យ
េ�ក� ុ ង��ង េ�យេ�ប ��ស់ Tag <TH> (Table Header) រឺ <TD> (Table Data) េហ យបេង �ត
ជួរេដក ថ�ី េ�យេ�ប Tag <TR> (Table Row) េយ ង�ត�វគិត� <TR> Tag េ�ប សំ �ប់បេង�តជួរេដក ថ�ី ។ Table
Header �ទូ េ�ប�� ញអក�រដិត (Bold) េហ យ Table Data ប�� ញអក�រេ�យយកគំរូ �មអក �រេ�ក� ុ ង
Body ។ Cell េ�ក� ុ ង Table �ចេ�បសំ �ប់ផ� ុ ក�តុដូ ច�ងេ ��មៈ
- Text
- List
- Hypertext
- Image
- Tag Element ……….
�ក�មួ យចំ នួ នែដលេយ ងេ�ប��ស់ញឹ ក�ប់េ�ក� ុ ង�របេង�ត��ង
Caption: ចំ នង េជ ង��ង
Table Header : កំ នត់អក�រធំេ�េដ ម� ក� និ ង អក �រដិត
Table Data: ទិ ន�ិ ន័ យេ�ក� ុ ង��ង
TableCell: ចំ នុ ច�បសព�រ�ង ជួរេដក និ ង ជួរឈរ
Caption
Table Header Table Data Table Cell
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 36 - HTML
1. Basic HTML Table Element
េដ ម�ីបេង�ត��ងក � ុង HTML េយ ងេ�ប <table>……………</table> Tag េហ យ�ន �តុមួ យចំ នួ ន
េទ�តេ�ក � ុ ង� ដូ ច� <tr>…………….</tr> tag �ត�វ�នេ�ប សំ�ប់បេង�តជួរេដក េ�ក� ុ ង��ង។ េ�ក� ុ ង
<tr>…………….</tr> េយ ង�ន tag មួ យចំ នួ នេ ទ�តដូ ច� <th>……</th> េ�ប សំ�ប់បេង�ត� Header
�ធម��េគេ�ប �េ� Row ដំបូងរ ឺ Column ដំបូងៃន��ង និ ង�តុមួ យេទ�តគឺ <td>……….....</td> េ�ប
សំ �ប់ផ� ុ កទិ ន�ិ ន័ យ។
ឧ�ហរណ៏ �ងេ��មេនះប�� ញពី�របេង�ត��ងធ ម��ៈ
Table.html
<html> <head><title>Sample Table</title> </head> <body> <table> <caption>Sample Table</caption> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td>Row 1 : Col 1</td> <td>Row 1 : Col 2</td> <td>Row 1 : Col 3</td> </tr> <tr> <td>Row 2 : Col 1</td> <td>Row 2 : Col 2</td> <td>Row 2 : Col 3</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 37 - HTML
ទំរង់ ទូ េ�របស់ Table
2. �រេ�ប��ស់ Attribute របស់ Table
�រេ�ប��ស់ Attribute background
េយ ងេ�ប ��ស់ Attribute េនះ េដ ម�ីេធ��រកំ នត់ៃផ�របស់ ��ង�របូ�ពេ�យ��ន់ ែត
កំ នត់េ�� ះរបស់ របូ�ព�ពម�ំ ងទី �ំ ង �បសិ នេប ទី �ំ ងរបស់ របូ�ព និ ងទី �ំងរបស់ file ែដលេយ ង កំ ពុ ង
បេង�តមិ នេ �ក� ុង folder ែតមួ យ។
ឧ�ហរណ៌ ៈ
<table> <caption>Sample Table</caption> <tr> <th>………………………</th> <th>………………………</th> </tr> <tr> <td>………………………</td> <td>………………………</td> </tr> </table>
<html> <head><title>Sample Table</title> </head> <body> <table background="img8.jpg"> <caption>Sample Table</caption> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td>Row 1 : Col 1</td> <td>Row 1 : Col 2</td> <td>Row 1 : Col 3</td> </tr> <tr> <td>Row 2 : Col 1</td> <td>Row 2 : Col 2</td> <td>Row 2 : Col 3</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 38 - HTML
�រេ�ប��ស់ Attribute bgcolor
េយ ងេ�ប ��ស់ Attribute េនះ េដ ម�ីេធ��រកំ នត់ពណ៌ ៃផ�របស់ ��ង។
<table bgcolor= “color_name” | “color_code” > ………………………………………. ………………………………………. </table>
�រេ�ប��ស់ Attribute Border
េ�ក� ុ ង <table> tag េយ ង�ចេ �ប Attribute Border េ ដ ម�ីកំ នត់ទំហំ ែដលហ៊ ំ ព័ ទ�ជុំ វ ិញ��ង
ឧ�ហរណ៏ ៈ
<html> <head><title>Sample Table</title> </head> <body> <table bgcolor="#CC9999"> <caption>Sample Table</caption> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td>Row 1 : Col 1</td> <td>Row 1 : Col 2</td> <td>Row 1 : Col 3</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 39 - HTML
Tableborder.html
�រេ�ប��ស់ Attribute bordercolor, bordercolorlight, bordercolordark
- bordercolor : សំ �ប់កំ នត់ពណ៌ េ�យស៊ុ មរបស់��ង
- bordercolorlight : សំ �ប់កំនត់ពន�ឺរបស់ ស៊ុ មៃន��ងេ�យ�នលក�ណះ� 3D
- bordercolordark : សំ �ប់កំ នត់ពណ៌ េ�េ�យស៊ុមរបស់ ��ងែដល�ន�ពងងឹត និ ង
�នលក�ណះ� 3D
<html> <head><title>Sample Table</title> </head> <body> <table border="1"> <caption>Sample Table</caption> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td>Row 1 : Col 1</td> <td>Row 1 : Col 2</td> <td>Row 1 : Col 3</td> </tr> </table> </body></html>
<html> <head><title>Table</title></head> <body> <table width="500" border="5" align="center" cellspacing="2" bordercolor="#0099FF" bordercolorlight="blue" bordercolordark="red" height="150" cellpadding="2"> <tr> <th>No</th> <th>Product</th> <th>Amount</th> </tr> <tr> <td>1</td> <td>Cocacola</td> <td>20</td> </tr>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 40 - HTML
�រេ�ប��ស់ Attribute width
េយ ង�ចេ �ប��ស់ Attribute េនះ េដ ម�ីកំ នត់�បែវងទទឹ ងរបស់ ��ង ែដលតំៃលរបស់ �
គិត� pixel ឬ �គរយ។
<html> <head><title>Alignment Table</title></head> <body> <table width="500" border="1" align="center"> <caption>Using Attribute Width</caption> <tr> <th scope="col">Header 1</th> <th scope="col">Header 2</th> <th scope="col">Header 3</th> </tr> <tr> <td> Data </td> <td> Data </td> <td> Data </td> </tr> </table> </body></html>
<tr> <td>2</td> <td>Pepsi</td> <td>10</td> </tr> <tr> <td>3</td> <td>Spy</td> <td>15</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 41 - HTML
ទី �ំង ៃន�តុេ�ក � ុង��ង (Aligning Table Element)
�រកំ នត់ទី�ំងអត�បទេ�ក� ុង Table cell េ�ប េ�យ Attribute Align និ ង Valign ។
Attribute �ំ ងេនះ�ចេ�ប �នេ�ទី កែន�ង�េ�ច នដូ ច�េ�ក� ុ ង <caption> ,<tr>,<th> និ ង <td>
<caption> : េ�ប�មួ យ Attribute align សំ �ប់កំ នត់ទី �ំ ងៃនចំ នង េជ ង Table
េដ ម�ីេ�យ េ� េល ��ងេយងេ�ប Align= “top” និ ងេ�ពី េ��ម��ង Align= “bottom” �ទូ េ�
Default របស់ �គឹ top
<tr> : �ន Attribute ដូ ច�ងេ��ម
align: សំ �ប់កំ នត់ទី�ំងេ�យ�នតំៃល left, right និ ង center (Default=left)
valign: សំ �បកំ នត់ទី �ំងេ�យ�នតំៃល top, bottom និ ង middle
(default=middle)
<th> : �ន Attribute ដូ ច�ងេ��ម
align: សំ �ប់កំ នត់ទី�ំងេ�យ�នតំៃល left, right និ ង center (Default=left)
valign: សំ �ប់កំ នត់ទី �ំងេ�យ�នតំៃល top, bottom និ ង middle
(default=middle)
<td> : �ន Attribute ដូ ច�ងេ��ម
align: សំ �ប់កំ នត់ទី�ំងេ�យ�នតំៃល left, right និ ង center (Default=left)
valign: សំ �ប់កំ នត់ទី �ំងេ�យ�នតំៃល top, bottom និ ង middle
(default=middle)
ឧ�ហរណ៏
<html> <head><title>Alignment Table</title></head> <body> <table border="1" cellspacing="5" width="400">
<caption align="bottom">Sample Table</caption> <tr> <th align="left">Left</th> <th align="center">Center</th> <th align="right">Right</th> </tr> <tr height="60"> <td valign="top">Top</td> <td valign="middle" align="center">Middle</td> <td valign="bottom" align="right">Bottom</td> </tr> </table> </body></html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 42 - HTML
Cell �� ន�តុ (Empty Cells)
េបសិ ន�អ�កចង់ េ�យ cell �� នអ�ី េ�ក � ុង� េ�ះ��រ�យ�ស�ល �ស់ េ�យ��ន់ ែត
េ�ចេ�� ះ <th> រឺ <td> េយ ងមិ ន�ច់ េ�ប អ�ី �ំ ងអ ស់ ។
ឧ�ហរណ៏ ៈ
�រប��ូ ល Cell េ�ច ន េ�� Cell ែតមួយ
េយ ង�ចេ ធ��រប�� ូ ល Rows េ�ច ន ឬ Columns េ�ច នេ�យេ�� Cell ែតមួ យ�នេ�យ
េ�ប ��ស់ នូ វ Attribute “colspan” or “rowspan” ។
<td colspan= “n” rowspan= “n”> ……………………………………….</td>
សូ មពិ និត�េម ល�រសរេសរ code ដូ ច�ងេ��មៈ
<html> <head><title>Alignment Table</title> </head> <body> <table border="1" cellspacing="5" width="400"> <tr> <th>AAAAAA</th> <th></th> <th>BBBBBB</th> </tr> <tr> <td></td> <td>CCCCCC</td> <td>DDDDDD</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 43 - HTML
សូ មពិ និត�េម លលទ�ផល�ងេ��មៈ
�រកំនត់ចំ�យពី Cell េ� Cell និ ងពី ស៊ុមៃន Cell េ��តុរបស់ �
េដ ម�ីេធ��រកំនត់គំ�តពី Cell មួ យ េ� Cell មួ យេទ�តេយងេ�ប��ស់ Attribute cellspacing
េហ យចំ េ� ះ�រកំ នត់គំ�តពី ស៊ុ មៃន Cell េ�តួអក �រេយងេ�ប ��ស់ Attribute cellpadding េ�ក� ុ ង
<table> tag ។
<table cellspacing="n" cellpadding="n">
<html> <head><title>Table</title></head> <body> <table width="500" border="1" align="center"> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td rowspan="3"> Data </td> <td colspan="2">Data</td> </tr> <tr> <td>Data</td> <td>Data</td> </tr> <tr> <td colspan="2">Data</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 44 - HTML
ឧ�ហរណ៍
លទ�ផលៈ
�រកំ នត់ទំរង់ ��ង�មជួរេដក
�ងេ��មេនះ� Syntax សំ �ប់កំ នត់ Attribute របស់ ��ង�មជួរេដក
<thead>………………..</thead> សំ �ប់កំ នត់ទំរង់ េ�យ Table Header
<tbody>………………..</tbody> សំ �ប់កំ នត់ទំរង់ េ�យ Table Body
<tfoot>…………………..</tfoot> សំ �ប់កំ នត់ទំរង់ េ�យ Table Footer
<html> <head><title>Table</title></head> <body> <br/><br/><br/> <table width="500" border="1" align="center" cellspacing="40" cellpadding="15"> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td>Data</td> <td>Data</td> <td>Data</td> </tr> </table> </body> </html>
cellspacing
cellpadding
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 45 - HTML
ឧ�ហរណ៍
លទ�ផលៈ
<html> <head>
<title>Table</title> </head>
<body> <table width="500" border="1" align="center" cellspacing="2"
height="200" cellpadding="2"> <thead> <tr> <th>No</th> <th>Product</th> <th>Amount</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Cocacola</td> <td>20</td> </tr> <tr> <td>2</td> <td>Pepsi</td> <td>10</td> </tr> </tbody> <tfoot> <tr bgcolor="#0099CC"> <td colspan="2" align="right">Total</td> <td align="center">30</td> </tr> </tfoot> </table> </body> </html>
Thead
Tbody
Tfoot
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 46 - HTML
កំ នត់អត�បទមិ នេ�យចុ ះប�� ត់
េ�េពលែដ ល Browser ជួប Attribute “nowrap” េពលេ�ះ�េធ��រ បកែ�បេ�យអត�បទ
េ� ក� ុ ង Cell �នែតមួ យប�� ត់បុ៉េ�� ះ។
<td nowrap>………………………………</td> <th nowrap>………………………………</th>
ឧ�ហរណ៍
�បេភទ Border
េយ ង�ចកំ នត់�បេភទ Border របស់ ��ងេ�យេ�ប Attribute Frame និ ង Rules េ�ក� ុ ង
Table Tag ដូ ច�ងេ��មៈ
<table border="n" frame="frameConstant" rules="area">
frame= frameConstant សំ �ប់កំ នត់�បេភទប�� ត់េ�ែផ �ក�ងេ����ងែដល�ន�បេភទដូ ច
�ងេ��មៈ
1. void �� នប�� ត់ែផ�ក�ងេ����ង
2. above ប�� ត់ជុំ វ ិញ��ង�ន ែតែផ�ក�ងេល
3. below ប�� ត់ជុំ វ ិញ��ង�ន ែតែផ�ក�ងេ��ម
4. hsides Horizontal Sides ប�� ត់ជុំ វ ិញ��ង�ន ែតែផ�ក�ងេល និ ង�ងេ��ម
5. vsides Vertical Side ប�� ត់ជុំ វ ិញ��ង�ន ែតែផ�ក�ងេឆ�ង និ ង�ង�� ំ
6. rhs Right hand side ប�� ត់ជុំ វ ិញ��ង�ន ែតែផ�ក�ង�� ំ
7. lhs Left hand side ប�� ត់ជុំ វ ិញ��ង�ន ែតែផ�ក�ងេឆ�ង
<html> <head><title>Table</title></head> <body> <br/><br/><br/> <table width="200" border="1" align="center"> <tr> <td>This text will be wrapped within this cell</td> <td nowrap>This text will not be wrapped with this cell</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 47 - HTML
8. box or border (Default) ប�� ត់ជុំ វ ិញ��ង�គប់ែផ�ក�ំ ងអស់
- Rules = area កំ នត់�បេភទប�� ត់ែដលស�ិតេ�ែផ�ក�ងក� ុ ង��ងែដល�ន�បេភទ
ដូ ច�ងេ��មៈ
1. none �� នប�� ត់ែផ�ក�ងក� ុ ង��ង
2. rows ប�� ត់េ�ែផ �ក�ងក � ុ ង��ង �នែតជួរេដក
3. cols ប�� ត់េ�ែផ �ក�ងក � ុ ង��ង �នែតជួរឈរ
បេង��តទំរង ់Web Page េ�យេ�����ស ់Tables
វ ិធី � ម��ក� ុ ង�របេង�តទំរង់ web page េ�យេ�ប��ស់ HTML <table> tag ។ �ងេ��ម
េនះ�ឧ�ហរណ៍ េ �យេ�ប Table ែដល�ន 3 rows និ ង 2 columns
<html> <head> <title>Sample HTML Layout</title> </head> <body> <table width="500" border="0"> <tr> <td colspan="2" style="background-color:#06F;"> <h1>Header</h1> </td> </tr> <tr valign="top"> <td style="background-color:#FC9;width:100px;text-align:top;"> <b>MENU</b><br /> Home<br /> About Us<br /> Contact Us<br/> Location </td> <td style="background-color:#EEEEEE;height:200px;width:400px;text-align:top;"> Content</td> </tr> <tr> <td colspan="2" style="background-color:#06F;text-align:center;"> Copyright © 2011 USEA Web</td> </tr> </table> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 48 - HTML
លទ �ផលៈ
បេង��តទំរង ់Web Page េ�យេ�����ស ់Div Elements
The div element is a block level element used for grouping HTML elements. �ងេ��មេនះ
�ឧ�ហរណ៍ េ�យេ�ប�� ស់ div element បេង �ត�ទំរង់ Website
<html> <body> <div id="container" style="width:500px; margin:0px auto;"> <div id="header" style="background-color:#03F;"> <h1 style="margin-bottom:0;">Header</h1></div> <div id="menu" style="background-color:#F99;height:200px;width:100px;float:left;"> <h2>Menu</h2><br /> Home<br /> About Us<br /> Contact Us<br/> Location </div> <div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;"> Content</div> <div id="footer" style="background-color:#03F;clear:both;text-align:center;"> Copyright 2011 USEA Web</div> </div> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 49 - HTML
លទ �ផលៈ
HTML Layout - Useful Tips
Tip: The biggest advantage of using CSS is that, if you place the CSS code in an external style sheet, your site becomes MUCH EASIER to maintain. You can change the layout of all your pages by editing one file.
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 50 - HTML
Frame អនុ �� តេ�យេយងេ ធ��រែចកនូ វ�� ំង window �េ�ច នែផ �ក េដ ម �ីប�� ញ pages
េ�ច នខុ ស�ៗ� ។ ឧ �ហរណ៍ េ�ក � ុង�� ំង window ែតមួយេយ ង�ច េធ��រែបងែចក�
៤ែផ�កេ ផ�ង ៗ�� េ�យ ែផ�ក�ងេល សំ�ប់�ក់ នូ វ logo �ក�មហ៊ុន ែផ �ក�ងេ ធ�ងសំ�ប់�ក់ � menu
សំ�ប់ link ចំ ែន កែផ�ក�ង�� ំ សំ�ប់ផ� ុ កពត៌�នេផ� ងៗ និ ងែផ�ក�ងេ��មសំ�ប់�ក់ copyright
សូមេ ម ល page �ងេ��មៈ
Frame �នមុ ខ�រដូ ច�ៈ
- Frame អនុ �� តិេ�យអ �កទ ស� � េម លេឃញ Web page េ�ច នក� ុ ងេ ពលែតមួ យ
- Frame នី មួ យៗ�ន Web page �� ល ខ់� ួ នេ ហយ�ចប�� ញ �មែផ �ករបស់ Window
េ�យឯក�ជ �
គុណវ បិត�ិរបស់ Frame
- Web developer �ត�វរក�ទុ ក HTML Document េ�ច ន
- ពិ �ក Print page �ំងមូ ល
1. �របេង�ត Frameset
- Frameset: �ត�វ�នេគគិត�� Window ែដល�នែ ផ�កតូចៗរបស់ � សំ �ប់ផ� ុ កពត័�នេផ�ង��
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 51 - HTML
- អ�ក�ត�វសំ េរចចិត��េតេ�ក� ុ ង Window មួ យែបងែចក�បុ៉�� នែផ�ក ? េហ យ Border �ន
លក�ណ : �៉ ងដូ ចេម �ច ? េហ យ�ន�រេ�ប��ស់ Scroll bar រឺេទ ?
- េ�េពលែដលអ�កបេង�ត Window អ�ក �ចផ�ល់ URL េ�េ�យែ ផ�កនី មួ យបៗ�� ប់មក��� យេ�
� Frames ។
ទំរង់ ទូ េ�
<frameset> � tag ែដល��ប់េ� Browser េដ ម�ីែបងែចក Window េ�� Rows រឺ Columns រឺ
ែបងែចក Rows ផង និ ង Columns ផង ។ <frameset> tag �ន Attributes ដូ ច�ងេ��មៈ
- rows = “r1, r2 ,r3,…...” �តំៃលែដ លខ័ ណ� េ�យស�� េក ��សេហ យ��ចេ�ប� “*”
�ចំ នួ ន ( គិត� Pixels) រ�ឺ�គរយេដ ម�ីកំ នត់កំ ពស់ ៃន Frame នី មួ យៗ
Ex: rows = “10%, 40%,*” => *=50%
- cols= “c1, c2 , c3, ……” �តំៃលែដ លខ័ ណ� េ� យស�� េក ��សេហ យ��ចេ�ប� “*”
�ចំ នួ ន ( គិត� Pixels) រ�ឺ �គរយេដ ម�ីកំ នត់ប�� យៃន Frame នី មួ យៗ ។
Ex: cols= “40%, *, 20%” Browser នឹងបំែលង “*” េ��តំៃល 40%
ចំ �ំ េយង�ចេ �ប “*” េល សពី មួ យេពល Browser ជួបស�� “*” �នឹ ងែបកែចកតំៃលែដលេ�
សល់ េស�ៗ�� ។
ឧ�ហរណ៍
header.html left.htm
<html> <head><title>Header</title></head> <body bgcolor=red><h1><center>Frame 1</center></h1></body> </html>
<html> <head><title>Menu</title></head> <body leftmargin=0 topmargin=0 bgcolor="#FF9966" text="white"> <h2> Frame 2<br/> Left </h2> </body></html>
<frameset rows= “r1, r2 ,r3,…...” cols= “c1, c2, c3 ,……” > <frameset rows= “r1, r2 ,r3,…...” cols= “c1, c2, c3 ,……”> ……………………………………………… </frameset> <frameset rows= “r1, r2 ,r3,…...” cols= “c1, c2, c3 ,……”> ……………………………………………… </frameset> <frame………> …………………………………………………………….. </Frameset>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 52 - HTML
right.html footer.htm
index.html
លទ �ផលៈ
<html> <head><title>Home page</title></head> <body> <h1> Frame 3<br/> Right </h1> </body> </html>
<html> <head><title>Header</title></head> <body leftmargin=0 topmargin=0 bgcolor="#0099CC" text="white"> <font color=blue size=5> Frame 4 :: Footer </font> </body> </html>
<html> <head><title>Frameset</title></head> <frameset rows="20%,*,10%" > <frame src="header.html"> <frameset cols="15%,*"> <frame src="left.html"> <frame src="right.html"> </frameset> <frame src="footer.html"> </frameset> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 53 - HTML
ចំ� ំ
- �បសិនេប frame �នប�� ត់ជុំ វ ិញ េ�ះ អ�កទ ស���ចព �ងី ក ឬប�ង�មទំ ហំ frame
�នេ �យ�ញ ប�� ត់ែដលេ �ព័ ទ�ជុំ វ ិញ េដ ម�ី�រ�រកុំេ �យអ�កទស� �� ញ�ន�ត�វបែន�ម
attribute noresize= “noresize” េ� េ�យ <frame> tag ។
- ប�� ូ ល <noframes> tag សំ�ប់ browsers ែដ លអត់�� ល់ frames
- េយងមិ ន�ចេ�ប��ស់ <body></body> tags �មួយ <frameset></frameset> tags
�នេឡយ។ ែត�បសិនេបេយងប�� ូ ល <noframes> tag ចូ លេដ ម� ី�ក់ អត�បទសំ�ប់ browsers
ែដលអត់�� ល់ frames េ�ះ េយង�ត�វែតបែន�ម <body></body> tags ។
2. �រេ�ប��ស់ Attribute របស់ Frameset
2.1. Attribute Border
�គឺ�ប�� ត់ែដលខ័ ណ� ែច ករ�ង Frame និ ង Frame ។ �បសិនេបេយងមិ នច ង់ េ�យ �ន
border េពលែដលប�� ញេល browser េទេ យង�ត�វកំ ណត់េ�យតំៃលរបស់ border = 0 ។
<html> <head><title>Frame Border</title></head> <frameset rows="20%,*,10%" border="0"> <frame src="header.html"> <frameset cols="15%,*"> <frame src="left.html"> <frame src="right.html"> </frameset> <frame src="footer.html"> </frameset><noframes></noframes> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 54 - HTML
2.2. Attribute FrameBorder
�ខុ សពី attribute border �តង់ ���នតំៃ លែតពីរបុ៉េ�� ះគឺ 1 រ ឺ0 និ ង yes រ ឺno េ�បសំ�ប់
កំ ណត់� Frameborder �ន រឺមិ ន�ន។
2.3. Attribute BorderColor
េដ ម� ីកំ ណត់ពណ៌ េ�យ border របស ់frame េយ ងេ�ប� �ស់ attribute bordercolor
<frameset bordercolor="color_name | color_code">
<html> <head><title>Frame Border</title></head> <frameset rows="20%,*,10%" frameborder="no"> <frame src="header.html"> <frameset cols="15%,*"> <frame src="left.html"> <frame src="right.html"> </frameset> <frame src="footer.html"> </frameset><noframes></noframes> </html>
<html> <head><title>Frame Border</title></head> <frameset rows="20%,*,10%" bordercolor="#0000FF" border="7"> <frame src="header.html"> <frameset cols="15%,*"> <frame src="left.html"> <frame src="right.html"> </frameset> <frame src="footer.html"> </frameset><noframes></noframes> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 55 - HTML
3. �រេ�ប��ស់ Attribute របស ់Frame
<frame></frame> � tag មួ យែដ លេ យងេ�ប��ស់�មួយនឹ ង frameset ។ Frameset េ�បសំ�ប់
ែបងែច កៃផ �របស់ Window �េ�ច នែ ផ �ក ចំ ែណ កឯ Frame tag េ�បសំ�ប់ប�� ញ page េផ �ង ៗ។
Attribute របស ់Frame �នៈ
- src: កំ ណត់�ស័យ �� នរបស ឯ់ក �រែដល�ត�វប�� ញ
- name: សំ�ប់�ក់ េ�� ះេ�យ frame ែដ លេ�� ះេន ះេយងនឹ ង យកេ �េ�បេ�េពល ែដល
េយងេ� Page េផ �ងៗ មកប�� ញេ�ក� ុ ង frame
- bordercolor: សំ�ប់កំ ណត់ពណ៌ border របស ់frame
- scrolling: េ�បសំ�ប់កំណត់នូ វ Scrollbar របស ់frame
scrolling = “yes/no/auto”
- yes : �ន Scrollbar
- no : មិ ន�ន Scrollbar
- auto : ប�� ញ Scrollbar េ�េពលែដលអត�បទេពញៃផ � frame (default)
- noresize: មិ នអ នុ �� តិេ�យអ�កទ ស�� ព� ងី ក របឺ�ង�មទំ ហំរបស់ frame
<html> <head><title>Frame </title></head> <frameset rows="20%,*,10%" bordercolor="#0000FF" border="7"> <frame src="header.html" marginwidth="30"> <frameset cols="15%,*"> <frame src="left.html" noresize bordercolor="#FF0000" scrolling="auto"> <frame src="right.html" name="right" scrolling="auto"> </frameset> <frame src="footer.html" bordercolor="yellow"> </frameset> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 56 - HTML
4. �រេ�ប��ស់ Link េ��ន់ ទី �ំង�មួយេ�ក� ុង Frame
េនះ�ចំនុ ចមួ យដ៏ សំ �ន់ េ�ក� ុ ង frame ែដ លេយង�ត�វេ�ប�ញឹក�ប់េ�េព លែដលេ យង
រច�េគហ ទំ ព័រេ� យេ�ប frame ។ �អនុ �� តិេ�យេ យងេធ ��រ link េ� យេ� page
មក�ក់ �តង់ ទី �ំង�មួ យ�ក់ �ក់ ។ េ�ក� ុងែ ផ�កេនះេ យងកំ នត់ Target attribute េ�ក� ុង <A>
tag េ�� ះេ��ន់ Browser េដ ម� ីេ�យ� Load ឯក�របស់ HREF Attribute េ��ន់ Window ឬ
Frame � មួ យ�៉ ងច�ស់ � ស់ ។
Ex: <a href= “about.html” target= “right”>About Us</a>
េ�េពល Load HTML Document េ� about.html េ� យប�� ញេ �ក� ុង Window ឬ Frame
ែដល�នេ�� ះ “right” េ�េពលអ�កេ �ប�� ស់ ចុ ច About Us Link។ �បសិនេប Frame �� នេ�� ះ
“right” េ�ះេទ Browser និ ងបេង�ត Window ថ�ី េហយកំ នត់េ�� ះ�� “right” ។
<base target= “target_name”> សំ�ប់បេង�ត Target �គប ់ Links �ំងអស់េលែ លងែត Target
�ែដ ល�នេ�� ះ ។
Special Targets:
Browser support 4 Target ពិ េសសៗែ ដល �ប់េផ� មេ �យ ស�� “_” ។ �រេ�ប��ស់ “_”
�នែតចំ េ�ះ Target �ំងេ�ះ ែតបំុ៉េ�� ះ ចំ េ�ះ Target េផ �ងេទ�តអ�កេ �បស�� េនះ េពល
Browser ជួប�មិ ន�� ល់េទ។
_blank : �ត�វ�នេគេ�ប�� ស់ េដ ម� ីេ� យ Browser �ប់េផ� មេបក Window ថ�ី ។ �
�ទូេ�� នេគេ�បសំ�ប់ Window ែដ ល�� នេ�� ះ។
_self : �បសិនេប <A>tag អត់�ន target value �គឺ� Default target ។ Target េនះ
ចង � ុលេ��ន់ Current Frame or Window
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 57 - HTML
_parent : �នឹ ងេបក�រ Link េ�េល�� ំង window ដែដលេ�យបំ�ត់ frame ែដ ល�ន
ពី មុ នម ក។
_top : ��នលក �ណ ះ�សេដ� ងេ �នឹ ង _parent ែដរែត�ខុ សេ�េព លែដ លេយង
េ�ប��ស់ ��មួយនឹ ង nested frameset
index.html
<html> <head><title>USEA</title></head> <frameset rows="20%,*,10%" bordercolor="#0000FF" border="7"> <frame src="header.html" marginwidth="30"> <frameset cols="15%,*"> <frame src="left.html" noresize bordercolor="#FF0000" scrolling="auto"> <frame src="right.html" name="right" scrolling="auto"> </frameset> <frame src="footer.html" bordercolor="yellow">
</frameset> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 58 - HTML
left.html
aboutus.html
contact.html
<html> <head><title>Menu</title></head> <body leftmargin=0 topmargin=0 bgcolor="#FF9966" text="white"> <a href="home.html" target="right">
Home </a> <br/> <a href="aboutus.html" target="right">
About Us </a> <br/>
<a href="contact.html" target="right">Contact Us</a> <br/> </body> </html>
<html> <head><title>About Us</title></head> <body leftmargin=0 topmargin=0 bgcolor="#FF9966" text="white"> <h1> About Us Page</h1> <p> About USEA </p> </body> </html>
<html> <head><title>Contact Us</title></head> <body leftmargin=0 topmargin=0 bgcolor="#FF9966" text="white"> <h1> Contact Us Page</h1> <p> Email: [email protected] | Tel: 012 561 373 </p> </body></html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 59 - HTML
Using iframe
An iframe is used to display a web page within a web page
Syntax for adding an iframe:
- URL points to the location of the separate page
- Width and height: set width and height to iframe in pixels by default, but they can also be in
percent (like “60%”)
- frameborder attribute specifies whether or not to display a border around the iframe
Example:
<iframe src="URL" width = “w” height = “h” frameborder= “n” ></iframe>
<html> <head><title>Using iframe</title></head>
<body> <iframe src="http://www.fbis.edu.kh/" width="500"
height="300"></iframe> <p>Some older browsers don't support iframes.</p> <p>If they don't, the iframe will not be visible.</p>
</body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 60 - HTML
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 61 - HTML
�ធម��េយ ងេ ធ��របេង�តេគហទំ ព័រមិនែ មន�តឹមែតប�� ញ អ�កេ �ប�� ស់ េ�យេឃងែត
ព័ត៌�ន ឬក៏ ផលិតផលេផ� ងៗេ�ះេទ គឺេយង�ចេធ ��រ�បមូ លព័ត៌�ន ពី អ�កេ�ប��ស់េ�យ
ផ�ល ល់ទ��ពេ�យ អ �កេ �ប��ស់ ចុ ះេ�� ះ រ ឺក៏ ទិ ញផលិតផលេផ �ងៗ�េដ ម ។ លក�ណ ះ� ំងអ ស់
េនះគឺ�ចេ ធ� េ��ន�ត�វពឹ ងែផ �កេល Form ។ Form គឺ��តុមួ យ ែដ លេ យងេ�បសំ�ប់
បេង�ត�ទំរង់ ប�� ូ លទិ ន�ន័ យ េដ ម�ីប�� ូ នព័ត៌�នេ��ន់ Server េដ ម� ីេធ��រ Process េយ ង�ច
សរេសរ�តុេផ�ងៗរបស់ Form ដូ ច� Textbox, Password, Button … �នេ �ចេ �� ះរ�ង <form>
និ ង </form> ។
1. ទំរង់ទូ េ� សំ�ប់បេង�ត Form
- name : កំ នត់េ�� ះេ�យ Form
- action = “URL” : កំ នត់ទី �ំងែដល�ត�វយកទិ ន�ន័ យេ � �ក់
- method = “Post | Get” : គឺ�វ ិធី � �ស�ក� ុ ង�រប�� ូ នទិ ន �ន័ យេ ��ន់ Server (Default :
Get)
2. �របេង�ត Textbox
Textbox េយងេ�បសំ�ប់ visitor េធ ��រប�� ូ លទិ ន�ន័ យែដល �នែតមួ យប�� ត់បុ៉េ�� ះ
value= “Default” កំ នត់តំៃល Default សំ�ប់ Textbox
size = “n” កំ នត់ទំ ហំៃន Textbox ែដ ល�ត�វនឹ ង�បែវង n Characters
maxlength= “n” កំ នត់ចំ នួ នតួអក�រេ�ច នបំផុតែដលប�� ូ លេ �ក� ុ ង Textbox
<form name= “name_ of_ form” action= “URL” method= “Post |Get” > ……………….Form Elements …………………… ……………….Form Elements …………………… ……………….Form Elements …………………… </Form>
<input type="text" name="Field_Name" value="Default Value" size="n" maxlength="n" readonly disabled >
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 62 - HTML
readonly កំ នត់មិ នេ�យអ�កេ �ប�� ស់េធ��រែកែ�បគឺ�ចែត�នបុ៉េ�� ះ
disable កំ នត់េ�យមិ ន�ចចុ ច�ន ឬេធ � សកម ��ពេផ� ងៗ�ន
3. �របេង�ត Password Boxes
Password Boxes �នលក�ណះដូ ច�� េ �នឹ ង Textbox ែដរ ែតខុ ស�តង់ �តំៃលែ ដល
េយងប�� ូ ល ��ស�� Asterisks “*” រ�ឺ bullets
<html> <head><title>Sign Up</title> </head> <body> <form name="form1" method="post" action=""> Frist Name: <input type="text" name="FirstNameTextbox" size="50" maxlength="50" ><br/><br/> Last Name: <input type="text" name="LastNameTextbox" size="50" maxlength="50" > </form> </body> </html>
<html> <head><title>Log In</title></head> <body> Log In <form name="form1" method="post" action=""> User Name: <input type="text" name="username" size="30"><br/><br/> Password : <input type="password" name="password" size="30"> </form> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 63 - HTML
4. �របេង�ត TextArea
TextArea ខុ សពី Textbox �តង់ ���ចផ� ុ កអត�បទមួ យឬ េ�ច នប�� ត់ េហយ �ច
ព�ងី ក�នេ� េពល�ត�វ�រ
rows = “n” �ចំនួ នជួរេដកេ�ក� ុ ង Textarea
cols = “n” �បែវង Textarea ែដលេយង �ក់ តួអក�រ�ន
wrap អនុ �� តិេ�យអត�បទ�ចចុ ះប�� ត់�នេ �ក� ុ ងែដន កំ នត់របស់
Textarea
- off ចុ ះប�� ត់លុះ��ែតេយងេ�ប Key Enter
- hard | soft ចុ ះប�� ត់េ�យស�័ យ�បវត�ិ
<textarea name="Field Name" rows="n" cols="n" wrap="off | hard | soft">
…………… Default Text …………………. </textarea>
<html> <head> <title>Contact Us</title> </head> <body> Contact Us <form name="form1" method="post" action=""> Full Name: <input type="text" name="fullname" size="40"> <br/><br/> Email: <input type="text" name="email" size="40"><br/><br/> Comment: <textarea name="comment" rows="5" cols="50" wrap="hard"></textarea> </form> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 64 - HTML
5. �របេង�ត Radio Button
Radio Button េ�បសំ�ប់េ�យអ �កទស� � �ចេ � ជ ស េរ សតំៃល�នែតមួ យក� ុ ងចំ េ�ម
តំៃល�េ�ច ន។
name = “Field Name” : សំ�ប់កំនត់េ�� ះេ�យ Radio Button
value= “Field Value” : សំ�ប់កំនត់តំៃល
checked : សំ�ប់កំ នត់� Select រឺក៏ មិ ន Select
<input type="radio" name="Field Name" value="Field Value" checked >
<html> <head><title>Contact Us</title></head> <body> Contact Us <form name="form1" method="post" action=""> Full Name: <input type="text" name="fullname" size="40"> <br/><br/> Sex:<input type="radio" name="sex" value="Male" checked> Male <input type="radio" name="sex" value="Female">Female<br/><br/> Email: <input type="text" name="email" size="40"><br/><br/> Comment: <textarea name="comment" rows="5" cols="50" wrap="hard"></textarea> </form> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 65 - HTML
6. �របេង�ត Checkboxes
អនុ �� តិេ�យអ �កទស� ��ច �ន ជំ េរ សេ�ចនក� ុ ងេពលែតមួ យ
ឧ�ហរណ៍
7. �របេង�ត Hidden Field
Hidden Fields មិ ន�នប�� ញេ �យអ�កទ ស��េ ម លេឃញេ ល browser window េទ ។
�រះ សំ� ន់ របស់ Hidden Fields គឺេ�បេដ ម� ីរក�ទុកតំៃលេផ�ងៗ សំ�ប់ប�� ូ នពី Form ។
<input type="checkbox"
name="Field Name" : កំនត់េ��ះរបស់ Checkbox
value="Field Value" : កំនត់តំៃលរបស់ Checkbox
checked> : កំនត់ Checkbox � Select រ�ក៏មិន Select
<html> <head><title>Checkbox Example</title></head> <body> <form name="form1" method="post" action=""> Which course do you like?<br/><br/> <input type="checkbox" name="course" value="HTML" checked> HTML <input type="checkbox" name="course" value="HTML5"> HTML 5 <input type="checkbox" name="course" value="css2"> CSS 2 <input type="checkbox" name="course" value="css3"> CSS 3 <input type="checkbox" name="course" value="js"> Javascript </form> </body> </html>
<input type="hidden" value="Field Value" name="Field Name" >
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 66 - HTML
8. �របេង�ត File
File អនុ �� តេ�យេយងប�� ូ លនូ វ ឯក�រ (File) ពី ក � ុង�៉ ស ុីនរបស េ់យង េ��ន់
�៉ ស ុីន Server
9. �របេង�ត Select
Select េ�បេដ ម� ីបេង�ត Drop down menus េហយ Select អនុ �� តិេ�យអ�កទ ស� �
�ចេ �ជ សេរ សមួ យ រ ឺេ�ច ន Items ពី List េហ យ�ច េ�ប Optgroup េ�បេដ ម�ីបេង�ត�ក �មៃន Items
េ�ក� ុង�តុ Select ។
- multiple : �ចេ�ជ សេរ ស Option �ន�ប់ពីមួ យេឡងេ �
- size = “n” : កំ នត់ចំ នួ ន Items ែដ ល�ត�វប�� ញ �បសិនេបេយង មិន�នកំ នត់
េ�ះចំ នួ ន Item ែដ ល�ត�វប�� ញគឺ�នែតមួ យគត់
- selected : � Attribute េ�បេ�ក� ុ ង Option េដ ម� ីេ�ជ សេរ ស Option �មួ យ
<html> <head><title>Upload</title></head> <body> <form name="form1" method="post" action="" enctype="multipart/form-data"> Upload your photo: <input type="file" name="upload" size="20"> </form> </body> </html>
<select name="Field Name" size="n" multiple > <option value="value1"> Text 1</option> <option value="value2" selected>Text 2</option> ………………………………………………. ………………………………………………. <option value="valuen"> Text n </option> </select>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 67 - HTML
�រេ�ប�មួយ Optgroup
Optgroup េ�បេដ ម� ីបេង�ត� �ក�មៃ ន items េ� ក� ុង Select
<html> <head><title>Select Menu</title></head> <body> <form name="form1" method="post" action=""> Choose your Language<br/> <select name="language" size="1"> <option value="html">HTML</option> <option value="html5" selected>HTML 5</option> <option value="css2">CSS 2</option> <option value="css3">CSS 3</option> <option value="js">Javascript</option> </select> </form> </body> </html>
<html> <head><title>Select Menu</title></head> <body> <form name="form1" method="post" action=""> Type of Website<br/> <select name="language"> <optgroup label="Static Website"> <option value="html">HTML</option> <option value="html5" selected>HTML 5</option> <option value="css2">CSS 2</option> <option value="css3">CSS 3</option> <option value="js">Javascript</option> </optgroup> <optgroup label="Dynamic Website"> <option value="php">PHP</option> <option value="asp">ASP</option> <option value="aspnet">ASP.NET</option> <option value="jsp">JSP</option> </optgroup> </select> </form> </body></html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 68 - HTML
10. �របេង�ត Button
ក� ុ ង�� HTML េយង�ចបេង�ត Button �នចំ នួ ន ៤�បេភទ ៈ
Submit button េ�បេដ ម� ីេធ��រប�� ូ ន�ល់ ទិ ន�ន័ យេផ �ងៗ េ��ន់ ចំ នុ ចដូ ចែដ ល�ន
កំ នត់េ�ក � ុង Action Attribute ៃន Form tag ។
Example:
<input type="submit" value="Field Value" name="Field Name" disabled >
<html> <head><title>Contact Form</title></head> <body> Contact Us <form name="form1" method="post" action="contact.php"> Full Name: <input type="text" name="fullname" size="40"> <br/><br/> Sex:<input type="radio" name="sex" value="Male" checked> Male <input type="radio" name="sex" value="Female">Female<br/><br/> Email: <input type="text" name="email" size="40"><br/><br/> Comment: <textarea name="comment" rows="5" cols="50" wrap="hard"></textarea> <br/><br/> <input type="submit" value="Submit" name="Submit"> </form> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 69 - HTML
Reset button �នលក�ណ ះ�ប�ក់ �បែហលេ�នឹ ង Submit Button ែដរែតខុ ស�តង់ �
េគេ�ប� េដម� ីលុបេ�លនូ វតំៃ ល� ស់ ែដ ល �នេ��គប់�តុរបស់ Form ។
Example:
<input type="reset" value="Field Value" name="Field Name" disabled >
<html> <head>
<title> Contact Form
</title> </head>
<body> Contact Us <form name="form1" method="post" action="contact.php"> Full Name: <input type="text" name="fullname" size="40"> <br/><br/> Sex:<input type="radio" name="sex" value="Male" checked> Male <input type="radio" name="sex" value="Female">Female<br/><br/> Email: <input type="text" name="email" size="40"><br/><br/> Comment: <textarea name="comment" rows="5" cols="50" wrap="hard"></textarea> <br/><br/> <input type="submit" value="Submit" name="Submit"> <input type="reset" value="Reset" name="Reset"> </form> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 70 - HTML
Button ��នលក �ណះខុ សពី Submit និ ង Reset េ��ះ �ពុំ �ន�រកំ នត់ Function
ច�ស់ � ស់េទ។ េយង�ច�ក់ Script េល Button េដ ម�ីេ�យ�ដំ េណ រ�រេ�េ ពល �ន Events
េកតេឡង ដូ ច� Event on Click �េដម ។
Image Button �បសិនេបេយងមិ នចូ លចិត�េ�ប button ែដ ល�នលក�ណ :ដូ ច�
Submit េ� ះេទ េយង �ចេ�ប�� ស់ �បេភទ�រូប�ពជំ នួ សេ�យ Button Submit ។ េ�េពលេ យ ង
ចុ ចេលរូប�ព េពលេ �ះ �ដំេណ រដូច�� េ�នឹ ង button Submit ែដរ។
<input type="button" value="Field Value" name="Field Name" disabled >
<input type="image" src="URL" name="Field Name" value="Field Value" alt="Description">
<html> <head><title>Log In</title></head> <body> Log In <form name="form1" method="post" action="login.php"> User Name: <input type="text" name="username" size="30"> <br/><br/> Password :<input type="password" name="password" size="30"><br/><br/> <input type="image" src="go.gif" name="btngo" value="GO" alt="Click Go"> <input type="button" value="Cancel Button" name="btnClick"> </form> </body></html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 71 - HTML
11. �រេ�ប�� ស់ Fieldset
The <fieldset> tag is used to logically group together elements in a form.
The <fieldset> tag draws a box around the related form elements.
The <legend> tag defines a caption for the fieldset element.
Image Button Button
<html> <head><title>Log In</title></head> <body> <form name="form1" method="post" action="login.php"> <fieldset style="width:400px; height:180px; text-align:center; background-color:#CCC"> <legend align="center">Membership Login</legend><br/> User Name:<input type="text" name="username" size="30"> <br/><br/> Password : <input type="password" name="password" size="30"><br/><br/> <input type="submit" value="Log In" name="btnLogin"> </fieldset> </form> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 72 - HTML
សំេ លង និ ង វ ិេដអូ ក៏�ែផ�កមួ យែដលជួ យេ� យេគហទំ ព័ររបស់ េយងទទួ ល �ន
�ប��បិយ�ពពី អ�ក ទស�� �ពិេសសគឺបេង� នេ �ភណ� �ពដល េ់គហទំ ព័រេយ ង។ សំ�ប់
Browser ជំ �ន់ ថ�ី ៗគឺ អនុ �� តេ�យេយង េធ��រេ�ជ សេរ សយក�បេភទ file �េ�ច នម កេធ��រ
រច�នូ វេគហទំ ព័រដូ ច� file ែដ ល�ន extension: .wav, .aiff, .au, .mid, .mp3, .mp4, .swf, .ra, .ram,
.avi..... ។ល។
1. Sound
Displaying audio in HTML is not easy!
You must add a lot of tricks to make sure you audio files will play in all browsers (Internet Explorer, Chrome, Firefox, Safari, Opera) and on all hardware (PC, Mac , iPad, iPhone).
Format File
MIDI .mid .midi
RealAudio .rm .ram
Wave .wav
WMA .wma MP3 .mp3
.mpga
What Format To Use?
The WAVE is the most popular uncompressed sound format on the Internet, and it is supported by all popular browsers. If you want uncompressed sound (music or speech) to be available to all your visitors, you should use the WAVE format.
The MP3 format is the newest format for compressed recorded music. The term MP3 has become synonymous with digital music. If your website is about recorded music, the MP3 format is the choice.
Using The <embed> Element
The purpose of the <embed> tag is to embed multimedia elements in HTML pages.
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 73 - HTML
ទំរង់ ទូ េ�
Example
Problems:
The <embed> tag is unknown to HTML 4. Your page will not validate correctly. If your browser does not support the file format, your audio will not play. If you convert your file to another format, it will still not play in all browsers.
1.1 Using the <audio> Element
The <audio> element is an HTML 5 element, unknown to HTML 4, but it works in new browsers.
<embed src="URL" : កំ នត់ទី�ំងរបស់ Sound file
width="w" : ទំ ហបំេ�� យ
height="h" : ទំ ហ ំកំ ពស់
autostart="true | false" : កំ នត់�េ�យ��ប់េផ� ម េលង រ ឺមិ នេ លង
loop="true | false" : កំ នត់ចំនួ នជុំ សំ�ប់ Play
align="left | right"> : សំ�ប់តំរឹម េឆ�ង �� ំ
</embed>
<html> <head><title>Multimedia</title></head> <body> <embed src="02_Fanta_Calltune chlong chleuy.mp3" width="200" height="150" autostart="true" loop="true" align="absmiddle"></embed> This is sound Test </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 74 - HTML
Example
The example above uses an Ogg file, to make it work in Firefox, Opera and Chrome. To make the audio work in Internet Explorer and Safari, a file of the type MP3 is added.
Currently, there are 3 main formats for the audio element:
Format IE 9 Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0
Ogg Vorbis No Yes Yes Yes No
MP3 Yes No No Yes Yes
Wav No Yes Yes Yes Yes
Problems:
You must convert your videos to many different formats. The <audio> element does not work in older browsers. The <audio> element does not validate in HTML 4 and XHTML.
The Best HTML Solution
Example
The example above uses 4 different audio formats. The HTML 5 <audio> element tries to play the video either as ogg or mp3. If this fails, the code "falls back" to try the <embed> element. If this also fails, it displays an error.
Problems:
You must convert your videos to many different formats. The <audio> element does not validate in HTML 4 and XHTML. The <embed> element does not validate in HTML 4 and XHTML.
NOTE: Using <!DOCTYPE html> solves the validation problem.
1.2 Using the Yahoo Media Player
Using the Yahoo Media Player is a different approach. You simply let Yahoo do the job of playing your songs.
<audio controls="controls"> <source src="song.mp3" type="audio/mpeg" /> <source src="song.ogg" type="audio/ogg" />
Your browser does not support this audio </audio>
<audio controls="controls" height="50px width="100px"> <source src="song.mp3" type="audio/mpeg" /> <source src="song.ogg" type="audio/ogg" /> <embed height="50px width="100px" src="song.mp3" /> </audio>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 75 - HTML
Example
1.3 Using Google
Example
2. Background Sound (Internet Explore Only)
Background sound �នន័ យ��សំេ លងែ ដលនឹ ង េល ងេ�េព លែដ លេយ ងេបក
webpage �ពិេសសគឺ�មិ នប�� ញនូ វ form control េឡយ។
Example
3. Adding a link to a sound
េយង�ចេធ ��រ Link េ��ន់ sound file �នេ �យ��ន់ ែតកំ នត់ URL របស ់href
attribute ៃន <a></a> tag េ��ន់ ទី �ំង file sound េ� យ�ន �តឹម�ត�វ។
<bgsound src="URL" : កំ នត់ទី �ំង file sound
loop="n"> : កំ នត់ចំ នួ នដង ៃនសំេលងែ ដល�ត�វេលង
�បសិនេប n = -1 �នន័ យ��ែលងរហូត
<html> <head><title>Multimedia</title></head> <body> <h1> Test Backgournd Sound</h1> <bgsound src="02_Fanta_Calltune chlong chleuy.mp3" loop="-1"> </body> </html>
<a href="song.mp3">Play Song</a> <script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>
<a href="song.mp3">Play Song</a> <embed type="application/x-shockwave-flash" wmode="transparent" src="http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=song.mp3" height="27" width="320"></embed>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 76 - HTML
4. �រប��ូ ល Video File េ� ក� ុង Webpage
ឯក �រ Video file ��បេភទ ឯក�រ�ន�ំងសំ េលងនិ ងរូប�ព
េយ ង�ចេ �ប�� ស់ Video file មួ យចំ នួ ន ដូ ច�ៈ
Description Extension
Quick Time Movie .mov or .qt
MPEG Movie .mpeg or .mpg Audio-Video Interleaved .avi
Windows Media movies . wmv
Flash .swf Mpeg-4 .mp4
4.1 The <embed> Tag
Example
<html> <head><title>Multimedia</title> </head> <body> <h1> Test Link Sound</h1> <a href="02_Fanta_Calltune chlong chleuy.mp3">My Favorite Song</a> </body> </html>
េ�េពលចុ ចេ ល Link �នឹ ងេ�េបកក ម�វ ិធី សំ�ប់�ក់ ចំ េរ�ងរួចេធ ��រ play
<html> <head><title>Video</title></head> <body> <h2>My Favorite Song</h2> <embed src="Preap Sovath.avi" width="400" height="300" autostart="true" loop="true" align="absmiddle"></embed> </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 77 - HTML
Problems The <embed> tag is unknown to HTML 4. Your page will not validate correctly. If the browser does not support Flash, your video will not play. iPad and iPhone cannot display Flash videos. If you convert the video to another format, it will still not play in all browsers.
4.2 Using the <video> Tag
The <video> element is new in HTML 5. The purpose of the <video> tag is to embed video elements in HTML pages. The following HTML fragment displays a video in ogg, mp4, or webm format embedded in a web page:
Problems: You must convert your videos to many different formats. The <video> element does not work in older browsers. The <video> element does not validate in HTML 4 and XHTML
The Best HTML Solution: HTML 5 + <object> + <embed>
<video width="320" height="240" controls="controls"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> <source src="movie.webm" type="video/webm" /> Your browser does not support the video tag. </video>
<video width="320" height="240" controls="controls"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> <source src="movie.webm" type="video/webm" /> <object data="movie.mp4" width="320" height="240"> <embed src="movie.swf" width="320" height="240"> Your browser does not support video </object> </video>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 78 - HTML
The example above uses 4 different video formats. The HTML 5 <video> element tries to play the video either in mp4, ogg, or webm formats. If this fails, the code "falls back" to try the <object> element. If this also fails, it "falls back" to the <embed> element.
Problems:
You must convert your videos to many different formats. The <video> element does not validate in HTML 4 and XHTML. The <embed> element does not validate in HTML 4 and XHTML.
NOTE: Using <!DOCTYPE html> solves the validation problem.
5. Adding a Link to External Video
េយង�ចេធ ��រ Link េ��ន់ video file �នេ�យ ��ន់ ែតកំ នត់ URL របស់ href
attribute ៃន <a></a> tag េ��ន់ ទី �ំង file video េ�យ�ន �តឹម�ត�វ។
6. Playing a YouTube Video in HTML
The easiest way to display videos (others or your own) in HTML is to use YouTube.If you
want to display a video in a web page, you can upload the video to YouTube and insert HTML code to
display the video in your web page.
<html> <head><title>Video Link</title> </head> <body> <h1> Link to Video</h1> <a href=" Preap Sovath.avi">Preah Sovat – Bek Teang bangkham</a> </body> </html>
េ�េពលចុ ចេ ល Link �នឹ ងេ�េបកក ម�វ ិធី សំ�ប់�ក់ ចំ េរ�ងរួចេធ ��រ play
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 79 - HTML
Example
7. Embedding Windows Media
8. Embedding Flash
9. Creating a Marquee (for Internet Explorer Only)
The marquee element is unique to Internet Explorer. It displays HTML content in a scrolling
region on the page.
<object width="100%" height="100%" type="video/x-ms-asf" url="3d.wmv" data="3d.wmv" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"> <param name="url" value="3d.wmv"> <param name="filename" value="3d.wmv"> <param name="autostart" value="1"> <param name="uiMode" value="full" /> <param name="autosize" value="1"> <param name="playcount" value="1"> <embed type="application/x-mplayer2" src="3d.wmv" width="100%" height="100%" autostart="true" showcontrols="true" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"></embed> </object>
<object width="300" height="150" id="flash1" name="flash1“ classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">
<param name="movie" value="test.swf"> <param name="quality" value="high" > <embed src="test.swf" width="300" height="150" id="flash1"
name="flash1“quality="autohigh" bgcolor="#ffffff" type="application/x-shockwave-flash" ></embed> </object>
<html> <body>
<iframe width="420" height="315" src="http://www.youtube.com/embed/EXkfU1klbJU" frameborder="0" allowfullscreen></iframe>
</body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 80 - HTML
Example
<marquee behavior="scroll | slide | alternate" direction="left | right | up | down" loop="-1 | n" width="w" height="h" bgcolor="color_name | color_code" hspace="n" vspace="n" scrolldelay="n" scrollamount="n" > Scrolling Text </marquee>
<html> <head><title>Scrolling Text</title> </head> <body> <h1> Marquee Tag</h1> <marquee behavior="scroll" direction="right" loop="-1" width="500" height="30" bgcolor="#0099FF" scrollamount="10"> Welcome to Unverisity of South-East Asia </marquee> </body></html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 81 - HTML
The head element is a container for all the head elements. Elements inside <head> can include
scripts, instruct the browser where to find style sheets, provide meta information, and more.The
following tags can be added to the head section: <title>, <base>, <link>, <meta>, <script>, and
<style>.
1. title Element
The <title> </title> tag េ�បសំ�ប់កំនត់ចំនង់ េជ ងេ�យ Webpage ។ title element is required
in all HTML/XHTML documents ។ េយ ងេ�ប� �ស់ title element េដ ម� ី:
កំ នត់ចំ នងេ ជ ងក� ុង the browser toolbar
ផ�ល ន់ូ វចំ នងេ ជ ងេ�េពល ែដ លេ យង added to favorites
ប�� ញចំ នងេ ជ ងសំ�ប់ page in search-engine results
Example :
2. base Element
The <base> tag specifies a default address or a default target for all links on a page:
<html> <head> <title>Title of the document</title> </head> <body> The content of the document...... </body> </html>
<head> <base href="http://www.usea.edu.kh/images/" /> <base target="_blank" /> </head>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 82 - HTML
3. link Element
The <link> tag សំ�ប់កំ នត់ទំ �ក់ ទំ នងរ�ង HTML document និ ង resource �ងេ �� . The
<link> tag គឺ�គេ�ច នេ�បសំ�ប់េធ ��រ�� ប់េ��ន់ style sheets:
4. style Element
The <style> tag គឺេ�បសំ�ប់កំ នត់ style information សំ�ប់ an HTML document ។ េ�ក� ុង
style element you specify how HTML elements should render in a browser:
5. meta Element
The <meta> tag provides metadata about the HTML document. Metadata is information about
data. Metadata will not be displayed on the page, but will be machine parsable. Meta elements are
typically used to specify page description, keywords, author of the document, last modified, and other
metadata. <meta> tag always goes inside the head element.
Keywords for Search Engines
Some search engines will use the name and content attributes of the meta element to index your
pages. The following meta element defines a description of a page:
The following meta element defines keywords for a page:
Note: A lot of webmasters have used <meta> tags for spamming, like repeating keywords (or
using wrong keywords) for higher ranking. Therefore, most search engines have stopped using <meta>
tags to index/rank pages.
<head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head>
<head> <style type="text/css"> body {background-color:yellow} p {color:blue} </style> </head>
<meta name="description" content="Free Web tutorials on HTML, CSS, XML" />
<meta name="keywords" content="HTML, CSS, XML" />
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 83 - HTML
Controlling other Information
You can also add information to your page about who wrote it, what program was used to
generate the HTML code and if it is copyrighted. Note, however, that search engines do not currently
use this information and browser do not display it.
<meta name= “author” content= “name”>
<meta name= “generator” content= “program”>
<meta name= “copyright” content= “copyright info”>
Specifying Character Encoding with <meta>
The <meta> tag is also used to specify the character encoding for your documents
Automatic Document Refresh with <meta>
The <meta> tag can also be used to force a browser to automatically reload a document
browser will wait 10 seconds before reloading the current document.
6. script Element
The <script> tag is used to define a client-side script, such as a JavaScript. The script element
either contains scripting statements or it points to an external script file through the src attribute.
Common uses for JavaScript are image manipulation, form validation, and dynamic changes of
content.
The script below writes Hello World! to the HTML output:
noscript Element
The <noscript> tag is used to provide an alternate content for users that have disabled scripts in
their browser or have a browser that doesn’t support client-side scripting. The noscript element can
contain all the elements that you can find inside the body element of a normal HTML page. The
<script type="text/javascript"> document.write("Hello World!") </script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="10 url=http://www.google.com/" />
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 84 - HTML
content inside the noscript element will only be displayed if scripts are not supported, or are disabled
in the user’s browser:
7. Submit Your Site to Search Engines
Web search engines (like Google) automatically add new web sites to their search index every
time they crawl the web.
If your web site is new and unknown, it may take some time before your site is "discovered".
Luckily most search engines invites you to submit your site: *
Google: http://www.google.com/addurl.html
Yahoo: http://search.yahoo.com/info/submit.html
Bing: http://www.bing.com/webmaster/SubmitSitePage.aspx
Open Directory: http://www.dmoz.org/help/submit.html
Normally you will have to enter the full URL of your site including the http:// prefix.
Example: http://www.usea.edu.kh/
When you submit your site to a search engine, you only need to specify the top-level (home)
page. You do not need to submit each page. The search engine will find the rest based on your links
(keep your navigation menus tidy).
<script type="text/javascript"> document.write("Hello World!") </script> <noscript>Sorry, your browser does not support JavaScript!</noscript>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 85 - HTML
េសចក �ីបែន�ម HTML Entities
Reserved characters in HTML must be replaced with character entities. It is not possible to
use the less than (<) or greater than (>) signs in your text, because the browser will mix them with tags.
To actually display reserved characters, we must use character entities in the HTML source code.
A character entity looks like this:
- To display a less than sign we must write: < or <
- the non-breaking space we must write
Tip: The advantage of using an entity name, instead of a number, is that the name is easier to
remember. However, the disadvantage is that browsers may not support all entity names (the support
for entity numbers is very good).
HTML Useful Character Entities
Note: Entity names are case sensitive!
Result Description Entity Name Entity Number
non-breaking space   < less than < <
> greater than > >
& ampersand & &
¢ cent ¢ ¢
£ pound £ £
¥ yen ¥ ¥
€ euro € €
§ section § § © copyright © ©
® registered trademark ® ®
™ trademark ™ ™ Symbols
Character Entity Number Entity Name Description   non-breaking space ¡ ¡ ¡ inverted exclamation mark
¢ ¢ ¢ cent £ £ £ pound ¤ ¤ ¤ currency
¥ ¥ ¥ yen ¦ ¦ ¦ broken vertical bar § § § section
&entity_name;
OR
&#entity_number;
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 86 - HTML
¨ ¨ ¨ spacing diaeresis © © © copyright ª ª ª feminine ordinal indicator « « « angle quotation mark (left) ¬ ¬ ¬ negation ­ ­ soft hyphen ® ® ® registered trademark ¯ ¯ ¯ spacing macron ° ° ° degree
± ± ± plus-or-minus ² ² ² superscript 2 ³ ³ ³ superscript 3 ´ ´ ´ spacing acute
µ µ µ micro ¶ ¶ ¶ paragraph · · · middle dot
¸ ¸ ¸ spacing cedilla ¹ ¹ ¹ superscript 1 º º º masculine ordinal indicator
» » » angle quotation mark (right) ¼ ¼ ¼ fraction 1/4 ½ ½ ½ fraction 1/2 ¾ ¾ ¾ fraction 3/4 ¿ ¿ ¿ inverted question mark × × × multiplication ÷ ÷ ÷ division
Characters
Character Entity Number Entity Name Description À À À capital a, grave accent Á Á Á capital a, acute accent    capital a, circumflex accent à à à capital a, tilde Ä Ä Ä capital a, umlaut mark Å Å Å capital a, ring Æ Æ Æ capital ae Ç Ç Ç capital c, cedilla
È È È capital e, grave accent É É É capital e, acute accent Ê Ê Ê capital e, circumflex accent
Ë Ë Ë capital e, umlaut mark Ì Ì Ì capital i, grave accent Í Í Í capital i, acute accent
Î Î Î capital i, circumflex accent Ï Ï Ï capital i, umlaut mark Ð Ð Ð capital eth, Icelandic Ñ Ñ Ñ capital n, tilde
Ò Ò Ò capital o, grave accent Ó Ó Ó capital o, acute accent
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 87 - HTML
Ô Ô Ô capital o, circumflex accent Õ Õ Õ capital o, tilde Ö Ö Ö capital o, umlaut mark Ø Ø Ø capital o, slash Ù Ù Ù capital u, grave accent Ú Ú Ú capital u, acute accent Û Û Û capital u, circumflex accent Ü Ü Ü capital u, umlaut mark Ý Ý Ý capital y, acute accent
Þ Þ Þ capital THORN, Icelandic ß ß ß small sharp s, German à à à small a, grave accent á á á small a, acute accent
â â â small a, circumflex accent ã ã ã small a, tilde ä ä ä small a, umlaut mark
å å å small a, ring æ æ æ small ae ç ç ç small c, cedilla
è è è small e, grave accent é é é small e, acute accent ê ê ê small e, circumflex accent ë ë ë small e, umlaut mark ì ì ì small i, grave accent í í í small i, acute accent î î î small i, circumflex accent ï ï ï small i, umlaut mark ð ð ð small eth, Icelandic ñ ñ ñ small n, tilde ò ò ò small o, grave accent ó ó ó small o, acute accent ô ô ô small o, circumflex accent õ õ õ small o, tilde
ö ö ö small o, umlaut mark ø ø ø small o, slash ù ù ù small u, grave accent
ú ú ú small u, acute accent û û û small u, circumflex accent ü ü ü small u, umlaut mark
ý ý ý small y, acute accent þ þ þ small thorn, Icelandic ÿ ÿ ÿ small y, umlaut mark
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 88 - HTML
1. CSS Overview
Cascading Style Sheets were created to provide a powerful, yet flexible means for formatting
HTML content. Style sheets allow authors to specify layout and design elements, such as fonts, colors,
and text indentation. Style sheets give you precise control over how elements appear on a Web page.
What’s even better is that you can create a single style sheet for an entire Web site to ensure that the
layout and display of your content is consistent from page to page. And for the last bit of icing on the
cake, Web style sheets are easy to build and even easier to integrate into your Web pages.
Generally, style sheets give you more flexibility than markup ever will, and the HTML element
collection won’t grow to include more display-oriented tags. When you want tight control over the
display of your Web pages, style sheets are the way to go.
2. CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The selector is normally the HTML element you want to style. Each declaration consists of a
property and a value. The property is the style attribute you want to change. Each property has a value.
3. CSS Comments
Comments are used to explain your code, and may help you when you edit the source code at a
later date. Comments are ignored by browsers.
A CSS comment begins with "/*", and ends with "*/", like this:
/*This is a comment*/ p { text-align:center; /*This is another comment*/ color:black; font-family:arial; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 89 - HTML
4. CSS Id and Class
In addition to setting a style for a HTML element, CSS allows you to specify your own
selectors called "id" and "class".
4.1 The id Selector
The id selector is used to specify a style for a single, unique element. The id selector uses the id
attribute of the HTML element, and is defined with a "#". The style rule below will be applied to the
element with id="test":
NOTE: Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.
4.2 The class Selector
The class selector is used to specify a style for a group of elements. Unlike the id selector, the
class selector is most often used on several elements. This allows you to set a particular style for any
HTML elements with the same class. The class selector uses the HTML class attribute, and is defined
with a "."
In the example below, all HTML elements with class="center" will be center-aligned:
5. Applying CSS to an HTML document
There are three ways you can apply CSS to an HTML document. These methods are all
outlined below. We recommend that you focus on the third method i.e. external.
5.1 Method 1: In-line (the attribute style)
One way to apply CSS to HTML is by using the HTML attribute style. Building on the above
example with the red background color, it can be applied like this:
#test { text-align:justify; color:black; }
.center {text-align:center;}
<html>
<head>
<title>Example</title>
</head>
<body style="background-color: #FF0000;">
<p>This is a red page</p>
</body>
</html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 90 - HTML
5.2 Method 2: Internal (the tag style)
Another way is to include the CSS codes using the HTML tag <style>.
5.3 Method 3: External (link to a style sheet)
The recommended method is to link to a so-called external style sheet. Throughout this tutorial
we will use this method in all our examples. An external style sheet is simply a text file with the
extension .css. Like any other file, you can place the style sheet on your web server or hard disk. For
example, let's say that your style sheet is named style.css and is located in a folder named style. The
situation can be illustrated like this:
The trick is to create a link from the HTML document (default.htm) to the style sheet
(style.css). Such link can be created with one line of HTML code:
<link rel="stylesheet" type="text/css" href="style/style.css" />
Notice how the path to our style sheet is indicated using the attribute href. The line of code
must be inserted in the header section of the HTML code i.e. between the <head> and </head> tags.
Like this:
<html>
<head>
<title>Example</title>
<style type="text/css">
body {background-color: #FF0000;}
</style>
</head>
<body>
<p>This is a red page</p>
</body>
</html>
<html>
<head>
<title>My document</title>
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body> …………………………..
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 91 - HTML
This link tells the browser that it should use the layout from the CSS file when displaying the
HTML file. The really smart thing is that several HTML documents can be linked to the same style
sheet. In other words, one CSS file can be used to control the layout of many HTML documents.
6. CSS Background
CSS background properties are used to define the background effects of an element.
CSS properties used for background effects:
background-color
background-image
background-repeat
background-attachment
background-position
6.1 Background Color
The background-color property specifies the background color of an element.The background
color of a page is defined in the body selector:
The background color can be specified by:
name - a color name, like "red"
RGB - an RGB value, like "rgb(255,0,0)"
Hex - a hex value, like "#ff0000"
6.2 Background Image
The background-image property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element. The background image for a page can
be set like this:
6.3 Repeat background image [background-repeat]
In the example above, did you notice that by default the image was repeated both
horizontally and vertically to cover the entire screen? The property background-repeat controls this
behaviour. The table below outlines the four different values for background-repeat.
body {background-color:#b0c4de;} h1 {background-color:#6495ed;} p {background-color:#e0ffff;} div {background-color:#b0c4de;}
body {background-image:url('mypic.gif');}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 92 - HTML
Value Description
background-repeat: repeat-x The image is repeated horizontally
background-repeat: repeat-y The image is repeated vertically
background-repeat: repeat The image is repeated both horizontally and vertically
background-repeat: no-repeat The image is not repeated
For example, to avoid repetition of a background image the code should look like this:
6.4 Lock background image [background-attachment]
The property background-attachment specifies whether a background picture is fixed or
scrolls along with the containing element. A fixed background image will not move with the text when
a reader is scrolling the page, whereas an unlocked background image will scroll along with the text of
the web page. The table below outlines the two different values for background-attachment.
Value Description
Background-attachment: scroll The image scrolls with the page - unlocked
Background-attachment: fixed The image is locked
6.5 Place background image [background-position]
By default, a background image will be positioned in the top left corner of the screen. The
property background-position allows you to change this default and position the background image
anywhere you like on the screen. There are numerous ways to set the values of background-position.
However, all of them are formatted as a set of coordinates. For example, the value '100px 200px'
positions the background image 100px from the left side and 200px from the top of the browser
window. The coordinates can be indicated as percentages of the browser window, fixed units (pixels,
centimetres, etc.) or you can use the words top, bottom, center, left and right. The model below
illustrates the system:
body {
background-color: #FFCC66;
background-image: url("butterfly.gif");
background-repeat: no-repeat;
}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 93 - HTML
The table below gives some examples.
Value Description
background-position: 2cm 2cm The image is positioned 2 cm from the left and 2 cm down the
page
background-position: 50% 25% The image is centrally positioned and one fourth down the page
background-position: top right The image is positioned in the top-right corner of the page
6.6 Background - Shorthand property
As you can see from the examples above, there are many properties to consider when
dealing with backgrounds. To shorten the code, it is also possible to specify all the properties in one
single property. This is called a shorthand property. The shorthand property for background is simply
"background":
When using the shorthand property the order of the property values are:
background-color
background-image
background-repeat
background-attachment
background-position
body {background:#ffffff url('img_tree.png') no-repeat right top;}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 94 - HTML
7. CSS Font
We will also look at how to work around the issue that specific fonts chosen for a website
can only be seen if the font is installed on the PC used to access the website. The following CSS
properties will be described:
font-family
font-style
font-variant
font-weight
font-size
font
7.1 Font family [font-family]
The property font-family is used to set a prioritized list of fonts to be used to display a given
element or web page. If the first font on the list is not installed on the computer used to access the site,
the next font on the list will be tried until a suitable font is found.
There are two types of names used to categorize fonts: family-names and generic families. The
two terms are explained below.
Family-name
Examples of a family-name (often known as "font") can e.g. be "Arial", "Times New Roman"
or "Tahoma".
Generic family
Generic families can best be described as groups of family-names with uniformed appearances.
The difference can also be illustrated like this:
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 95 - HTML
When you list fonts for your web site, you naturally start with the most preferred font followed
by some alternative fonts. It is recommended to complete the list with a generic font family. That way
at least the page will be shown using a font of the same family if none of the specified fonts are
available.
7.2 Font style [font-style]
The property font-style defines the chosen font either in normal, italic or oblique. In the
example below, all headlines marked with <h2> will be shown in italics.
7.3 Font variant [font-variant]
The property font-variant is used to choose between normal or small-caps variants of a font. A
small-caps font is a font that uses smaller sized capitalized letters (upper case) instead of lower case
letters. Confused? Take a look at these examples:
If font-variant is set to small-caps and no small-caps font is available the browser will most
likely show the text in uppercase instead.
7.4 Font weight [font-weight]
The property font-weight describes how bold or "heavy" a font should be presented. A font can
either be normal or bold. Some browsers even support the use of numbers between 100-900 (in
hundreds) to describe the weight of a font.
7.5 Font size [font-size]
The size of a font is set by the property font-size. There are many different units (e.g. pixels
and percentages) to choose from to describe font sizes. In this tutorial we will focus on the most
common and appropriate units. Examples include:
h1 {font-family: arial, verdana, sans-serif;}
h2 {font-family: "Times New Roman", serif; font-style: italic;}
h1 {font-variant: small-caps;}
h2 {font-variant: normal;}
p {font-family: arial, verdana, sans-serif;}
td {font-family: arial, verdana, sans-serif; font-weight: bold;}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 96 - HTML
There is one key difference between the four units above. The units 'px' and 'pt' make the font
size absolute, while '%' and 'em' allow the user to adjust the font size as he/she see fit. Many users are
disabled, elderly or simply suffer from poor vision or a monitor of bad quality. To make your website
accessible for everybody, you should use adjustable units such as '%' or 'em'.
Below you can see an illustration of how to adjust the text size in Mozilla Firefox and Internet
Explorer. Try it yourself - neat feature, don't you think?
7.6 Compiling [font]
Using the font short hand property it is possible to cover all the different font properties in one
single property. For example, imagine these four lines of code used to describe font-properties for <p>:
Using the short hand property, the code can be simplified:
h2 {font-size: 12pt;}
h3 {font-size: 120%;}
p {font-size: 1em;}
p {
font-style: italic;
font-weight: bold;
font-size: 30px;
font-family: arial, sans-serif;
}
p { font: italic bold 30px arial, sans-serif; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 97 - HTML
The order of values for font is:
font-style | font-variant | font-weight | font-size | font-family
8. CSS Text
Formatting and adding style to text is a key issue for any web designer. In this lesson you
will be introduced to the amazing opportunities CSS gives you to add layout to text. The following
properties will be described:
text-indent
text-align
text-decoration
letter-spacing
text-transform
8.1 Text indention [text-indent]
The property text-indent allows you to add an elegant touch to text paragraphs by applying an
indent to the first line of the paragraph. In the example below a 30px is applied to all text paragraphs
marked with <p>:
8.2 Text alignment [text-align]
The CSS property text-align corresponds to the attribute align used in old versions of HTML.
Text can either be aligned to the left, to the right or centred. In addition to this, the value justify will
stretch each line so that both the right and left margins are straight. You know this layout from for
example newspapers and magazines.
In the example below the text in table headings <th> is aligned to the right while the table data
<td> are center. In addition, normal text paragraphs are justified:
p { text-indent: 30px; }
th {
text-align: right;
}
td {
text-align: center;
}
p {
text-align: justify;
}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 98 - HTML
8.3 Text decoration [text-decoration]
The property text-decoration makes it is possible to add different "decorations" or "effects" to
text. For example, you can underline the text, have a line through or above the text, etc. In the
following example, <h1> are underlined headlines, <h2> are headlines with a line above the text and
<h3> are headlines with a line though the text.
8.4 Letter space [letter-spacing]
The spacing between text characters can be specified using the property letter-spacing. The
value of the property is simply the desired width. For example, if you want a spacing of 3px between
the letters in a text paragraph <p> and 6px between letters in headlines <h1> the code below could be
used.
8.5 Text transformation [text-transform]
The text-transform property controls the capitalization of a text. You can choose to capitalize,
use uppercase or lowercase regardless of how the original text is looks in the HTML code. An
example could be the word "headline" which can be presented to the user as "HEADLINE" or
"Headline". There are four possible values for text-transform:
As an example, we will use a list of names. The names are all marked with <li> (list-item).
Let's say that we want names to be capitalized and headlines to be presented in uppercase
letters.Try to take a look at the HTML code for this example and you will see that the text actually is in
lowercase.
h1 { text-decoration: underline; }
h2 { text-decoration: overline; }
h3 { text-decoration: line-through; }
h1 { letter-spacing: 6px; }
p { letter-spacing: 3px; }
capitalize
Capitalizes the first letter of each word. For example: "the sun" will be "The Sun".
uppercase
Converts all letters to uppercase. For example: " the sun " will be "THE SUN".
lowercase
Converts all letters to lowercase. For example: "JOHN DOE" will be "john doe".
none
No transformations - the text is presented as it appears in the HTML code.
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 99 - HTML
9. CSS Links
You can apply what you already learned in the previous lessons to links (i.e. change colors,
fonts, underline, etc). The new thing is that CSS allows you to define these properties differently
depending on whether the link is unvisited, visited, active, or whether the cursor is on the link. This
makes it possible to add fancy and useful effects to your website. To control these effects you use so-
called pseudo-classes.
What is a pseudo-class?
A pseudo-class allows you to take into account different conditions or events when defining a
property for an HTML tag. Let's look at an example. As you know, links are specified in HTML with
<a> tags. We can therefore use a as a selector in CSS:
A link can have different states. For example, it can be visited or not visited. You can use
pseudo-classes to assign different styles to visited and unvisited links.
Use a:link and a:visited for unvisited and visited links respectively. Links that are active have
the pseudo-class a:active and a:hover is when the cursor is on the link.We will now go through each of
the four pseudo-classes with examples and further explanation.
Pseudo-class: link
The pseudo-class :link is used for links leading to pages that the user has not visited. In the
code example below, unvisited links will be light blue.
h1 { text-transform: uppercase; }
li { text-transform: capitalize; }
a { color: blue; }
a:link { color: blue; }
a:visited { color: red; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 100 - HTML
Pseudo-class: visited
The pseudo-class :visited is used for links leading to pages that the user has visited. For
example, the code below would make all visited links dark purple:
Pseudo-class: active
The pseudo-class :active is used for links that are active. This example gives active links a
yellow background color:
Pseudo-class: hover
The pseudo-class :hover is used when the mouse pointer hovers over a link. This can be used to
create interesting effects. For example, if we want our links to be orange and be italicized when the
cursor is pointed at them, our CSS should look like this:
10. CSS Lists
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
In HTML, there are two types of lists:
unordered lists - the list items are marked with bullets
ordered lists - the list items are marked with numbers or letters
With CSS, lists can be styled further, and images can be used as the list item marker. The type
of list item marker is specified with the list-style-type property:
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;}
a:link { color: #6699CC; }
a:visited { color: #660099; }
a:active { background-color: #FFFF00; }
a:hover { color: orange; font-style: italic; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 101 - HTML
An Image as The List Item Marker
To specify an image as the list item marker, use the list-style-image property
The example above does not display equally in all browsers. IE and Opera will display the
image-marker a little bit higher than Firefox, Chrome, and Safari. If you want the image-marker to be
placed equally in all browsers, a crossbrowser solution is explained below.
Crossbrowser Solution
The following example displays the image-marker equally in all browsers:
List - Shorthand property
It is also possible to specify all the list properties in one, single property. This is called a
shorthand property. The shorthand property used for lists, is the list-style property:
When using the shorthand property, the order of the values are:
list-style-type
list-style-position (for a description, see the CSS properties table below)
list-style-image
11. CSS Box Model
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
ul { list-style-type: none; padding: 0px; margin: 0px; } li { background-image: url(sqpurple.gif); background-repeat: no-repeat; background-position: 0px 5px; padding-left: 14px; }
ul
{
list-style-image: url('sqpurple.gif');
}
ul
{
list-style: square url("sqpurple.gif");
}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 102 - HTML
us to place a border around elements and space elements in relation to other elements. The image
below illustrates the box model:
Explanation of the different parts:
Margin - Clears an area around the border. The margin does not have a background color,
and it is completely transparent
Border - A border that lies around the padding and content. The border is affected by the
background color 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
In order to set the width and height of an element correctly in all browsers, you need to know
how the box model works.
12. CSS Border
Borders can be used for many things, for example as a decorative element or to underline a
separation of two things. CSS gives you endless options when using borders in your pages.
border-width
border-color
border-style
border
12.1 The width of borders [border-width]
The width of borders is defined by the property border-width, which can obtain the values thin,
medium, and thick, or a numeric value, indicated in pixels. The figure below illustrates the system:
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 103 - HTML
12.2 The color of borders [border-color]
The property border-color defines which color the border has. The values are the normal color-
values for example "#123456", "rgb(123,123,123)" or "yellow" .
12.3 Types of borders [border-style]
There are different types of borders to choose from. Below are shown 8 different types of
borders as Internet Explorer 5.5 interprets them. All examples are shown with the color "gold" and the
thickness "thick" but can naturally be shown in other colors and thicknesses. The values none or
hidden can be used if you do not want any border.
Border - Individual sides
In CSS it is possible to specify different borders for different sides:
p { border-top-style:dotted; border-right-style:solid; border-bottom-style:dotted; border-left-style:solid; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 104 - HTML
Border - Shorthand property
The shorthand property for the border properties is "border":
When using the border property, the order of the values are:
border-width
border-style
border-color
It does not matter if one of the values above are missing (although, border-style is required), as
long as the rest are in the specified order.
13. Height and width
Up until now, we have not cared much about the dimensions of the elements we have worked
with. In this lesson, we will take a look at how you easily can define the height and width of an
element.
width
height
13.1 Setting the width [width]
With the width-property, you can define a certain width of an element. The simple example
below provides us with a box wherein text can be typed:
13.2 Setting the height [height]
In the example above notice how the height of the box is set by the content of the box. You can
affect the height of an element with the property height. As an example let us try to make the box in
the example 500px high:
border:5px solid red;
div.box {
width: 200px;
border: 1px solid black;
background: orange;
}
div.box {
height: 500px;
width: 200px;
border: 1px solid black;
background: orange;
}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 105 - HTML
14. CSS Margin
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.
Margin - Individual sides
In CSS, it is possible to specify different margins for different sides:
The margin property can have from one to four values.
margin:25px 50px 75px 100px;
o top margin is 25px
o right margin is 50px
o bottom margin is 75px
o left margin is 100px
margin:25px 50px 75px;
o top margin is 25px
o right and left margins are 50px
o bottom margin is 75px
margin:25px 50px;
o top and bottom margins are 25px
o right and left margins are 50px
margin:25px;
o all four margins are 25px
15. CSS Padding
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. Padding - Individual sides
padding-top:25px; padding-bottom:25px; padding-right:50px; padding-left:50px;
margin-top:10px;
margin-top:100px; margin-bottom:100px; margin-right:50px; margin-left:50px;
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 106 - HTML
Padding - Shorthand property
To shorten the code, it is possible to specify all the padding properties in one property. This is
called a shorthand property. The shorthand property for all the padding properties is "padding":
The padding property can have from one to four values.
padding:25px 50px 75px 100px;
o top padding is 25px
o right padding is 50px
o bottom padding is 75px
o left padding is 100px
padding:25px 50px 75px;
o top padding is 25px
o right and left paddings are 50px
o bottom padding is 75px
padding:25px 50px;
o top and bottom paddings are 25px
o right and left paddings are 50px
padding:25px;
o all four paddings are 25px
16. CSS Positioning
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:
16.1 Static Positioning
HTML elements are positioned static by default. A static positioned element is always positioned
according to the normal flow of the page. Static positioned elements are not affected by the top,
bottom, left, and right properties.
16.2 Fixed Positioning
An element with fixed position is positioned relative to the browser window. It will not move even if
the window is scrolled:
padding:25px 50px;
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 107 - HTML
16.3 Relative Positioning
A relative positioned element is positioned relative to its normal position
The content of a relatively positioned elements can be moved and overlap other elements, but
the reserved space for the element is still preserved in the normal flow. Relatively positioned element
are often used as container blocks for absolutely positioned elements.
16.4 Absolute Positioning
An absolute position element is positioned relative to the first parent element that has a position
other than static. If no such element is found, the containing block is <html>:
Absolutely positioned elements are removed from the normal flow. The document and other
elements behave like the absolutely positioned element does not exist. Absolutely positioned elements
can overlap other elements.
17. Layer on layer with z-index
we will learn how to let different elements become layers. In short, this means the order of
which the elements overlap one another. For that purpose, you can assign each element a number (z-
index). The system is that an element with a higher number overlaps an element with a lower number.
p.fixed { position:fixed; top:50px; right:15px; }
h2.left { position:relative; left:-20px; } h2.pos_right { position:relative; left:20px; }
h2 { position:absolute; left:100px; top:150px; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 108 - HTML
Let us say we are playing poker and have a royal flush. Our hand can be presented in a way where
each card has got a z-index:
In this case, the numbers follow on another (1-3) but the same result can be obtained by using 3
different numbers. The important thing is the chronological sequence of the numbers (the order).
The code in the card example could look like this:
18. CSS Float
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. How
Elements Float Elements are floated horizontally, this means that an element can only be floated left or
right, not up or down. A floated element will move as far to the left or right as it can. Usually this
means all the way to the left or right of the containing element. The elements after the floating element
will flow around it. The elements before the floating element will not be affected. If an image is
floated to the right, a following text flows around it, to the left:
#div1 {
position: absolute;
left: 100px;
top: 100px;
z-index: 1; }
#div2 {
position: absolute;
left: 115px;
top: 115px;
z-index: 2; }
#div3 {
position: absolute;
left: 130px;
top: 130px;
z-index: 3; }
z-index: 1
z-index: 2
z-index: 3
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 109 - HTML
Floating Elements Next to Each Other. If you place several floating elements after each other,
they will float next to each other if there is room.
Here we have made an image gallery using the float property:
Turning off Float - Using Clear
Elements after the floating element will flow around it. To avoid this, use the clear property.
The clear property specifies which sides of an element other floating elements are not allowed. Add a
text line into the image gallery, using the clear property:
19. CSS Image Opacity / Transparency
Creating transparent images with CSS is easy.
Note: This is not yet a CSS standard. However, it works in all modern browsers, and is a part
of the W3C CSS 3 recommendation.
.thumbnail { float:left; width:110px; height:90px; margin:5px; }
img { float:right; }
.cleartext
{
clear:both;
}
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 110 - HTML
Firefox uses the property opacity:x for transparency, while IE uses filter:alpha(opacity=x).
Tip: The CSS3 syntax for transparency is opacity:x.
In Firefox (opacity:x) x can be a value from 0.0 - 1.0. A lower value makes the element more
transparent. In IE (filter:alpha(opacity=x)) x can be a value from 0 - 100. A lower value makes the
element more transparent.
20. CSS Media Types
Media Types allow you to specify how documents will be presented in different media. The
document can be displayed differently on the screen, on the paper, with an aural browser, etc.
Some CSS properties are only designed for a certain media. For example the "voice-family"
property is designed for aural user agents. Some other properties can be used for different media types.
For example, the "font-size" property can be used for both screen and print media, but perhaps with
different values. A document usually needs a larger font-size on a screen than on paper, and sans-serif
fonts are easier to read on the screen, while serif fonts are easier to read on paper.
The @media Rule
The @media rule allows different style rules for different media in the same style sheet. The
style in the example below tells the browser to display a 14 pixels Verdana font on the screen. But if
the page is printed, it will be in a 10 pixels Times font. Notice that the font-weight is set to bold, both
on screen and on paper:
<img src="klematis.jpg" width="150" height="113" alt="klematis"
style="opacity:0.4;filter:alpha(opacity=40)" />
<html> <head> <style> @media screen { p.test {font-family:verdana,sans-serif;font-size:14px;} } @media print { p.test {font-family:times,serif;font-size:10px;} } @media screen,print { p.test {font-weight:bold;} } </style> </head> <body> .... </body> </html>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 111 - HTML
Web-standards and validation
W3C is the World Wide Web Consortium, which is an independent organization that manages
code standards on the web (e.g. HTML, CSS, XML and others). Microsoft, The Mozilla Foundation
and many others are a part of W3C and agree upon the future developments of the standards. If you
have been working just a bit with web design, you probably know that there can be a big differences in
how a webpage is presented across different browsers. It can be very frustrating and time-consuming
to create a webpage which can be viewed in Mozilla, Internet Explorer, Opera and all the rest of the
existing browsers. The idea of having standards is to agree upon a common denominator on how to use
web technologies. This means that by observing the standards, a webdeveloper has a certainty that
what he or she does will work in a more appropriate manner across different platforms. We therefore
recommend that you back up the work carried out by the W3C and validate your CSS in order
to observe the standard.
The validator can also be found at this link: http://jigsaw.w3.org/css-validator/
CSS Sample
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 112 - HTML
HTML File(index.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div class="sitelogo"> <h1>Logo</h1> </div> <div class="bannertop"> <h1>Banner Top Advertising</h1> </div> </div> <div id="menu"> <ul> <li><a href="#home">Home</a></li> <li id="sample_attach_menu_parent" class="sample_attach"><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> </ul> </div> <div id="search"> Search </div> <div id="breadcrumb"> site map </div> <div id="ads_top"> Advertising Company </div> <div id="googleadstop"> Google Adsense </div> <div id="content"> <div id="left"> <ul> <li><a href="#home">Home</a></li> <li><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> </ul> <div class="leftads"> <h2>Advertising</h2> </div> </div>
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 113 - HTML
CSS File(style.css)
<div id="center"> <div class="centerads"> Advertising Center </div> Content... </div> <div id="right"> <div class="login"> <h2>LogIn</h2> </div> <div class="rightads"> <h2>Our Sponser</h2> <img src="chinglong.gif" /> </div> </div> </div> <div id="facebook">Facebook Comment</div> <div id="footer">Footer</div> </div> </body> </html>
*{ margin:0; padding:0;} body { font-family:Verdana, Geneva, sans-serif; font-size:100%; background-color:#FFF; line-height:24px; word-spacing:1px; color:black; } h1{ font-size:2.5em; } h2{ font-size:1.875em; } p{ font-size:0.875em; } #wrapper{ width:990px; height:auto; background-color:#9CF; margin:0 auto; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 114 - HTML
#header{ width:990px; height:120px; background-color:#36F; color:yellow; } #header .sitelogo{ float:left; width:300px; height:90px; padding-top:30px; text-align:center; } #header .bannertop{ float:left; width:690px; height:90px; padding-top:30px; background-color:#C93; text-align:center; } #menu{ clear:left; width:990px; height:40px; background-color:#98bf21; color:red; } #menu ul{ list-style-type:none; margin:0; padding:0; } #menu ul li{ display:inline; } #menu a:link,#menu a:visited{ float:left; line-height:40px; /*width:150px;*/ padding:0 25px; border-right:1px inset #39C; font-weight:bold; color:#FFFFFF; background-color:#98bf21; text-align:center; text-decoration:none; text-transform:uppercase; -moz-border-radius:15px 15px 0 0px; border-radius:15px 15px 0 0px; }
#menu a:hover,#menu a:active{ background-color:#7A991A;} #search{ width:990px; height:60px; background-color:#FC9;} #breadcrumb{ width:980px; height:auto; margin:5px 0px; padding:0px 5px; text-align:left; font-size:14px; background-color:#CCC;} #ads_top{ width:980px; height:auto; text-align:center; border:0px; outline:none; margin:5px; background-color:#fff;} #googleadstop{ width:980px; height:80px; text-align:center; border:0px; outline:none; margin:5px; background-color:#fff;} #content{ width:990px; height:auto; background-color:#CCC; color:#00F; overflow:auto; margin-bottom:10px;} #content #left{ float:left; width:200px; height:auto; background-color:#066; color:#00F;} #content #left ul{ list-style-type:none; margin:0; padding:0; }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 115 - HTML
#content #left a:link,#content #left a:visited{ display:block; font-weight:bold; color:#FFFFFF; background-color:#06F; width:192px; text-align:center; padding:4px; line-height:30px; text-decoration:none; text-transform:uppercase; border-bottom:1px inset yellow; } #content #left a:hover,#content #left a:active{ background-color:#C96; } #content #left .leftads{ width:190px; height:200px; border:1px solid blue; margin:4px; text-align:center; background-color:#FCF; margin-top:5px; } #content #left .leftads h2{ background-color:#66C; font-size:20px; height:35px; padding-top:5px; } #content #left .leftads h2:hover{ background-color:#993; } #content #center{ float:left; width:580px; height:auto; color:#00F; margin-left:5px; margin-right:5px; } #content #center .centerads{ width:580px; height:200px; background-color:white; }
#content #right{ float:left; width:200px; height:auto; background-color:#9F3; color:#00F; } #content #right .login{ width:190px; height:200px; border:1px solid blue; margin:4px; text-align:center; background-color:#FCF; margin-top:5px; } #content #right .login h2{ background-color:#66C; font-size:20px; height:35px; padding-top:5px; } #content #right .login h2:hover{ background-color:#993; } #content #right .rightads{ width:190px; height:auto; border:1px solid blue; margin:4px; text-align:center; background-color:#FCF; margin-top:5px; } #content #right .rightads h2{ background-color:#66C; font-size:20px; height:35px; padding-top:5px; } #content #right .rightads h2:hover{ background-color:#993; } #content #right .rightads img{ width:184px; padding:3px; } #content #right .rightads img:hover{ opacity:0.4; filter:alpha(opacity=40); }
University of South-East Asia Hyper Text Markup Language
Prepared by Mr. Chan Seriya - 116 - HTML
#facebook{ clear:left; width:990px; height:100px; background-color:#FC9; color:#000; text-align:center; margin-top:10px; } #footer{ margin-top:10px; width:990px; height:70px; background-color:#CF6; color:#000; }