ALL > Computer and Education > courses > university courses > undergraduate courses > practice for Computer English Language > > 2017-2018-1-class > 2014329620012陈日正 > >
CSS manual<en> Version 0
👤 Author: by as17744 2018-01-07 00:36:46
Like HTML, CSS is not really a programming language. It is not a markup language either — it is a style sheet language. This means that it lets you apply styles selectively to elements in HTML documents. For example, to select all the paragraph elements on an HTML page and turn the text within them red, you'd write this CSS:

p {
color: red;
}

Let's try it out: paste those three lines of CSS into a new file in your text editor, and then save the file as style.css in your styles directory.

But we still need to apply the CSS to your HTML document. Otherwise, the CSS styling won't affect how your browser displays the HTML document. (If you haven't been following on with our project, read Dealing with files and HTML basics to find out what you need to do first.)

Open your index.html file and paste the following line somewhere in the head (that is, between the and tags):



The whole structure is called a rule set (but often "rule" for short). Note also the names of the individual parts:

Selector
The HTML element name at the start of the rule set. It selects the element(s) to be styled (in this case, p elements). To style a different element, just change the selector.
Declaration
A single rule like color: red; specifying which of the element's properties you want to style.
Properties
Ways in which you can style a given HTML element. (In this case, color is a property of the

elements.) In CSS, you choose which properties you want to affect in your rule.
Property value
To the right of the property after the colon, we have the property value, which chooses one out of many possible appearances for a given property (there are many color values besides red).
Note the other important parts of the syntax:

Each rule set (apart from the selector) must be wrapped in curly braces ({}).
Within each declaration, you must use a colon (:) to separate the property from its values.
Within each rule set, you must use a semicolon (;) to separate each declaration from the next one.
So to modify multiple property values at once, you just need to write them separated by semicolons, like this:

p {
color: red;
width: 500px;
border: 1px solid black;
}

Please login to reply. Login

Reversion History

Loading...
No reversions found.