An element can have both an ID selector and a class selector, but only one ID selector, and the ID selector has a precedence greater than the class selector.
Cases:
HTML file Contents:
Contents of Test.css File:
/* An element can have both an ID selector and a class selector.
#id1 {
Background-color:silver;
font-size:40px;
Color:black;
}
After reading this, you will understand the differences between class and id selector in css styles. You can define your own selector using class and id.
The benefit of doing so is that depending on the class or id, you can behave the same HTML element differently.
In CSS
Instancea: Link {color:#FF0000;} / * non-visited links * / a:visited {color: #00FF00 Span class= "hl-reserved" >;} /* visited link */ a:hover {color: #FF00FF ;} /* mouse over link */ a:active {color: #0000FF ;} /* selected links */ Note: in CSS definitions, a:hover must be placed after A:link and a:visited to be valid.Note: in the
css| Tips
A pseudo class can be viewed as a special class selector, a special selector that can be automatically recognized by browsers that support CSS. Its greatest use is that you can define different style effects on links in different states.
1. Grammar
The syntax of a pseudo
. warning or. Notification. The great advantage of meaningful class names is that they can be reused throughout the site. For example, you can also use the. Notification class on other types of messages to apply a completely different style depending on where they are located in the document.
The name of the difference
A good name
Red
Error
Leftcolumn
[Document of the fire School of website construction] Today, a friend asked CSS questions in the group. When talking about the difference between Class and ID, I suggested Baidu. Then he checked a lot of articles, I still don't quite understand it, so I had to give it a one-by-one analysis.Class is the class for setting labels.Id is the identifier of the tag.The
"alt=" Wkiol1byc6siedymaacophzrvrc869.png "/>Four, pseudo-element selectorPseudo-element: First-letter-: First-letter selector to select the first letter of the specified selector-often used for typesetting details such as initials highlighting, sinking, etc.650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/E2/wKiom1byC32ysFjHAACGOSu3dec073.png "title=" Web.png "alt=" Wkiom1byc32ysfjhaacgosu3dec073.png "/>Pseudo-element: First-line-: First-line selector for selecting the first row o
-origin:padding-box; Border-box: Starting from the outside frame show Padding-box: Starting from the inner margin Content-box: Start */7 from the content. Background picture clipping position background-clip:content-box;8. Composite properties for background back Ground:red URL (".. /.. /img/j.png ") no-repeat 20px 20px; It combines these four properties Background-color, Background-image, Background-repeat, background-position Two, sprite Figure 1. Entry explanation
REM article title: Using the VBS class to implement CSS buttons
REM Author: Yanek
REM Contact: aspboy@263.net
Class Cssbutton
Public Name
Public BackColor
Public bordercolor
Public Font
Public FontColor
Public Width
Public Text
Public URL
Public Mouseovercolor
Public Function Generatestyletag ()
' Create ' STYLE tag
Dim Strstyle
Strstyle = """#mybutton" Name "
: Before: The function of After is to insert an inline element containing the content specified by the content property before or after the specified element contents (not the element itself), with the following basic usage:#example:before { content: "#"; color: red;}#example:after { content: "$"; color: red;}This code inserts a ' # ' before the content of the #example element, and adds a ' $ ' after the content, and the inserted inline element is the child of the #example, with the
ID and Class SelectorIf you want to set CSS styles in HTML elements, you need to set the "id" and "class" selectors in the element.
ID SelectorThe ID selector can specify a specific style for an HTML element that is labeled with a specific ID.The HTML element sets the ID selector with the id attribute, and the ID selector in the
Text text colorIf the text is a link, the text is dimmed when you move the mouse over the linked text. text-muted: Grey. Text-primary: Light Blue. Text-success: Green. Text-info: Dark blue. text-warning: Orange. Text-danger: RedText position. Text-left: Text left Justified. Text-center: Text Center alignment. text-right: Text right-alignedWrap text. text-justify: Text alignment, out of screen part text wrapping. TEXT-NOWRAP: Paragraph beyond the screen part does not wrapText case. text-lowercase
Source: http://www.css88.com/archives/744-------------------------------------------------------------------------------------------------IE6 under the link pseudo-class (: hover) CSS background image has a flashing bug, the main reason IE will once again request this picture, or that the picture is not cached.For example:CSS Code
a:hover{background:URL (imagepath)}
Common solutions:Add the f
Focus on the use of After and before:How to becomeThe above directory structure is generated by jstree, we know that there is no tag behind, how to generate it?Very simple, only CSS style can be done: tag element + pseudo-class aftera.task-pack:after{//My style name is this, you can write your own style nameContent: ' Packaged ';Display:inline-block;min-width:10px;PADDING:3PX 7px;margin-left:2px;font-size:1
css| Tutorial | style sheet
classIn order to define the Web page format more accurately, it is necessary to make the same selectors can be categorized, and can be different categories for different style design. The basic format is as follows:
Selector. Category name {property: value}
A category name can be referenced in an character of an HTML ID:
Instance:
ID
ID, which is to send an "id" to the style in HTML text, to ensure that it has
css| Skills | Web page
ID and class How to use, in the title of the use of the principles and techniques, the use of principles and techniques here is my summary of experience, not from which the book, so is not what authoritative discussion, please users in this article when you need to have assertive reading, do not be confused by my bogey.
The use principle of ID and
In CSS, the class selector is preceded by the class name with a dot number, if the multi-class is not to hit more than one point number and the. Important.urgent this form.
Class SelectorIn CSS, the
Core tips: Class can be reused and IDs can only be used once in a page. It is possible that using the same ID repeatedly in a large number of browsers will not cause problems, but it is definitely wrong to use on the standard and is likely to lead to some real-world problems with browsers.
Class can be reused and IDs can only be used once in a page. It is possible that using the same ID repeatedly in a lar
[Switch] CSS target pseudo Class E: target CSS3 target pseudo class has to talk about those things (implement tab switching with pure CSS)
Do you think target is a little familiar ?!
What I want to talk about todayNoThe HTML tag has a target attribute.
The target pseudo class
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.