CSS Syntax



Syntax

The CSS syntax is made up of three parts: a selector, a property and a value:

selector {property:value}


The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon, and surrounded by curly braces:

body {color:black}


Note: If the value is multiple words, put quotes around the value:

p {font-family:"sans serif"}


Note: If you want to specify more than one property, you must separate each property with a semicolon. The example below shows how to define a center aligned paragraph, with a red text color:
p {text-align:center;color:red}


To make the style definitions more readable, you can describe one property on each line, like this:

p
{
text-align:center;
color:black;
font-family:arial
}

Grouping

You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. All header elements will be displayed in green text color:


h1,h2,h3,h4,h5,h6
{
color:green
}


The class Selector

With the class selector you can define different styles for the same type of HTML element.

Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph. Here is how you can do it with styles:


p.right {text-align:right}
p.center {text-align:center}


You have to use the class attribute in your HTML document:

This paragraph will be right-aligned.


This paragraph will be center-aligned.



Note: To apply more than one class per given element, the syntax is:

This is a paragraph.



The paragraph above will be styled by the class "center" AND the class "bold".

You can also omit the tag name in the selector to define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class="center" will be center-aligned:
.center {text-align:center}

In the code below both the h1 element and the p element have class="center". This means that both elements will follow the rules in the ".center" selector:

This heading will be center-aligned


This paragraph will also be center-aligned.



Remark Do NOT start a class name with a number! It will not work in Mozilla/Firefox.
Add Styles to Elements with Particular Attributes

You can also apply styles to HTML elements with particular attributes.

The style rule below will match all input elements that have a type attribute with a value of "text":
input[type="text"] {background-color:blue}

The id Selector

You can also define styles for HTML elements with the id selector. The id selector is defined as a #.

The style rule below will match the element that has an id attribute with a value of "green":
#green {color:green}

The style rule below will match the p element that has an id with a value of "para1":
p#para1
{
text-align:center;
color:red
}

Remark Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.
CSS Comments

Comments are used to explain your code, and may help you when you edit the source code at a later date. A comment will be 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
}

1 comments:

Unknown said...

đồng tâm
game mu
cho thuê nhà trọ
cho thuê phòng trọ
nhac san cuc manh
số điện thoại tư vấn pháp luật miễn phí
văn phòng luật
tổng đài tư vấn pháp luật
dịch vụ thành lập công ty trọn gói
lý thuyết trò chơi trong kinh tế học
đức phật và nàng audio
hồ sơ mật dinh độc lập audio
đừng hoang tưởng về biển lớn ebook
chiến thắng trò chơi cuộc sống ebook
bước nhảy lượng tử
ngồi khóc trên cây audio
truy tìm ký ức audio
mặt dày tâm đen audio
thế giới như tôi thấy ebook

- Xuân Hạnh cô nương cũng là lần đầu tiên hay sao?

Xuân Hạnh nghe vậy, sắc mặt hiện lên vẻ xấu hổ, một lúc lâu sau mới thẹn thùng, khe khẽ nói:

- Thiếp …cũng là lần đầu tiên.
“Ha ha, ngươi là lần đầu tiên mà sao mông và ngực tựa như không còn chút đàn hồi nào nữa, cứ như cao su xài lâu mất hết tính đàn hồi vậy. Ta là thiếu niên mới lớn nhưng cũng không phải là đầu bò. Ngươi mà còn là xử nữ thì chắc tất cả kỹ nữ trong thiên hạ cũng là xử nữ.”

Mặc dù Lưu Phong trải qua hai kiếp người vẫn còn là xử nam thế nhưng năm đó học đại học hắn cũng mấy tên bạn vô lại cũng đã từng tranh luận phán đoán xem nữ tử có còn là xử nữ hay không vô số lần, phim ảnh xxx hắn xem cũng không ít, muốn lừa hắn cũng không phải là chuyện dễ dàng.

Lưu Phong nãy giờ giả ngây giả ngô, hai tay liên tục thám hiểm thân thể Xuân Hạnh, vuốt ve bóp nhéo vài lần là đã có thể khẳng định nữ tử này nhất định không còn đồng trinh nữa.

“Mẹ nó, Phong Nguyệt lâu này nên gọi là Hắc lâu thì mới đúng, ta đã hào phóng trả cho các ngươi một phiến kim diệp tử, vậy mà các ngươi lại định lừa gạt lão tử…thật sự là các ngươi muốn gì đây?”

Lưu Phong thấy Xuân Hạnh không đề cập tới chuyện xử nữ nữa, cũng không truy hỏi, chỉ liên tục bắt nàng uống rượu, mỗi một chén rượu, hắn lại thưởng cho nàng mười lượng bạc.
Xuân Hạnh từ khi bước chân vào thanh lâu đến bây giờ cũng chưa từng gặp được ai hào phóng như hắn, không nói nhiều, mà uống liên tục.

Thời gian một nén nhang trôi qua, Xuân Hạnh cũng đã uống được khoảng 50 chén. Mặc dù tửu lượng của nàng hơn người nhưng lúc này cũng đã hơi say.

Rượu có thể làm cho bản tính nổi loạn, Xuân Hạnh vốn chẳng phải là nữ tử đàng hoàng gì, rượu vào càng chẳng cần phải ý tứ gì nữa, nhìn Lưu Phong như cây ngọc trước gió, xuân tình dâng trào, vẻ mặt lẳng lơ nói:

- Công tử, xuân tiêu rất ngắn, chúng ta lên giường an giấc sớm một chút nhé.

Lưu Phong mỉm cười:

- Thời gian vẫn còn sớm, nàng hãy cùng ta uống vài chén nữa. Như vậy đi, bây giờ nàng uống một chén, bổn công tử sẽ cho nàng một trăm lượng bạc.

Post a Comment

Advertisement

 

Copyright 2009 All Rights Reserved SITS