ComputersSoftware

CSS: font color, styles, background, size

Programming - that mirror: in the beginning there was a word, and the answer was not at all. And very quickly it was necessary to "change": first a mirror, then a word ... At this point in time the tables of cascading styles are good, but why did the developer's mind go so long? CSS is all the same array of times of the beginning of the era of computer programs, but only in a different perspective. Even when the arrays became associative, the revolution did not produce it.

The site page is HTML markup tags that can be assigned to a specific style class or style identifier. The first can be defined once and attributed to anything as many times as necessary, the second belongs to a particular element.

General style description logic

Traditionally, the style is placed in a CSS file, but can be assigned to a specific element in its style attribute. You can create a style in the dynamics using JavaScript. Of particular importance is not how to describe, for example, through CSS the font color , its size, the headset, the background under it, and so on. The place of the description of the style is important in the context, usually two, of ideas: the later is described, the more priority it is, and if it is described on an element, it is absolutely important. The last, written as is, explicitly determines the priority.

Apply a style so that, for example, some font color changes the color, you can do it anywhere and anyhow. The question is how the browser will react to this in the course of disassembling all the styles together. How much will it spend on CPU time?

Ideally, font color should be indicated only once - it's a classic. To think out to one simple description a couple more, and then again and again ... of course, you can. It's fashionable, but impractical.

Example of general logic

It's very simple: having determined by CSS color for only three elements, you can get at least three long-playing problems:

# Ele1, # Ele2, # Ele3 {
POSITION: absolute;
Left: 20px;
Top: 14px;
Color: red;
}

# Ele2, # Ele3 {
Left: 90px; // change the CSS coordinate horizontally
Color: yellow; // change the font color of CSS
}

# Ele3 {
Top: 114px; // change the CSS coordinate vertically

Color: green; // change the CSS font color again

Background-color: lightgrey; // the color of CSS text selection is changed, but this is not in # Ele1 and # Ele2; The position is also changed, but it has already changed in # Ele2 and not like here

}

Now we have to remember that all these three elements have been defined somewhere, and in case of changing the color representations of the site owner, the developer will have to remember not only about color, but also about left and top rules, and the color change of text selection should not be forgotten.

Not all developers honor the CSS requirement: the style of the identifier is only for one element, and the style of the class for many tags, and the latter can be specified in tags as adjectives:

  • Set font color in CSS - style of groundColor class;
  • Specify the font size - class size15;
  • Set the position - class PlaceUp.

Naturally, the use of identifiers, especially when they belong to a single element of markup, is better than a dozen style classes, painted in various combinations over a hundred page elements. But everything has its own objective logic.

The developer just needs to take into account correctly: if even the HTML font color , CSS offers to describe rigidly, then the flexibility of the general structure of descriptions is his work.

Expected result of application of the general logic

Modern browsers calmly refer to a large number of style files and their volumes. However, when designing, in particular, through CSS, the color of the entire page, one should always think about reasonable sufficiency. Not all style rules "cheap" look in application. A simple laconic entry: * {color: white;} - is certainly beautiful, but it applies to all elements of the page without exception.

Of all the rules that CSS has, the most important:

  • Style is a class, and then his name begins with ".";
  • Style - identifier and its name begins with the symbol "#";
  • In other cases - this is the name of the tag or something special

Other ideas in terms of describing styles (inheritance, overlapping properties, priorities, position, order, etc.) should be applied meaningfully and strictly as necessary.

The browser will always miss that does not understand in the description, so there will be no special surprises. If something was not in the right place or you could not set the font color in CSS, then the error is in style.

Unexpected opportunities

Do not abuse styles like * {left: 124px; } or

Ol ol, ol ul, ul ul, ul ol {margin-bottom: 0; }
A img {border: 0; }

Although it is difficult to force even a novice developer to use CSS rules as is. Always in the development of any site, even an ideally simple CSS syntax presents unforeseen problems. However, if you direct efforts in the proper use of syntax, but apply the JavaScript functionality to it, new unexpected features will allow you to avoid monotonous creation of identifiers for each element or to follow the variety of application of style classes.

CSS is not only a stylesheet connected to a page through a link tag or inserted into it via the style tag. It is also an opportunity to create a style on the fly or change an existing one.

Applying CSS, font color can be done programmatically. As well as size, position, indents. A site is not a goal to apply knowledge in CSS, HTML, PHP or flashing JavaScript effects.

A web resource is primarily information offered in a certain way. That's why CSS is best viewed in dynamics through the prism of how you can generate it while the page is still on the server (it is occupied by PHP when the visitor came to the site, not the developer at the time it develops the site), the desired style file For a specific text, for the current content, or create a class or ID style on the fly in the process of the page when it is viewed by a specific visitor.

Static dynamics

It is not always necessary to write complex JavaScript code to make content dynamic, and its design - adequate content. Sometimes it is enough to use the available opportunities correctly. In particular, by defining the color of the font by CSS as a static rule, you can hide this hidden rule and visualize another (visible) rule.

Here the dynamics does not require an algorithm:

// highlight the login button on the site
Function scfWelcomeOver () {
Document.getElementById ('scDocxNamePiP'). Style.visibility = 'visible';
}

// hide the login button on the site
Function scfWelcomeOut () {
Document.getElementById ('scDocxNamePiP'). Style.visibility = 'hidden';
}

CSS offers its own variants of dynamics: running lines, transparency of elements, various variants of overlays, manifestations, color fades. In CSS, font color can be made even such that no style rule is provided.

Dynamic content display

If there were no dogmas, there probably would not have been any progress. There is simply nothing to struggle with. Hypertext brought many dogmas to the world. It's time to pay attention to them and to develop websites in a pragmatic and practical style.

Initially there is a page (P), content (K) is placed on it, all page tags are described in the style sheet (S). It's not new to create a page P through PHP or Perl on the server, choosing K from the database. The existing style sheet S is attached automatically. However, K can be changed, and in most cases such a change will entail the need for other styles, that is, in S +.

For example, the customer said: "The site describing the life of Moscow, it will look better if the news articles are decorated in the style of" ZAZ-Zavtrak ", descriptions of the night bustle in the style of" Las Vegas ", and articles on scientific and technological progress in the style of" ModernTechno ". But if you make S for these three options, then there is no guarantee that the customer will not have an idea to have a set of articles "News", "Holidays", "Work", "CSS / HTML" and a bonus "Hostess".

More practical is another approach. Regardless of the category of the article, there is always content in it that can be colored in a certain color. Here at this place there is quite a sensible thought: after obtaining a specific K, even on the server to form an adequate S, and when the browser requires P, it will get the necessary content in proper design.

Dynamics of style from JavaScript

The minimal, albeit very effective, solution is to do the styling directly in the client's browser. First, it unloads the server - it will not be necessary to waste time on the formation of page hypertext and style files for it.

Secondly, the natural wastes of time inside the browser will create the effect that the page is busy and actively supports the dialogue with the visitor: still he does not perceive the content in bulk, therefore, he will like a consistent and thoughtful output of information.

Thirdly, it allows the developer to provide a mechanism for the visitor to create content in a style in which it is convenient. No one else has this.

To implement this idea, it is necessary to implement the mechanism for creating element styles immediately after the page is loaded and in the process of its functioning. A modern site is AJAX in one form or another. It is not difficult to perform the formation of styles directly in the process of forming a page tree. It's simple, accessible and effective, because content goes along with its design.

This does not contradict the current trend to separate the presentation of data from their processing and is performed on the data leaving the display.

CSS as the active component

Hypertext brought a lot of good, but only a small fraction of the natural information was successfully formalized, tools and experience of creating high-quality HTML, XML, CSS documents appeared. It is not a problem to formalize new volumes of information and to change what has been done before.

With regard to CSS, this process is already being activated in a completely different context. The built-in tools in JavaScript, allowing on the fly to create elements and styles of elements, did not anticipate such an opportunity, and the creators of PHP, in particular, believed to be engaged in the formation of only HTML pages.

Both the first and second allow you to do programming styles. This is a new direction in the field of information technology. Styles are a much more formal thing than HTML or XML, the rules are very simple. Style is always present in information, no matter what nature it is.

Data processing programmers are always engaged in much more informal spheres, but the CSS theme is a very simple task, but somehow did not fall into the field of view of the development process.

On dogmas in the field of programming

Like an iceberg, dogma can not long plow information spaces. The accumulated experience was to concentrate not only in HTML and CSS standards, tools for working with them, developers' knowledge.

A simple task - to make using CSS font color - found its own excellent solution. Rules, syntax, logic and convenience are unquestionable. But even when you really do not need a lot of fonts, you do not need a lot of colors for practice either, and in general, for virtualization purposes, all the accumulated "power" of HTML and CSS does not need at all, the moment comes when situational knowledge goes into reproducing ones and it appears Experience and tools of natural style education from content.

As it will, it may not be entirely clear, but the fact that the process is already underway is obvious.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.atomiyme.com. Theme powered by WordPress.