Css universal selector is set to . Universal CSS selector. Request for review

Golovna / 2 Cool Readers

Selector
Universal selector

The schema for the CSS code looks like this:

Selector ( css-power: value; css-power: value; ... and so on)

In the universal selector, as a selector, the sign * is used:

* ( CSS power: value; CSS power: value; ... etc. )

Universal selector, embedding on all tags of an HTML document.

For example, you can remove all internal and external inputs from all tags in an HTML document:

* ( margin: 0; padding: 0; )

Let's say we have an HTML document to check the following code:

Storinka about the snow leopard

Snow leopard

let's come in rank.

Let's help with the universal selector, let's change the color of the font for all green tags green , for the arial font, the style for the oblique font.

Storinka about the snow leopard

Snow leopard

Snow leopard (irbis, ak leopard) - a great husky savets from the cat family. Bags in the mountains of Afghanistan, Burma, Bhutan, India, Kazakhstan, Kyrgyzstan, China, Mongolia, Nepal, Pakistan, Russia, Tajikistan and Uzbekistan. The snow leopard has a thin, long, gnuchky body, prominently short paws, a small head and a long tail. The length of the snow leopard's tail at once becomes 200-230 cm, the weight is up to 55 kg. Zabarvlennya khutra is light, wild-frequently gray with ring-like or strong dark beaches.

Snow leopards mainly feed on mountain goats and rams, as well as wild boars, pheasants and howrahs in this diet. Due to the inaccessibility of the mind, irbisi dosi are littered with small things. However, according to approximate estimates, the number of people varies in the region of about 10 thousand individuals. By the camp for 2013, river watering on snow leopards is everywhere fenced.

The browser side will look like this.

You can also experiment with a different input, add 0, and then 15px, add it to the CSS code.

Sometimes you need to install one style for all elements of the web page at once, for example, install a font or an image text. In this way, a universal selector is additional, which matches any element of the web page.

In CSS3, the universal selector zastosovuetsya the same way in the combination of the space of names.

  • ns|* - all elements in the ns space of names.
  • *|* - all elements in all spaces of names.
  • |* - all elements without an explicit introduction to the space of names.

Syntax

* ( Description of style rules )

For the value of the universal selector, the zirochka symbol (*) is required. In some cases, the universal selector is neobov'yazkovo. So, for example, *.class and .class entries are identical in their result.

Appointment

Descriptionbutt
<тип> Specify the type of the value.<размер>
A&&BThe value may be displayed in the specified order.<размер> && <цвет>
A | BPlease indicate that you need to choose only one value from the proponations (A or B).normal | small-caps
A || BSkin meanings can be conquered independently or together with others in a sufficient order.width || count
Group of values.[crop || cross]
* Repeat zero or more times.[,<время>]*
+ Repeat one more times.<число>+
? Assignment type, the word chi group is not obov'yazkovim.inset?
(A, B)Repeat less A, ale s more times.<радиус>{1,4}
# Repeat one or more times through whom.<время>#
×

butt

Universal selector

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.

Note

Browser Internet Explorer up to the sixth version inclusive understanding of the *html design, which is illogical, oskilki tag є the tag of the upper level and more for the new none of the elements can not be. This pardon can be done to style for IE6, for example, the * html body ( ... ) construct will style the body selector in IE6 and is lower and does not work in other browsers.

At Internet browser Explorer 7 pіd hour adding a universal selector before the selector name without spaces, vin is accepted as a context selector. So, the *body entry works only in IE7 and is ignored by other browsers.

Specification

Skin specificity to go through the stages of hibernation.

  • Recommendation (Recommendation) - the specification has been praised by the W3C and is recommended as a standard.
  • Candidate Recommendation ( Possible recommendation) - a group that conforms to the standard, is satisfied, as if it were supporting its goals, but it needs additional help from the retailers to implement the standard.
  • Proposed Recommendation ( Promoted recommendation) - at which stage the document is submitted to the W3C Advisory for residual solidification.
  • Working Draft (Working Draft) - a larger mature version of the blueprint after discussing that amendments for a better look.
  • Editor's draft ( editorial blackie) - Black version of the standard after amendments made by the editors to the project.
  • draft ( Chernetka specifications) is the first black version of the standard.
×

The language description of the modern looking CSS document is constantly evolving. Over the years, not only the tightness and functionality grow, but also the flexibility and strength of the victoriousness.

Let's sort it out. Let me know if you are a CSS handyman, at least one of you has divided some of the assignments to types of selectors. There is nothing marvelous about him, shards of stench are one of themselves handy ways keruvannya by the content of the side. With help, you can interact with absolutely be-like HTML elements. Nine are 7 types of selectors:

  • for tags;
  • for classes;
  • for ID;
  • universal;
  • attributes;
  • for interaction with pseudo-classes;
  • for keruvannya pseudo-elements.

The syntax is simple. To learn how to vikoristovuvati, enough to read about them. Which option is better to choose to control the content of your mind? Let's try to get to know each other.

Selector tags

This is a simpler option, which does not require special knowledge for the record. To use tags, it is necessary to vikoristovuvat their name. Let's say that the "header" of your site is turned into a tag

. To wrap the CSS around it, you need to tweak the header() selector.

Positive vigor - simplicity vikoristannya, versatility.

Nedoliki - povna vіdsutnіst gnuchkostі. This app will have all header tags displayed in a row. And what is it necessary to cherubate only one?

Selectory class

The widest option. Appointments for keruvannya tags with the class attribute. Let's say your code has three blocks

, for skin s, it is necessary to set a singing color. How tse robiti? Standard CSS selectors do not follow the tags, they specify the parameters of all blocks in a row. Excuse me. Assign an element to a class. For example, the first div with class='red', the other with class='blue', and the third with class='green'. Now you can select them for additional CSS tables.

The syntax is as follows: specify a dot ("."), after which I write the name of the class. Shchob cheruvati first block, vikoristovuemo design. Others - .blue and so on.

Important! It is recommended that you understand the meaning of the class attribute. In a filthy tone, the use of transliteration (for example, krasiviy-blok) or vipadkovy combinations of letters/numbers (ojfh834871) is respected. With such a code, you get confused, it doesn’t seem like it’s about those who, with some difficulties, get stuck in the project after you. Optimal option- Vykoristovuvaty as a methodology, for the sake of BEM.

Positive vigor - to make your head high.

Nedoliki - at kіlkoh elementіv may be of the same class, then, the stench will redaguvatimutsya at once. The problem is succumbing to the deviance of methodology, as well as the decline of preprocessors. Obov'yazkovo master less, sass or any other preprocessor, stench forgive the robot.

Selector with ID

For any variant, the ideas of the drafters and the programmers are ambiguous. Deyakі assistantscssvzagali do not recommend vikoristovuvatiid,Shards with inaccurate stasis of stench can cause problems with decay. However, a lot of favorites are actively arranged in all directions. Verishuvat you. The syntax is as follows: the symbol ґrat ("# ”), Potim im'ya bloc. For example,#Red.

IDdepends on the class for the number of parameters. First, on the side, you can’t have two of the sameID.We are assigned unique names. In another way, such a selector may have a higher priority. Tse means that you can assign a class to the blockredand enter in the tablescssred and then assign youmaid blueIf you change the blue color, the block will become blue.

Positive vibes - you can tweak it with a specific element, without sacrificing respect for styles for tags and classes.

Nedoliki - it is easy to get lost at the great kіlkostIDіclass.

Important! How do you respect the BEM methodology (or its analogues),IDyou, zahalom, do not need. This kind of layout technique can be found in different unique classes, which is richer.

Universal selector

Syntax: asterisk sign ("*") and curly arches, tobto *{}.

Victory for the recognition of singing attributes once to all the elements of the side. When can you be in good luck? For example, if you want to set the side of powerbox-sizing: border-box.It is possible to vikoristovuvatis not only for keruvannya all components of the document, but also for the control of all child elements of the main block, for example,div*().

Perevagi - you can keruvati great kіlkistyu elements at once.

Nedoliki - not enough flexible option. In addition, the choice of this selector in some ways improves the work of the side.

Behind the attributes

Give the ability to cherubate an element from a specific attribute. For example, you have a few input tags with different attribute types. One of them is the text, the other is the password, the third is the number. Obviously, you can set the skin class ID, but don't enter it manually. CSS selectors behind attributes allow you to specify values ​​for song tags with maximum precision. For example, the axis is:

input()

This attribute selector selects all inputs of type text.

The tool to do it is gnuchky, you can beat it with whatever tags, like you can see the presence of attributes. And yet not all! With the CSS specification, you can control the navigation elements with great ease!

Apparently, on your side there is an input with the attribute placeholder="Enter name" and input placeholder="Enter password". You can also choose for the help of the selector! For whom the victorious construction is coming:

input() or input

Possibly a gnuchkish robot with attributes. Let's say you have a sprig of tags with similar title attributes (let's say, "Caspian" and "Caspian"). To choose insults, vikoristovuєmo such selectors:

CSS select all elements, for titles of any є the symbols "Caspian", that is "Caspian" and "Caspian".

You can also select tags, the attributes of which are based on the sing symbols:

or end with them:

{}.

Perevagi - the maximum flexibility. You can choose whether or not the essential elements of the side without the same with the classes.

Nedoliki - vikoristovuetsya appreciably rarely, less in specific vipadkah. A lot of verstalnikov give priority to the methodology, the shards indicate the class more simply, lower the numerical signs “equally”. In addition, these selectors do not work on the Internet. Explorer version 7 and below. Vtіm, who needs old Internet Explorer at a time?

Pseudo-class selectors

Pseudo-class designates the element's state. For example, :hover - those that show up on the other side when you hover over the cursor, :visited - see the message. These include xtalt elements: first-child i: last-child.

This type of selectors actively zastosovuetsya at the modern verst, oskolki zavdyaki new can sprobit side "live" without zastosuvannya JavaScript. For example, you want to work in such a way that when you hover over a button with the btn class, the color changes. For which vicorist, such a construction is possible:

Btn: hover (

Background color: red

For beauty, you can indicate in the main powers of the button the power of the transition, for example, in 0.5s - in this case, the button of the black time is not a mitte, but a stretch for a second.

Perevags are actively vindicated for the “revitalization” of the parties. Forgive me for being stagnant.

Nedoliki - there are none. Tse true zruchny zasib. However, ignorant typesetters can get lost among the great number of pseudo-classes. The problem is overcome by learning and practice.

Pseudo-element selectors

"Pseudo-elements" - these are the parts of the page, there are none in HTML, but they can all be twisted. Didn't you understand anything? Everything is simpler, it’s easier. For example, you want to add the first letter in a row of great and red, leaving the other text in small and black. Obviously, you can put this letter in a span with a sing class, but it's boring and boring. It's easier to see the paragraph and highlight the pseudo-element::first-letter. Vin gives the ability to cherubate with the familiar look of the first letter.

It is necessary to finish a lot of pseudo-elements. Pererahuvati їх at the borders of one statti is unlikely to go away. You can find the latest information in your favorite search system.

Positive vibes - to give the opportunity to gnuchko nalashtovuvat zvnіshnіshnіshnіshі vglyad side.

Nedoliki - newbies often get lost in them. A lot of selectors of this type are less practical in other browsers.

P_dvedemo p_dbag

The selector is an attempt to control the flow of the document. Zavdyaki youmu can choose the absolutely skin component of the side (navit іsnuyuchiy is less mentally). Obov'yazkovo vychit usi nayavnі options or write down їх. This is especially important, as you create folding sides with modern design and a great number of interactive elements.

The CSS universal selector is perhaps the easiest to understand, so you know that the styles will be stuck to absolutely all the elements without blaming. The universal selector consists of only one sign - a zirochka (*), the offensive syntax is:

* { power: meaning; power: meaning; ... )

An example of a variation of the CSS universal selector

Universal selector

Paragraph 1

Paragraph 2

Paragraph 3

Result in browser

Paragraph 1

Paragraph 2

Paragraph 3

For this butt, the fields were reset to zero, and the frames of the side elements were tidied up. What else can be needed? As you already know from the lesson some HTML-elementi on the back of the head weigh the same meanings of some powers, for example, in paragraphs of the price of non-zero upper and lower margins of empty space, in the case of a silan-image frame, etc. Ale, not everything is so simple, right in what's in different browsers rozmir tsikh watering can deshcho vіdіznyatisya, and deyakі already long ago not set the framework for zamovchuvannyam at silan-images. But far from everything is possible.

So the axis, a lot of verstalnikov (and you learn to verst at once) create the so-called “Skidannya CSS styles”, so that on the cob of the style table they reset all possible non-zero CSS values, and then, in the process, add styles to the elements, but also, of course, with their own values. In this way, you can be sure that the HTML side looks the same in all browsers.

Even more often, for the dropping of styles, the universal selector is also stagnant, if you want to use it for the sake of it, you just need to override the selector tags through someone else, and otherwise don’t beat the dropdown, relying on your own respect. How robitimete you - virishuvati only to you, but in any case, it’s too early to think about it. And be sure that from time to time you yourself will develop your own style of writing styles (voice for tautology) so don’t fool around with it.

Homework.

I don’t care about the homework of the universal selector, because everything is already obvious here, so I’ll take care of a few other things.

  1. Change the styles of the tag in such a way that the vin becomes similar to a paragraph. Yaku power for whom it is necessary to think for yourself.
  2. Change the tag of the paragraph so that it becomes similar to the tag of seeing other quotes.
  3. Convert the tag from the inline element to the block element. Victory for whom power

Sometimes you need to install one style for all elements of the web page at once, for example, install a font or an image text. In this way, a universal selector is additional, which matches any element of the web page.

For the value of the universal selector, the slash character (*) is required and the syntax will be available.

* (Description of style rules)

At In some cases, the universal selector is not obv'yazkovo. So, for example, records*.class and .class are identical in their result.

At butt 1.50 shown one possible additions Universal selector - choose font and size text for all document elements.

butt 1.50. Variant of universal selector

Universal selector