7 back to 30
source | link

CSS, 3330 bytes

* *:after{content:"Hello, World!"

:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after every element with a parent element, in this case the <body> element, with the content Hello, World!. Thanks to jimmy23013 for suggestingSo only one element (<html>) is selected, this assumes that we're using the most basic HTML document, i.e.

<html><style>:after{content:"Hello, World!"</style></html>

The above code adds the text to one element on the pageThis works in most major browsers, per the specifications. If you remove body fromwith the abovenotable exception of Firefox, code it selects all elements (in this casewhich applies the selector to the <html> and <body> elements) and writes the text twice. This is also why Stack snippets don't work, because there is always a savings of 4 bytes:body element that gets styled as well. Below is a slightly modified version to test.

:after{content:"Hello, World!"

* :after{content:"Hello, World!"

CSS, 33 bytes

* *:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after every element with a parent element, in this case the <body> element, with the content Hello, World!. Thanks to jimmy23013 for suggesting this.

The above code adds the text to one element on the page, per the specifications. If you remove body from the above, code it selects all elements (in this case the <html> and <body> elements) and writes the text twice, a savings of 4 bytes:

:after{content:"Hello, World!"

CSS, 30 bytes

:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after every element with the content Hello, World!. So only one element (<html>) is selected, this assumes that we're using the most basic HTML document, i.e.

<html><style>:after{content:"Hello, World!"</style></html>

This works in most major browsers, with the notable exception of Firefox, which applies the selector to the <html> and <body> elements. This is also why Stack snippets don't work, because there is always a body element that gets styled as well. Below is a slightly modified version to test.

* :after{content:"Hello, World!"

6 added 91 characters in body
source | link

CSS, 3433 bytes

body* *:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after every element with a parent element, in this case the <body> element, with the content Hello, World!. Thanks to jimmy23013 for suggesting this.

The above code adds the text to one element on the page, per the specifications. If you remove body from the above, code it selects all elements (in this case the <html> and <body> elements) and writes the text twice, a savings of 4 bytes:

:after{content:"Hello, World!"

CSS, 34 bytes

body:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after the <body> element, with the content Hello, World!.

The above code adds the text to one element on the page, per the specifications. If you remove body from the above, code it selects all elements (in this case the <html> and <body> elements) and writes the text twice, a savings of 4 bytes:

:after{content:"Hello, World!"

CSS, 33 bytes

* *:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after every element with a parent element, in this case the <body> element, with the content Hello, World!. Thanks to jimmy23013 for suggesting this.

The above code adds the text to one element on the page, per the specifications. If you remove body from the above, code it selects all elements (in this case the <html> and <body> elements) and writes the text twice, a savings of 4 bytes:

:after{content:"Hello, World!"
5 added 17 characters in body
source | link

CSS, 3034 bytes

body:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after eachthe <body> element, with the content Hello, World!. Thanks to Ismael Miguel for saving a byte.

The above code adds the text to everyone element on the page, so inper the snippet it appears twice becausespecifications. If you remove body from the above, code it selects all elements (in this case the <html> and <body> elements. To have it only appear once) and writes the text twice, it is 34a savings of 4 bytes:

body:after{content:"Hello, World!"

CSS, 30 bytes

:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after each element, with the content Hello, World!. Thanks to Ismael Miguel for saving a byte.

The above code adds the text to every element on the page, so in the snippet it appears twice because it selects the <html> and <body> elements. To have it only appear once, it is 34 bytes:

body:after{content:"Hello, World!"

CSS, 34 bytes

body:after{content:"Hello, World!"

Cascading Style Sheets (CSS) isn't a typical programming language, but it can do fixed output fairly well. This is done by creating a pseudo-element after the <body> element, with the content Hello, World!.

The above code adds the text to one element on the page, per the specifications. If you remove body from the above, code it selects all elements (in this case the <html> and <body> elements) and writes the text twice, a savings of 4 bytes:

:after{content:"Hello, World!"
4 added 268 characters in body
source | link
3 convert to stack snippet
source | link
2 added 206 characters in body
source | link
1
source | link