CSS Basics (i)
1. CSS style:
There are four ways to load CSS styles:
1), external style
2), internal style
3), inline style
4), Import style
<link href= "Layout.css" rel= "stylesheet" type= "Text/css"/>
This form is to write the CSS in a separate CSS file, and then link in the source code. The advantage is that not only this page can be called, other pages can also be called, is the most common form.
<STYLE>H2 {color: #f00;} </style>
This form is an internal style sheet, which ends with <style> and </style> and is written in the head tag of the source code. This style sheet is valid only for this page. cannot be used for other pages.
<p style= "FONT-SIZE:18PX;" > Internal Styles </p>
This is the inline style marked with style in the tag, and the inline style is only valid for the elements within the tag, because it is not separated from the content, so it is not recommended.
@import url ("/css/global.css");
A link style is an external style sheet that is linked with a @import URL tag, which is typically used inside another style sheet. If LAYOUT.CSS is the style used for the home page, then we can put the common styles needed for the whole world into a global.css file, and then link the global style in the form of @import URL ("/css/global.css") in Layout.css. This makes the code good reusability.
2, CSS Priority:
1), ID priority above class
2), the following style overrides the previous
3), specified above inheritance
4), inline style above internal or external style
Summary: the single (ID) is higher than the common (class), has the specified with the specified, without specifying the inheritance from its nearest
3, CSS box model composition:
Learning Web standards, the first thing to understand is the box model, this is the core of Div typesetting. The traditional table layout is to locate the content of the typesetting page by nesting tables and tables in different sizes, and then using CSS to format the pages by nesting the boxes and boxes of different sizes defined by CSS. The layout of the page code concise, performance and content separation, maintenance is convenient, can be compatible with more browsers, such as PDA devices can also be viewed normally.
So why is it called a box? Let's first talk about the property names we often hear in web design: content, padding (padding), Borders (border), boundaries (margin), CSS box patterns.
We can think of it as a box above the opening of the reality, and then look down from the top, the border is equivalent to the thickness of the box, the content of the box with respect to the space of the object, and fill it, the equivalent of shock and in the box filled with foam, the border is equivalent to the box around to set aside a certain amount of space Is it so easy to understand the box model.
So the width of the whole box model in the page is composed of the left border + left box + Left padding + content + right padding + right border + right boundary , while the width defined in CSS style is only the width of the content part.
Here the boundary we also call: margin, outer patch; padding is also called: Inner margin, inner patch.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Learning---CSS basics (i)