CSS Native Support of Fonts
Category: CSS, CSS Expert Ideas | 1,041 views | Add a Comment |
The ability to embed fonts on a Web page has been a dream of many designers for years. @font-face is the CSS declaration that allows us to do this, but it is not widely supported by Web browsers, especially Internet Explorer. When CSS 2 first came out, the W3C actually recommended support for@font-face, but it was soon deprecated due to lack of support by CSS 2.1.
Now the demand has returned with a stronger push. Even though some current browsers don’t support it and older browser versions are still being used, most modern browsers do now support@font-face. If it is one day fully implemented, all we would have to do is this: Read more…
- No Related Post
Design-Related CSS Solutions
Category: CSS | 1,015 views | Add a Comment |
CSS was originally meant for styling after all, right? Let’s step back from the programming-related concepts, and turn again to the design element of CSS. Aside from functionality in coding, some of the ideas floating around relate to functionality in design. Let’s look at a few below, some of which already have solutions.
Advanced Hyphenation Techniques
With increasing attention paid to typography in the last few years, hyphenation has become a priority for many people. Well-designed websites hyphenate the text in areas where it is important to the layout so that the text does not have to be constantly altered. This improves alignment and better organizes the overall design. Read more…
- No Related Post
Smarter CSS Shortcuts
Category: CSS, CSS Expert Ideas | 1,034 views | Add a Comment |
A much-wanted feature in future versions of CSS is to be able to use alternative and smarter shortcuts to shorten CSS code. Some of these are already being implemented in alternative CSS languages, but the new CSS 3 has no sign of this. With greater support, perhaps basic CSS could become smart enough to handle these shortcuts in another 10 or so years, when CSS 4 is introduced.
To see the benefit anyway, let’s look at a few examples in which smarter shortcuts would be beneficial.
When many elements from a certain class or ID share the same properties, things can get a bit repetitious:
- #navigation h1, #navigation h2, #navigation h3{
- font-family: Verdana, Tahoma, sans-serif;
- letter-spacing: -1px;
- }
Smarter syntax would tighten things up, saving both time and space in the style sheet:
- #navigation [h1,h2,h3]{
- font-family: Verdana, Tahoma, sans-serif;
- letter-spacing: -1px;
- }
As most of us know, styling links in CSS can be a huge hassle. Nesting these elements, as shown above, is a great solution, but a smarter syntax for dealing with pseudo-classes would also be good: Read more…
- No Related Post
How to use Conditional CSS?
Category: CSS | 1,676 views | Add a Comment |
Conditional options in CSS have a variety of benefits but can also bring the same deficiencies as CSS variables in that they alter the state of CSS as it is. Many of the cons have to do with efficiency, confusion and, in some cases, added HTTP requests (because it deals with a type of server-side programming language).
Nonetheless, let’s look into more of the benefits of conditional CSS statements. Just keep in mind the cons that come with them, and always be thinking of new ideas to overcome them. So far, the tools and solutions that give developers and designers conditional statements in CSS have come to be relatively well accepted. This is because CSS conditionals seem to solve bigger problems in CSS, and the lack of efficiency seems minor by comparison.
Let’s not forget the original CSS conditional. The problem with the traditional CSS conditional for IE, however, is that it has no else or else if. Although the use may be limited, an if/else statement for CSS could allow designers and developers to specify styles for other types of conditions: browsers, for example.
One popular tool for calling styles according to browser type is Conditional-CSS.com. While many other solutions are out there for conditionals as well as this particular problem, this tool can do most of the work automatically, with minimal confusion. Read more…
- No Related Post
What is CSS Variables
Category: CSS | 877 views | Add a Comment |
Developers can easily see the benefit of using variables to code their Web apps, so seeing the benefit of variables in CSS is just as easy. Are they needed though? Before we answer a tough question like this, let’s go over what they are and how both designers and developers can use them.
Similar to a programming language, CSS variables can be used to define style sheet-wide values with one descriptive word. This one word can then be used repeatedly throughout the style sheet to use the value assigned to it. The point of variables is to save time and, in most cases, create more efficient code. An example of the idea in practice is below. Read more…
- No Related Post
css Selector Grouping
Category: CSS | 303 views | Add a Comment |
We can group selectors using a comma (,) separator. The following declaration block will apply to any element that matches either of the selectors in the group:
td, th {
? declarations
}
We can think of the comma as a logical OR operator, but it’s important to remember that each selector in a group is autonomous. A common beginner’s mistake is to write groups like this: Read more…
- No Related Post
CSS Attribute Selector
Category: CSS | 333 views | Add a Comment |
Description
An attribute selector will match elements on the basis of either the presence of an attribute, or the exact or partial match of an attribute value. Attribute selectors were introduced in CSS2.
Attribute selectors are delimited by square brackets; the simplest form of an attribute selector consists of an attribute name surrounded by square brackets:
[href] {
? declarations
}
This example selector matches any element that has an href attribute. It also contains an implied universal selector, and is equivalent to *[href].
Here’s another example:
a[href] {
? declarations
}
This selector matches any a element that has an href attribute, so it matches a hypertext link, but not a named anchor.
- No Related Post
CSS ID Selector
Category: CSS | 536 views | Add a Comment |
Description
An ID selector matches an element that has a specific id attribute value. Since idattributes must have unique values, an ID selector can never match more than one element in a document.
In its simplest form, an ID selector looks like this:
#navigation {
? declarations
}
This selector matches any element whose id attribute value is equal to"navigation". In this selector, which is equivalent to *#navigation, the universal selector is implied. The universal selector is often omitted in cases like this. Read more…
- Use shorthand CSS notation
- Organize your CSS-code
- HTML Basics
- CSS Framework
- 150 CSS Examples
- CSS background-size
- Using Logo with CSS
- Introduction to CSS3
- How to design css sitemap Tree
- How to create Rounded Corners Using CSS without Images
Class Selector
Category: CSS | 345 views | Add a Comment |
Description
Selecting elements on the basis of their class names is a very common technique in CSS. The attribute selector syntax [class~="warning"] is rather awkward, but thankfully there’s a simpler and shorter form for it: the class selector.
Here’s a simple example that selects all elements with a class attribute that contains the value "warning":
.warning {
? declarations
}
This example also illustrates the use of an implied universal selector—it’s equivalent to *.warning. Note that whitespace characters can’t appear after the period, or between an element type selector, or explicit universal selector, and the period. For example, the following selector will match all p elements with a class attribute that contains the value "warning":
p.warning {
? declarations
}
A simple selector may contain more than one attribute selector and/or class selector; in such cases, the selector pattern matches elements whose attributes contain all the specified components. Here’s an example:
div.foo.bar {
? declarations
}
div.foo.bar[title^="Help"] {
? declarations
}
The first example selector above matches div elements whose class attribute value contains both the words "foo" and "bar". The second example selector matches divelements whose class attribute values contains both the words "foo" and "bar", and whose title attribute values begin with the string "Help".
Example
The following selector will match all p elements with a class attribute that contains the value "intro":
p.intro {
? declarations
}
- No Related Post











