Div+css New beginning of Web layout design (3)

Source: Internet
Author: User
The following describes the combo selector
Combined selectors are the same attributes that are all put together

For example


I'm going to turn the 5 titles into red, and it's obviously a lot of trouble to define them.
We can do this.


Of course, ID selectors, class selectors, tag selectors can also be combined

, A, #b, div{color:red}

Be careful to separate them with commas.
If we don't use commas, it's the parent-child selector We're going to talk about.

<div id= "A" >

If I had to make the hi tag in the div red,
There are many ways to use a tag selector, but it will make all the H1 tags on the page red, not good
You can also use the class tag, but every H1 tag has to be a class trouble.

We can do this.


That's OK.

If that's the case

<div id= "A" ><a>

That's OK.


It's simple, but the father chooses to control any tag or class or ID selector underneath it, that is, grandson or heavy grandson.
So it's also possible.


But it is advisable not to do so. Because the hierarchy is unclear, it's easy to faint.


Another property selector, not very common

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Must be trained to add

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Document Description only Works

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

Only valid for equals a

The property selector is especially useful when styling a form that does not have a class or ID:

Input[type= "text"]{width:150px; display:block; margin-bottom:10px; background-color:yellow; Font-family:verdana, Arial; } input[type= "button"] {width:120px; margin-left:35px; display:block; Font-family:verdana, Arial;}

But it is not often used, do not do necessary training to master the content


Here is an introduction to the adjacent selector
This may be difficult to understand

<! DOCTYPE html>

This is actually for the first p style, margin-top:50px represents the margin 50px, later learned

There is also a sub-element selector, which is also difficult to understand

Let's look at the following

<! DOCTYPE html>

This is very familiar, father and son selector, I said Dad can control any of the following sub-elements, so two all red
If I only want a to be a child of P, and another A is a child of span, that

<! DOCTYPE html>

Both of these selectors have to be <!. DOCTYPE html> (Of course not only this), otherwise invalid


These two kinds of selectors are very flexible, as a master advanced bar, beginner or the other selector base to fight firmly


Now is the key Content div box model

This is a picture of the map, looking at another picture

Actually, it's clear to see.


The above is div+css page layout design New Beginning (3) content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.