_newCSS

creates and adds a style-element from the given text

Requires

import {_newCSS} from "./tt/ttHTML.js";

Definition

domElement = _newCSS (stylesheetText);

Description

_newCSS creates a style-DOM-Element and adds it to the head-section of the current Document.

Parameters

stylesheetText: a string-formatted Style-Sheet Text

Return Value

_newCSS returns the newly created style-typed DOM-Object

Remarks

-

Example 1: set and use CSS-File

main.js:

import {_newCSS, _newTag} from "./tt/ttHTML.js";

import css from "./myStyles.css";

/* set stylesheets from the file "myStyles.css" */
_newCSS (css);

/* create and add JSX to the document-body */
document.body.appendChild(<div className="myDivStyle">My tiktag&nbsp; 
	<a href="https://docs.tiktag.de/reference-js-_newCSS.html">Styles </a> 
	from a file</div>);
myStyles.css:
.myDivStyle {
	font-size: xxx-large;
	font-weight: bold;
}

a {
	text-decoration: none;
	color: #3344ff;
}

Output:

_newCSS Example screenshot from File

Example 2: set custom styles and apply CSS

main.js:

import {_newCSS, _newTag} from "./tt/ttHTML.js";

/* set stylesheets from using text */
const myCSSObj = _newCSS ("div {font-size: xxx-large;font-weight:bold;color:#aa6622}");

/* create and add JSX to the document-body */
document.body.appendChild(<div>My tiktag text-style injection</div>);

Output:

_newCSS Example screenshot from String

See Also

_newTag