Sam Sam - 4 months ago 7x
HTML Question

Styling Text without HTML Tag?

Is there anyway to style Plain text without HTML tag in HTML.

Example: like I type in HTML some plain text say

hello world -> Can I style this plain text without any tag

and not like

<div> Hello World </div>


Plain text is contained within an element: the body element:

    Hello, world!

Because of this, you could style this text by simply styling the body element:

body {
    color: red;
    text-decoration: underline;

Depending on the context though, CSS3 does provide two pseudo-element selectors which could be used for this: :first-line and :first-letter.

To style the "H" you could simply use:

body:first-letter {
    font-size: 32px;

If there was a <br> element separating your first line from another line, you could also make use of :first-line:

    Hello, world!<br>
    Second line.
body:first-line {
    font-style: italic;

JSFiddle demo.