XHTML và CSS
| A Basic Page | A Basic Page with Style | CSS in Action | How CSS and HTML Work Together | Create a nav bar | Create a Table | Page with Image | | Một cơ bản Trang | Một Trang cơ bản với Style | CSS trong hành động | CSS và HTML như thế nào làm việc cùng nhau | Tạo một thanh nav | Tạo Bảng | Trang với hình ảnh |
A Basic Page Một Trang cơ bản
This code demonstrates a basic page in HTML. Mã này chứng tỏ một trang cơ bản trong HTML. Notice how the tags are ordered. Chú ý các thẻ được đặt hàng. This process is called nesting. Quá trình này được gọi là làm tổ. You must always close a tag or the page may not display properly. Bạn luôn luôn phải đóng một thẻ hoặc trang không thể hiển thị đúng. The code: Mã:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <DOCTYPE html PUBLIC "! - / / W3C / / DTD XHTML 1.0 Strict / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My World Sample</title> Thế giới của tôi <title> mẫu </ title>
</head> </ head>
<body> <body>
<p>Welcome to my world</p> <p> Chào mừng đến với thế giới của tôi </ p>
</body> </ body>
</html> </ html>
return to top trở về đầu trang
A Basic Page with Style Một Trang cơ bản với Style
When we use CSS styles in a basic page, there are three ways of accomplishing this. Khi chúng tôi sử dụng CSS trong một trang cơ bản, có ba cách để hoàn thành này. The first is an inline style which is placed in the line of code where it will affect that particular line of text. Đầu tiên là một phong cách nội tuyến được đặt trong dòng mã nơi nó sẽ ảnh hưởng tới dòng cụ thể của văn bản. the second is internal styles, which are placed in the head section (as demonstrated here in this file). thứ hai là phong cách nội bộ, được đặt ở phần đầu (như chứng minh ở đây trong tập tin này). The third is an external style sheet that is a separate file that is called into the HTML file as in some examples below. Thứ ba là một phong cách trang bên ngoài mà là một tập tin riêng biệt đó được gọi vào tệp HTML như ở một số ví dụ dưới đây. Here is the sample code: Dưới đây là đoạn code mẫu:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <DOCTYPE html PUBLIC "! - / / W3C / / DTD XHTML 1.0 Strict / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My World Sample</title> Thế giới của tôi <title> mẫu </ title>
<style type="text/css"> <style type="text/css">
<!-- <! --
body,td,th { cơ thể, td, th (
color: #CCCCCC; color: # CCCCCC;
} )
body { body (
background-color: #333333; background-color: # 333333;
} )
--> ->
</style> </ style>
</head> </ head>
<body> <body>
<div align="center">Welcome to my world <div align="center"> Chào mừng đến với thế giới của tôi
</div> </ div>
</body> </ body>
</html> </ html>
return to top trở về đầu trang
CSS in Action CSS in Action
This CSS file defines the presentation for the HTML content: CSS định nghĩa tập tin này trình bày về nội dung HTML:
p {color:red} p (color: red)
p.group {color:blue} p.group (color: blue)
p#one {color:green} p # một (color: green)
p#one {color:magenta} p # một (color: magenta)
This is the HTML code that references the CSS coded file: Đây là mã HTML mà tài liệu tham khảo CSS mã hoá tập tin:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Untitled Document</title> <title> Untitled Document </ title>
<link href="styletest.css" rel="stylesheet" type="text/css" /> <link href="styletest.css" rel="stylesheet" type="text/css" />
</head> </ head>
<body> <body>
<p>Here is a generic p element. <p> Đây là một nguyên tố p chung. It will be red.</p> Nó sẽ được màu đỏ. </ P>
<p class="group"> Here is a group class p element. <p class="group"> Đây là một lớp học nhóm p phần tử. there are two rules that apply, but since the p.group rule is more specific, this paragraph will be blue.</p> có hai quy tắc được áp dụng, nhưng kể từ khi luật p.group là cụ thể hơn, đoạn này sẽ có màu xanh lam. </ p>
<p class="group" id="one">Here is ap element with an id of one. <p class="group" id="one"> ap Đây là yếu tố với một id của một. there are four rules that could apply here. có bốn nguyên tắc có thể áp dụng ở đây. The first two are overruled by the more specific last two. Việc đầu tiên là hai overruled do cuối cụ thể hơn hai. The position breaks the tie between the last two: the one that appears later wins, and thus this paragraph will be magenta. Các vị trí phá vỡ tie giữa cuối hai: một xuất hiện sau đó thắng, và như vậy đoạn này sẽ có màu đỏ tươi.
</p> </ p>
</body> </ body>
</html> </ html>
Here is the HTML and CSS code in a zipped folder. styles.zip Đây là mã HTML và CSS trong một thư mục nén. Styles.zip
return to top trở về đầu trang
How CSS and XHTML work together Làm thế nào CSS và XHTML làm việc cùng nhau
The next two files demonstrate how CSS and XHTML work together to define the page via the <div> tag and CSS formating. Hai tập tiếp theo chứng minh làm thế nào CSS và XHTML làm việc cùng nhau để xác định các trang thông qua <div> thẻ và Formating CSS. Notice the columns that are defined. Thông báo các cột được xác định. If you download the accompanying zip file you can play with the code in the CSS file to see how this file defines the XHTML content. Nếu bạn tải về các zip đi kèm file bạn có thể chơi với mã trong file CSS để xem tập tin này xác định nội dung XHTML.
The CSS Code: Mã CSS:
/* CSS definition - below is the definition for the pix id */ / * CSS định nghĩa - dưới đây là định nghĩa cho các pix id * /
#who { # người (
float:left; float: left;
width: 200px; width: 200px;
margin-left: 20px; margin-left: 20px;
padding:15px 0; padding: 15px 0;
} )
#camp { # trại (
margin:0 auto; margin: 0 auto;
width: 200px; width: 200px;
padding:15px 0; padding: 15px 0;
} )
The HTML Code: Mã HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<link href="styles.css" rel="stylesheet" type="text/css" /> <link href="styles.css" rel="stylesheet" type="text/css" />
<title>sample div</title> <title> mẫu div </ title>
</head> </ head>
<body> <body>
<div align="center"> <div align="center">
<p>About Us</p> <p> Giới thiệu </ p>
</div> </ div>
<div id="who"> <div id="who">
<p> <p>
<h3>Who are we?</h3> <h3> Chúng tôi là ai? </ h3>
We are teachers, we are learners, and we are adventurers. Chúng tôi là giáo viên, chúng tôi là những người học, và chúng tôi là nhà thám hiểm. We want to be a part of a community of competent and caring individuals, so that is how we live. Chúng tôi muốn trở thành một phần của một cộng đồng của các cá nhân có thẩm quyền và chăm sóc, do đó là làm thế nào chúng ta sống. We are experienced at what we teach because we teach what we live. Chúng tôi có kinh nghiệm ở những gì chúng tôi giảng dạy bởi vì chúng tôi dạy những gì chúng ta đang sống. We want to create an experience that will not only help you grow as a person, as a member of a community, but also on that will stick with you forever. Chúng tôi muốn tạo ra một kinh nghiệm mà sẽ không chỉ giúp bạn phát triển như một người, như là một thành viên của cộng đồng, nhưng cũng có ngày mà sẽ dính với bạn mãi mãi. We aren't your average camp counselors; we bring our energy and our experience to you in a way that'll stick with you once you're gone. Chúng tôi không trung bình của bạn trại tư vấn viên, chúng tôi mang năng lượng của chúng tôi và kinh nghiệm của chúng tôi để bạn theo một cách mà sẽ dính với bạn một khi bạn đang đi. Come be a part of something amazing. Hãy đến được một phần của một cái gì đáng ngạc nhiên.
</p></div> </ p> </ div>
<div id="camp"> <div id="camp">
<p> <h3>What's this camp all about?</h3> <p> <h3> trại này tất cả về? </ h3 là gì>
It's about having fun, learning new things and meeting new people. It's about có vui vẻ, học hỏi những điều mới và đáp ứng những người mới. Foraging in the woods and building a community. Foraging trong rừng và xây dựng một cộng đồng. It's about growth and adventure. Đó là về tăng trưởng và phiêu lưu. Combining real life skills with imagination. Kết hợp các kỹ năng thực tế đời sống với trí tưởng tượng. We want you to learn from a master of martial arts and to storm a counselor compound all at the same camp. Chúng tôi muốn bạn học hỏi từ một bậc thầy của võ thuật và để cơn bão một hợp chất tư vấn viên ở tất cả các trại giống nhau. We want you to learn from yourself. Chúng tôi muốn bạn học hỏi từ chính mình. We teach what we know and what we live. Chúng tôi giảng dạy những gì chúng ta biết và những gì chúng ta đang sống. Summer camp will never be the same.</p></div> Trại hè sẽ không bao giờ như nhau. </ P> </ div>
</body> </ body>
</html> </ html>
Here is the HTML and CSS code in a zipped folder. two_column.zip Đây là mã HTML và CSS trong một thư mục nén. Two_column.zip
return to top trở về đầu trang
Create a Nav Bar Tạo một Bar Nav
Creating a nav bar for your site is not that difficult using HTML and CSS. Tạo một thanh nav cho trang web của bạn mà không phải là khó khăn bằng cách sử dụng HTML và CSS. The following are two files (the HTML file and the CSS file) that demonstrate a basic top nav bar. Sau đây là hai tập tin (file HTML và tập tin CSS) chứng minh rằng một thanh nav cơ bản hàng đầu. Feel free to use the code and manipulate it. Hãy sử dụng mã và thao tác nó.
The HTML file: Các tập tin HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>nav bar sample</title> <title> nav bar mẫu </ title>
<link href="index.css" rel="stylesheet" type="text/css" /> <link href="index.css" rel="stylesheet" type="text/css" />
</head> </ head>
<body> <body>
<ul id="nav"> <ul id="nav">
<li><a href="#">home</a></li> <li> <a href="#"> nhà </ a> </ li>
<li><a href="#">about</a></li> <li> <a href="#"> về </ a> </ li>
<li><a href="#">pics</a></li> <li> <a href="#"> pics </ a> </ li>
<li><a href="#">more</a></li> <li> <a href="#"> thêm </ a> </ li>
<li><a href="#">contact</a></li> <li> <a href="#"> liên hệ </ a> </ li>
</ul> </ ul>
</body> </ body>
</html> </ html>
The CSS file: File CSS:
body cơ thể
{ (
background: #666666 background: # 666666
} )
ul#nav ul # nav
{ (
margin-left: 0; margin-left: 0;
padding-left: 0; padding-left: 0;
list-style-type: none; list-style-type: none;
background: #36; background: # 36;
float: left; float: left;
width: 100%; width: 100%;
} )
ul#nav li ul # nav li
{ (
display: inline; display: inline;
} )
ul#nav a ul # nav một
{ (
display: block; display: block;
float: left; float: left;
padding:.2em 1em; padding: .2 em 1em;
text-decoration: none; text-decoration: none;
color: #fff; color: # fff;
background: #36; background: # 36;
border-right: 1px solid #fff; border-right: 1px solid # fff;
} )
ul#nav a:hover ul # nav a: hover
{ (
color: #000; color: # 000;
background: #69c; background: # 69c;
} )
return to top trở về đầu trang
Create a Table Tạo một Table
Tables used to be the default in HTML page design. Bàn được sử dụng để được mặc định trong thiết kế trang HTML. CSS has made a major impact on site design. CSS đã có những tác động lớn về thiết kế trang web. Although CSS does a better job with page layout, tables still have their uses. Mặc dù CSS làm một công việc tốt hơn với bố cục trang, bàn vẫn còn có sử dụng của họ. Common uses are tabular data such as price lists. Thường được sử dụng bảng dữ liệu như danh sách giá cả. The following code produces a table. Các mã sau tạo một bảng. I have included a row span and col span attribute in the code to demonstrate how to span columns and rows. Tôi đã có một khoảng hàng và thuộc tính span col trong các mã để chứng minh làm thế nào để cột span và các hàng. The code: Mã:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <DOCTYPE html PUBLIC "! - / / W3C / / DTD XHTML 1.0 Strict / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Basic Table</title> <title> cơ bản Table </ title>
</head> </ head>
<body> <body>
<table width="450" border="1"> <table width="450" border="1">
<caption> <caption>
My Table Bảng của tôi
</caption> </ caption>
<tr> <tr>
<td> </td> <td> </ td>
<td colspan="2">This cel is my col span</td> <td colspan="2"> cel Đây là span col của tôi </ font>
</tr> </ tr>
<tr> <tr>
<td rowspan="2"><p>This row is<br /> <td rowspan="2"> <p> Hàng này là <br />
my row span</p></td> span hàng của tôi </ p> </ td>
<td> </td> <td> </ td>
<td> </td> <td> </ td>
</tr> </ tr>
<tr> <tr>
<td> </td> <td> </ td>
<td> </td> <td> </ td>
</tr> </ tr>
<tr> <tr>
<td> </td> <td> </ td>
<td> </td> <td> </ td>
<td> </td> <td> </ td>
</tr> </ tr>
</table> </ table>
</body> </ body>
</html> </ html>
return to top trở về đầu trang
Page with Image Trang với hình ảnh
Inserting images in your site are easy once you know the code. Chèn hình ảnh vào trang web của bạn được dễ dàng một khi bạn biết mã. Here is an example using a division in order to center the iamge on the page and conform to current web standards. Dưới đây là một ví dụ bằng cách sử dụng một bộ phận ở trung tâm để đặt hàng các iamge trên trang và phù hợp với tiêu chuẩn web hiện tại. The code: Mã:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sample image on page</title> <title> mẫu hình ảnh trên trang </ title>
</head> </ head>
<body> <body>
<div align="center"><img src="webpic.jpg" /> <div align="center"> <img src="webpic.jpg" />
</div> </ div>
</body> </ body>
</html> </ html>
return to top trở về đầu trang
Copyright © 2008 Ken Desautels, MyNetFX.com Bản quyền © 2008 Ken Desautels, MyNetFX.com