CSS Class and ID selector, CSSClassID Selector

Source: Internet
Author: User

CSS Class and ID selector, CSSClassID Selector

9. CSS Class and ID Selector

The difference between id and class indicates that the same ID of a page can only be used once, but the class can be used without restriction.
Similarly, you can use a selector behind the html selector to specify special HTML elements. For example, p. jam {value} will use a section with the 'jam' class attribute.
10. I almost forgot about it. Page Layout
Clear float disply and so on. We mainly use this for websites with div + css.
Summary: The concept of css is basically the same. We must be engaged in web development. However, we cannot help but understand css and html front-end, you can check the information. So I want to make a demo to demonstrate it. I am sending this evening. I hope you can support the hacker. I am also a very old cainiao. Now I am stepping into this web. I hope you can help me a lot. Thank you ~
11. Practice html + css


Because my goal is to learn web development, this html + css does not need to be too refined. Let's take a look at it and I will be able to change it if I get an instance later, this is my purpose. I don't know what the requirements are.
Next, I will change the Baidu page. Because I am relatively lazy and the big page may not be patient, I just want to imitate Baidu, and I don't know if I can do it in the past two days.

First, we can see the layout. First, we will analyze the structure and use html to get the structure out. Then we will look at the presentation method and use css to define it.

The Code is as follows:
<Html>
<Head>
<Title> html + css baidu.com demo </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Link href = "css/css.css" rel = "stylesheet" type = "text/css"/>
<Body>
<Div id = "box">
<Div id = "login"> <a href = "#"> logon </a> </div>
<Div id = "log"> </div>
<Div id = "txt">
<Ul>
<Li> <a href = "#"> News </a> </li>
<Li> <a href = "#"> webpage </a> </li>
<Li> <a href = "#"> post </a> </li>
<Li> <a href = "#"> Yes </a> </li>
<Li> <a href = "#"> MP3 </a> </li>
<Li> <a href = "#"> image </a> </li>
<Li> <a href = "#"> video </a> </li>
</Ul>
</Div>
<Div id = "ipt"> (www.111cn.net)
<Input type = "text"/>
<Input type = "button" value = "" id = "btn"/>
</Div>
<Div id = "help">
<Ul>
<Li> <a href = "#"> help </a> </li>
<Li> <a href = "#"> Search </a> </li>
</Ul>
</Div>
<Div id = "link">
<Ul>
<Li> <a href = "#"> Enterprise Promotion </a> </li>
<Li> <a href = "#"> Search for the billboard </a> </li>
<Li> <a href = "#"> About Baidu </a> </li>
<Li> <a href = "#"> About Baidu </a> </li>
</Ul>
</Div>
<Div id = "copy" >&# 169; 2008 Baidu <a href = "#"> before using Baidu, you must read the Beijing ICP Certificate No. 030173 </a> </div>
</Div>
</Body>
</Html>

Body {
Width: 98%;
Margin: 0px auto;
}
# Login {
Float: right;
Font-size: 12px;
Padding-top: 7px;
}
# Log {
Background-image: url (../images/log.gif );
Height: 129px;
Padding: 0;
Background-repeat: no-repeat;
Background-position: center;
}
# Txt ul {
Float: left;
}
Input # btn {
Color: Blue;
}
# Nav {
Margin: 0px auto;
Height: 200px;
}
# Link ul {
Margin: 0px auto;
Color: Black;
Float: left;
}
# Copy {
Clear: both;
Text-align: center;
Color: # 7777cc;
Font-size: 12px;
}
# Copy {
Color: # 7777cc;
}



From: http://www.111cn.net/cssdiv/56/f4164fcc3cd74141c519e1e5313289c4.htm


What is the difference between the ID selector and CLASS in CSS styles?

On the same page, the same id object can only appear once, but the same class object can appear multiple times. When referencing the css style, the id is marked, while the class uses ".. In script, only the id element can be obtained, but the class element cannot be obtained. That's all. As follows:
In css: # id {padding: 1px;} // is referenced by id
. Class {margin: 15px solid # 3d3f3e} // referenced by the class
In the script: Only getElementbyId ("name") // assume that the page is named
 
Which of the following is the highest priority for CSS class and id selectors?

<Div class = "case1" id = "case2"> </div>
<Style>
. Case2 {style content}
# Case2 {style content}
</Style>
If the structure is the same, the ID priority is higher than the CLASS.
ID is unique. A class page can contain many

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.