NetBeans 8.0.1 is already out there!


Where it cames from

Still alive and more powerful than ever, NetBeans has reached its mark 8.0.1 five months after Oracle decided to boost Java World to the pool blackball‘s number.

NetBeans Logo

So far it has been the update that has been the slowest to come out.

Version Update Months
7.0 7.0.1 3
7.1 7.1.1 2
7.2 7.2.1 3
7.3 7.3.1 4
7.4
8.0 8.0.1 5

Due to the amount of the project’s complexity, it is becoming increasingly difficult to round a new version according to a previously planified roadmap.
Sigue leyendo

Anuncios

How to setup nodejs with Netbeans 8.1Beta


Hi folks!

I know, I know. I was missing. It’s been long time since my last post here. But I’m back … for now!

Im-Back

I’m not obsessed with it but I like being up to date of NetBeans IDE evolution and the main source is obviously NetBeans Home Page.

NetBeans-HomePage

First stop, I normally take a view to the NetBeans Release Roadmap which brings me a quick view of how things will be doing next months. Opss…! NetBeans 8.1 is coming next October.

NetBeans - Roadmap

Next, I usually visit NetBeans News Section with the most recent Featured Articles activity, NetBeans Podcast and Release News. NetBeans days happened all around the world!!!

Netbeans - News

And finally I end up my visit with the NetBeans Newsletter Section in which last year, every one or two weeks, Geertjan Wielenga uses to sign a sort of numbered NetBeans electronic magazines called “Issues” which have reached for #700 past August 11th.

NetBeans - NewsLetters

Focusing on today’s topic I read on Issue #700 – Aug 11, 2015, Blogs section, an interesting post called “Node.js and JavaScript” with this introduction:

Join us, Node.js developers everywhere, NetBeans is a lightweight and free tool with a special new focus on Node.js application development! Node.js is the key feature of NetBeans IDE 8.1, which has been released in its Beta release. Find out the basic features of how Node.js works in NetBeans IDE 8.1.

Sigue leyendo

CSS Basics – Values – Functional Notations


Introduction

In an early post I told you about CSS Selectors which, through CSS Rules, are used for binding style properties to elements written inside markup language documents. Then, taking as reference the CSS3 specifications, I spoke of CSS properties and of the values definition ​​they can take. The main topic was the syntax that follows this definition in the text of the official specifications.

css-logo

Today I’m going to focus on the other units that CSS Values are able to adquire which are not related and different respect others seen before.

Functional notation

A functional notation is a type of component value that can represent more complex types or invoke special processing.

The syntax starts with the name of the function immediately followed by a left parenthesis followed by the argument(s) to the notation followed by a right parenthesis. Whitespace is allowed, but optional, immediately inside the parentheses. If a function takes a list of arguments, the arguments are with optional whitespace before and after the comma.

   background: url(http://www.example.org/image);
   color: rgb(100, 200, 50 );
   content: counter(list-item) ". ";
   width: calc(50% - 2em);

Mathematical Expressions

The calc() function allows mathematical expressions with addition (‘+’), subtraction (‘-’), multiplication (‘*’), and division (‘/’) to be used as component values. The ‘calc()’ expression represents the result of the mathematical calculation it contains, using standard operator precedence rules. It can be used wherever <length>, <frequency>, <angle>, <time>, <number>, or <integer> values are allowed. Components of a ‘calc()’ expression can be literal values, ‘attr()’ or ‘calc()’ expressions, or <percentage> values that resolve to one of the preceding types.

section {
   float: left;
   margin: 1em; border: solid 1px;
   width: calc(100%/3 - 2*1em - 2*1px);
}

p {
   margin: calc(1rem - 2px) calc(1rem - 1px);
}

The following sets the ‘font-size’ so that exactly 40em fits within the viewport, ensuring that roughly the same amount of text always fills the screen no matter the screen size.

:root {
   font-size: calc(100vw / 40);
}

If the rest of the design is specified using the ‘rem’ unit, the entire layout will scale to match the viewport width.

The following example stacks two centered background images, with one offset slightly from the other.

.foo {
   background: url(top.png), url(bottom.png);
   background-repeat: no-repeat;
   background-position: calc(50% + 20px) calc(50% + 20px), 50% 50%;
}

This example shows how to place color-stops on a gradient an equal distance from either end.

.foo {
   background-image: linear-gradient(to right, silver, white 50px, white calc(100% - 50px), silver);
}

Toggling Between Values

The toggle() expression allows descendant elements to cycle over a list of values instead of inheriting the same value.

The following example makes <em> elements italic in general, but makes them normal if they’re inside something that’s italic:

em {
   font-style: toggle(italic, normal);
}

The following example cycles markers for nested lists, so that a top level list has disc-shaped markers, but nested lists use circle, then square, then box, and then repeat through the list of marker shapes, starting again (for the 5th list deep) with disc.

ul {
   list-style-type: disc;
}

ul ul {
   list-style-type: toggle(disc, circle, square, box);
}

Attribute References

The attr() function is allowed as a component value in properties applied to an element or pseudo-element. It returns the value of an attribute on the element. If used on a pseudo-element, it returns the value of the attribute on the pseudo-element’s originating element.

This example shows the use of attr() to visually illustrate data in an XML file:

<stock>
   <wood length="12"/>
   <wood length="5"/>
   <metal length="19"/>
   <wood length="4"/>
</stock>

Here comes CSS:

stock::before {
   display: block;
   content: "To scale, the lengths of materials in stock are:";
}

stock > * {
   display: block;
   width: attr(length em); /* default 0 */
   height: 1em;
   border: solid thin;
   margin: 0.5em;
}

wood {
   background: orange url(wood.png);
}

metal {
   background: silver url(metal.png);
}

All of the following examples are invalid and would cause a parse-time error, and thus cause the relevant declaration—in this case all of them—to be ignored:

content: attr(title color); /* 'content' doesn't accept colors */

Another example.

content: attr(end-of-quote string, inherit) close-quote; /* the 'inherit' value is not allowed there, since the result would be 'inherit close-quote', which is invalid. */

Another more.

margin: attr(vertical length) attr(horizontal deg); /* deg units are not valid at that point */

And finally another more.

color: attr(color); /* 'color' doesn't accept strings */

The attr() expression cannot currently fall back onto another attribute.

And that is all. With this entry CSS Basics series are over.

I hope you like it.

Regards.

CSS Basics – Values – Other units


Introduction

In an early post I told you about CSS Selectors which, through CSS Rules, are used for binding style properties to elements written inside markup language documents. Then, taking as reference the CSS3 specifications, I spoke of CSS properties and of the values definition ​​they can take. The main topic was the syntax that follows this definition in the text of the official specifications.

Today I’m going to focus on the syntax that follows the CSS specifications definition of some Data Types not related with others seen before.

css

As you already know, CSS stands for Cascading Style Sheets. A CSS document is used for describing the rendering of HTML and XML documents on screen, on paper, in speech, etc.

This description is formulated using CSS rules which uses Selectors for binding style properties to elements in the document. Inside a CSS Rule there is a set of CSS declarations.

cssrule

An example of CSS Rule could be:

p#intro {
   color: OliveDrab;
   font-size: 125%;
   margin: 15px 10px 15px 25px;
}

A CSS declaration is the pair formed by a CSS property name and its value. In a declaration there is always a colon between the property name and its value and always finishes with a semi-colon. For instance, in the declaration:

font-size: 125%;

There are two fields:

Property - font-size
Value    - 125%

Angles

Angle values are dimensions denoted by <angle> in the values specification syntax. The angle unit identifiers are:

  • Degrees – [deg] – There are 90 degrees in a quarter circle and  360 degrees in a full circle.
  • Gradians – [grad] –  Also known as “gons” or “grades”. There are 100 gradians in a quarter circle and 400 gradians in a full circle.
  • Radians – [rad] – There are π/2 radians in a quarter circle and 2π radians in a full circle. The symbol π denotes the irrational mathematical constant PI.
  • Turns – [turns] – There is 1 turn in a full circle.

Times

Time values are dimensions denoted by <time> in the values specification syntax. The time unit identifiers are:

  • Seconds – [s]. There are 60 seconds in a minute and 3600 seconds in an hour.
  • Milliseconds – [ms]There are 1000 milliseconds in a second.

Properties may restrict the time value to some range. If the value is outside the allowed range, the declaration is invalid and must be ignored.

Frequencies

Frequency is a magnitude to measure cyclic occurrences and frequency values are dimensions denoted by <frequency> in the values specification syntax. The frequency unit identifiers are:

  • Hertz – [Hz]. It represents the number of occurrences per second.
  • KiloHertz – [kHz]. A kiloHertz is 1000 Hertz.

For example, in the Spanish guitar:

  • Mi / E (6th string) – 82,41Hz.
  • La / A (5th string) – 110,00Hz.
  • Re / D (4th string) – 146,83Hz.
  • Sol / G (3th string) – 196,00Hz.
  • Si / B (2nd string) – 246,94Hz.
  • Mi / E (1st string) – 329,63Hz.

Resolutions

The resolution units represents the size of a single “dot” in a graphical representation by indicating how many of these dots fit in a CSS absolute unit dimension (‘in’, ‘cm’, or ‘px’).

Resolution units are dimensions denoted by <resolution> in the values specification syntax. The resolution unit identifiers are:

The default resolution images displayed in CSS is 1dppx:

1in   is equivalent to 96px
1dppx is equivalent to 96dpi

The following @media rule uses Media Queries to assign some special style rules to devices that use two or more device pixels per CSS ‘px’ unit:

@media (min-resolution: 2dppx) { … }

And that is all for today.

I hope you like it.

Regards.

CSS Basics – Values – Distance units


Introduction

In an early post I told you about CSS Selectors which, through CSS Rules, are used for binding style properties to elements written inside markup language documents. Then, taking as reference the CSS3 specifications, I spoke of CSS properties and of the values definition ​​they can take. The main topic was the syntax that follows this definition in the text of the official specifications.

Today I’m going to focus on the syntax that follows the CSS specifications definition of distance units in some CSS properties.

css

As you already know, CSS stands for Cascading Style Sheets. A CSS document is used for describing the rendering of HTML and XML documents on screen, on paper, in speech, etc.

This description is formulated using CSS rules which uses Selectors for binding style properties to elements in the document. Inside a CSS Rule there is a set of CSS declarations.

cssrule

An example of CSS Rule could be:

p#intro {
   color: OliveDrab;
   font-size: 125%;
   margin: 15px 10px 15px 25px;
}

A CSS declaration is the pair formed by a CSS property name and its value. In a declaration there is always a colon between the property name and its value and always finishes with a semi-colon. For instance, in the declaration:

margin: 15px 10px 15px 25px;

There are two fields:

Property - margin
Value    - 15px 10px 15px 25px

As you can see, in the value field there are four components:

margin - top    - 15px
margin - right  - 10px
margin - bottom - 15px
margin - left   - 25px

Each component is a distance measure which always has two parts:

  • Numeric value.
  • Distance measurement.

Distance measurements

Properties may restrict numeric values to some range. If the value is outside the allowed range, the declaration is invalid and must be ignored.

CSS theoretically supports infinite precision and infinite ranges for all value types; however in reality implementations have finite capacity. UAs should support reasonably useful ranges and precisions.

Lengths refer to distance measurements and are denoted by <length> type in the property definitions. A length is a dimension. However, for zero lengths the unit identifier is optional, thus can be syntactically represented as the <number> value ‘0’.

A dimension is a number immediately followed by a unit identifier. It corresponds to the DIMENSION token in the grammar. Like keywords, unit identifiers are case-insensitive within the ASCII range.

Properties may restrict the length value to some range. If the value is outside the allowed range, the declaration is invalid and must be ignored.

While some properties allow negative length values, this may complicate the formatting and there may be implementation-specific limits. If a negative length value is allowed but cannot be supported, it must be converted to the nearest value that can be supported.

In cases where the used length cannot be supported, user agents must approximate it in the actual value.

There are two types of length units:

  • Relative.
  • Absolute.

Relative lengths

Relative length units specify a length relative to another length. Style sheets that use relative units can more easily scale from one output environment to another.

The relative units are:

Unit Name Relative to
em M-Width Width of the “M” glyph in the element’s font
ex X-Height Height of the “x” glyph in the element’s font
ch 0-Width Width of the “0” (ZERO, U+0030) glyph in the element’s font
rem Root font size Font size of the root element
vw Viewport width 1% of viewport’s width
vh Viewport height 1% of viewport’s height
vmin Viewport minimum 1% of viewport’s smaller dimension
vmax Viewport maximum 1% of viewport’s larger dimension

Child elements do not inherit the relative values as specified for their parent, they inherit the computed values.

Font-relative lengths

Aside from rem unit which refers to the font-size of the root element, the rest of font-relative lengths refer to the font metrics of the element on which they are used.

The exception is when they occur in the value of the font-size property itself, in which case they refer to the computed font metrics of the parent element or the computed font metrics corresponding to the initial values of the ‘font’ property, if the element has no parent.

em unit

Equal to the computed value of the ‘font-size’ property of the element on which it is used.

The rule:

h1 { line-height: 1.2em }

means that the line height of h1 elements will be 20% greater than the font size of h1 element. On the other hand:

h1 { font-size: 1.2em }

means that the font size of h1 elements will be 20% greater than the computed font size inherited by h1 elements.

ex unit

The x-height is so called because it is often equal to the height of the lowercase “x”. However, an ex unit is defined even for fonts that do not contain an “x” character. Moreover, remember there is not any font-height property but font-size property.

The x-height of a font can be found in different ways by UAs:

  • Some fonts contain reliable metrics for the x-height.
  • If reliable font metrics are not available, UAs may determine the x-height from the height of a lowercase glyph. One possible heuristic is to look at how far the glyph for the lowercase “o” extends below the baseline, and subtract that value from the top of its bounding box.
  • In the cases where it is impossible or impractical to determine the x-height, a value of 0.5em must be assumed.

ch unit

Equal to the used advance measure of the “0” (ZERO, U+0030) glyph found in the font used to render it.

rem unit

Equal to the computed value of ‘font-size’ on the root element, which in HTML is the html element.

When specified on the ‘font-size’ property of the root element, the rem units refer to the property’s initial value., which, in HTML, for html element is 16px.

Viewport-percentage lengths

The viewport-percentage lengths are relative to the size of the initial containing block, usually in a mobile phone or tablet is the display size. When the height or width of the initial containing block is changed, they are scaled accordingly.

However, when the value of overflow property on the root element is auto, any scroll bars are assumed not to exist. Note that the initial containing block’s size is affected by the presence of scrollbars on the viewport.

In order to exemplary viewport-percentage lengths let’s suppose the width and height of the viewport are

Viewport width  - 400mm
Viewport height - 300mm

vw unit

This unit is equal to 1% of the width of the initial containing block.

Considering the CSS rule below:

h1 { font-size: 8vw }

the font size of h1 elements will be:

32mm --- 8 × 400mm / 100

vh unit

This unit is equal to 1% of the height of the initial containing block.

Considering the CSS rule below:

h1 { font-size: 8vh }

the font size of h1 elements will be:

24mm --- 8 × 300mm / 100

vmin unit

This unit is equal to the smaller of vw or vh.

Considering the CSS rule below:

h1 { font-size: 8vmin }

the font size of h1 elements will be:

vw   - 32mm --- 8 × 400mm / 100
vh   - 24mm --- 8 × 300mm / 100
vmin ≡ vh - 24mm

vmax unit

This unit is equal to the larger of vw or vh.

Considering the CSS rule below:

h1 { font-size: 8vmax }

the font size of h1 elements will be:

vw - 32mm --- 8 × 400mm / 100
vh - 24mm --- 8 × 300mm / 100
vmax ≡ vw - 32mm

Absolute lengths

The absolute length units are fixed in relation to each other and anchored to some physical measurement. They are mainly useful when the output environment is known.

The absolute units consist of:

  • The physical units  – in, cm, mm, pt, pc.
  • The screen resolution unit  – px.
Unit Definition
cm centimeters
mm millimeters
in inches: 1in is equal to 2.54cm
px pixels: 1px is equal to 1/96th of 1in
pt points: 1pt is equal to 1/72nd of 1in
pc picas: 1pc is equal to 12pt

For example.

h1 { margin: 0.5in } /* inches */
h2 { line-height: 3cm } /* centimeters */
h3 { word-spacing: 4mm } /* millimeters */
h4 { font-size: 12pt } /* points */
h4 { font-size: 1pc } /* picas */
p { font-size: 12px } /* px */

There are some recommendations in using absolute length units:

  • For a CSS device, these dimensions are either anchored:
    • By relating the physical units to their physical measurements.
    • By relating the pixel unit to the reference pixel.
  • For print media and similar high-resolution devices, the anchor unit should be one of the standard physical units, inches, centimeters, etc.
  • For lower-resolution devices, and devices with unusual viewing distances, it is recommended instead that the anchor unit be the pixel unit.
  • For such devices it is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel.

Notice that:

  • When the anchor unit is the pixel unit, the physical units might not match their physical measurements.
  • Alternatively, if the anchor unit is a physical unit, the pixel unit might not map to a whole number of device pixels.

This definition of the pixel unit and the physical units in CSS3 Specifications differs from previous versions of CSS.

In particular, in previous versions of CSS the pixel unit and the physical units were not related by a fixed ratio: the physical units were always tied to their physical measurements while the pixel unit would vary to most closely match the reference pixel.

This change was made because too much existing content relies on the assumption of 96dpi, and breaking that assumption breaks the content.

The reference pixel is the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm’s length. For a nominal arm’s length of 28 inches, the visual angle is therefore about 0.0213 degrees. For reading at arm’s length, 1px thus corresponds to about 0.26 mm (1/96 inch).

And that is all for today. I hope you like it.

In the next post, in CSS Basics series, I will tell you about Other Units in Values definition syntax.

Regards.

CSS Basics – Values – Numeric Data Types


Introduction

In an early post I told you about CSS Selectors which, through CSS Rules, are used for binding style properties to elements written inside markup language documents. Then, taking as reference the CSS specifications, I spoke of CSS properties and of the values definition ​​they can take. The main topic was the syntax that follows this definition in the text of the official specifications.

Today I’m going to focus on the syntax that follows the CSS specifications definition of Numeric Data Types values in some CSS properties. Of course, this another really boring yet essential part of CSS Basics, you are already warned!.

css-logo

As you already know, CSS stands for Cascading Style Sheets. A CSS document is used for describing the rendering of HTML and XML documents on screen, on paper, in speech, etc.

This description is formulated using CSS rules which uses Selectors for binding style properties to elements in the document. Inside a CSS Rule there is a set of CSS declarations.

cssrule

An example of CSS Rule could be:

p#intro {
   color: OliveDrab;
   font-size: 125%;
   margin: 15px 10px 15px 25px;
}

A CSS declaration is the pair formed by a CSS property name and its value. In a declaration there is always a colon between the property name and its value and always finishes with a semi-colon. For instance, in the declaration:

font-size: 125%;

There are two fields:

Property - font-size
Value    - 125%

Properties may restrict numeric values to some range. If the value is outside the allowed range, the declaration is invalid and must be ignored.

CSS theoretically supports infinite precision and infinite ranges for all value types; however in reality implementations have finite capacity. UAs should support reasonably useful ranges and precisions.

Integers: the ‘<integer>’ type

Integer values are denoted by <integer>. An integer is one or more decimal digits ‘0’ through ‘9’ and corresponds to a subset of the NUMBER token in the grammar. The first digit of an integer may be immediately preceded by ‘-’ or ‘+’ to indicate the integer’s sign.

The <integer> type is used in numerous CSS properties like z-index, line-height, counter-increment, column-count, etc. For instance:

Property      - z-index
Values        - auto | <integer> | inherit
Initial value - auto
Applies to    - positioned elements
Inherited     - No

There isn’t any unit associated to a <integer> which is not a CSS dimension.

Numbers: the ‘<number>’ type

Number values are denoted by <number> which represents a number either integer or fractional. Thus number is either an <integer> or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. It corresponds to the NUMBER token in the grammar. As with integers, the first character of a number may be immediately preceded by ‘-’ or ‘+’ to indicate the number’s sign.

As a example, in this property definition is used the <number> type:

Property       - line-height'
Value          - normal | <number> | <length> | <percentage> | inherit
Initial        - normal
Applies to     - all elements
Inherited      - yes
Percentages    - Refer to the font size of the element itself
Media          - Visual
Computed value - For <length> and <percentage> the absolute value; otherwise as specified

Like for <integer> data type, there isn’t any unit associated to a <number>, which is not a CSS dimension.

Percentages: the ‘<percentage>’ type

A percentage value is denoted by <percentage>, consists of a <number> immediately followed by a percent sign ‘%’. It corresponds to the PERCENTAGE token in the grammar.

Percentage values are always relative to another value, for example a length. Each property that allows percentages also defines the value to which the percentage refers. The value may be:

  • The value of another property for the same element.
  • A property for an ancestor element.
  • A value of the formatting context.

When a percentage value is set for a property of the root element and the percentage is defined as referring to the inherited value of some property, the resultant value is the percentage times the initial value of that property.

Last example again to illustrate the use of this type:

Property       - line-height'
Value          - normal | <number> | <length> | <percentage> | inherit
Initial        - normal
Applies to     - all elements
Inherited      - yes
Percentages    - Refer to the font size of the element itself
Media          - Visual
Computed value - For <length> and <percentage> the absolute value; otherwise as specified

And that is all for today. I hope you like it.

In the next post, in CSS Basics series, I will tell you about Distance Units in Values definition syntax.

Regards.

CSS Basics – Values – Textual Data Types


Introduction

In an early post I told you about CSS Selectors which, through CSS Rules, are used for binding style properties to elements written inside markup language documents. Then, taking as reference the CSS specifications, I spoke of CSS properties and of the values definition ​​they can take. The main topic was the syntax that follows this definition in the text of the official specifications.

Today I’m going to focus on the syntax that follows the CSS specifications definition of textual data types values in some CSS properties. And … yes, this another really boring yet essential part of CSS Basics, you are warned!.

ipsum

As you already know, CSS stands for Cascading Style Sheets. A CSS document is used for describing the rendering of HTML and XML documents on screen, on paper, in speech, etc. 

This description is formulated using CSS rules which uses Selectors for binding style properties to elements in the document. Inside a CSS Rule there is a set of CSS declarations.

cssrule

An example of CSS Rule could be:

p#intro {
   color: OliveDrab;
   font-size: 125%;
   margin: 15px 10px 15px 25px;
}

A CSS declaration is the pair formed by a CSS property name and its value. In a declaration there is always a colon between the property name and its value and always finishes with a semi-colon. For instance, in the declaration:

color: OliveDrab;

There are two fields:

Property - color
Value    - OliveDrab

Identifiers

An identifier is a sequence of characters conforming to the IDENT token in the grammar. Identifiers cannot be quoted; otherwise they would be interpreted as a string.

As you can see, in the later property definition example:

color: OliveDrab;

it has been used an identifier as property value:

OliveDraw

So it is are written without quotes.

Predefined Keywords

In the value definition fields, keywords with a predefined meaning appear literally. Keywords are CSS identifiers and are interpreted case-insensitively within the ASCII range.

For example, here is the value definition for a property:

Property - border-collapse
Value    - collapse | separate

And here is an example of its use:

table { border-collapse: separate}

As you can see, it has been used separate which is one of possible values for border-collapse property. As of it is a keyword it is interpreted case-insensitively, so you could write:

Separate
SEPARATE
SePaRaTe

without any problem. Said that is better to write it exactly as shown in specifications.

CSS-wide keywords: ‘initial’ and ‘inherit’

All properties accept the CSS-wide keywords, which represent value computations common to all CSS properties.

  • The inherit keyword is defined in CSS21. It means that, for a given element, the property takes the same specified value as the property for the element’s parent. The inherit value can be used to enforce inheritance of values, and it can also be used on properties that are not normally inherited.
  • The initial keyword represents the specified value that is designated as the property’s initial value.

For readability these are not listed explicitly in the property value syntax definition. For example, the full value definition of:

border-color

is:

[<color>{1,4}] | inherit | initial

even though it is listed in Background and Border Specification as:

<color>{1,4}

This implies that, in general, combining these keywords with other component values in the same declaration results in an invalid declaration. For instance, this declaration:

background: url(corner.png) no-repeat, inherit;

is invalid because inherit keyword appears combined with other values.

Author-defined Identifiers: the ‘<custom-ident>’ type

Some properties accept arbitrary author-defined identifiers as a component value. This generic data type is denoted by <custom-ident>, and represents any valid CSS identifier that does not otherwise appear as a predefined keyword in that property’s value definition.

Such identifiers are fully case-sensitive in the ASCII range, so

user-id
USER-ID
user-ID
User-Id

are four different user-defined identifiers.

The CSS-wide keywords are not valid identifiers for this category. This also happens with default keyword which is a reserved keyword. Reserved keywords are reserved in all ASCII case permutations.

Quoted Strings: the ‘<string>’ type

Strings are denoted by <string> and consist of a sequence of characters delimited by double quotes or single quotesDouble quotes cannot occur inside double quotes, unless escaped, as “\”” or as “\22”. Analogously for single quotes, like ‘\” or ‘\27’.

These four declarations properties are the same:

content: "'cm' means 'centimeters'.";
content: "\"cm\" means \"centimeters\".";
content: '"cm" means "centimeters".';
content: '\'cm\' means \'centimeters\'.";

It is possible to break strings over several lines, for aesthetic or other reasons, but in such a case the newline itself has to be escaped with a backslash ( \ ). The newline is subsequently removed from the string. For instance, the following selector:

a[title="a not s\
o very long title"] {/*...*/}

Is exactly the same than:

[title="a not so very long title"] {/*...*/}

Since a string cannot directly represent a newline, to include a newline in a string, use the escape “\A”. Hexadecimal A is the line feed character in Unicode (U+000A), but represents the generic notion of newline in CSS.

Resource Locators: the ‘<url>’ type

A URL is a pointer to a resource and is a specially-parsed functional notation denoted by <url>. It corresponds to the URI token in the grammar. Below is an example of a URL being used as a background image:

body { background: url("http://www.example.com/pinkish.gif") }

The same example can be written without quotes:

body { background: url(http://www.example.com/pinkish.gif) }

In some CSS syntactic contexts a URL can be represented as a <string> rather than by <URL>. An example of this is the @import rule. For instance:

@import url('/css/styles.css');

Some characters appearing in a URL must be escaped with a backslash so that the resulting value is a valid URL token:

  • Parentheses
  • Whitespace characters
  • Single quotes ( ‘ )
  • Double quotes ( ” )

For instance:

url(open\(parens)
url(close\)parens)

Depending on the type of URL, it might also be possible to write these characters as URI-escapes. for instance:

url(open%28parens)
url(close%29parens)

Alternatively a URL containing such characters may be represented as a quoted string within the url() notation.

In order to create modular style sheets that are not dependent on the absolute location of a resource, authors should use relative URIs. Relative URIs are resolved to full URIs using a base URI. For CSS style sheets, the base URI is that of the style sheet, not that of the source document (XML o HTML).

When a url appears in the computed value of a property, it is resolved to an absolute URL, as described in the preceding paragraph. The computed value of a URI that the UA cannot resolve to an absolute URI is the specified value.

For example, suppose the following rule:

body { background: url("tile.png") }

is located in a style sheet designated by the URL:

http://www.example.org/style/basic.css

The background of the source document’s body element will be tiled with whatever image is described by the resource designated by the URL:

http://www.example.org/style/tile.png

The same image will be used regardless of the URL of the source document containing the body element. Curious, isn’t it?

And that is all for today. I hope you like it.

In the next post, in CSS Basics series, I will tell you about Numeric Data Types in Values definition syntax.

Regards.