Dumb Noob Dumb Noob - 1 year ago 75
CSS Question

Referencing an HTML class starting with a whitespace

I want to make a CSS selector for a class which starts with a whitespace, but I don't know how. For example:

<table class=" example">…</table>
..example {/declarations/}

Answer Source

A class value that begins with a space is invalid HTML.


6.2 SGML basic types

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

HTML 5 The class attribute

The attribute, if specified, must have a value that is a set of space-separated tokens representing the various classes that the element belongs to.

Spaces are only used to separate class values. If you start the value with a space, expect the unexpected, or the browser may simply ignore the space. But it's invalid code, so avoid doing that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download