Styling html text without CSS

110,820

Solution 1

Add CSS as a style directly to the tag you want to format.

EX.

<p style="width:20px;height:20px;background-color:#ffcc00;">The contents go here</p>

Solution 2

With HTML alone, without any CSS, you can set

  • font family with <font face=...>
  • font size with <font size=...> (though just to a few values)
  • text color with <font color=...>
  • italic typefact with <i>
  • bold typeface with <b>
  • superscripts with <sup>
  • subscripts with <sub>
  • underlining with <u>
  • forced line breaks with <br>
  • allowed direct line break points with <wbr>
  • allowed hyphenation (word division) points with &shy;
  • no line breaks with <nobr>
  • text alignment in some elements with align attribute or (for vertical alignment) valign attribute
  • background color and/or image with bgcolor and background attributes in body element and in table-related elements
  • automatically scrolling text with <marquee>

and some other formatting tools (it is somewhat debatable what belongs to text formatting).

Although HTML5 drafts declare many of these as “obsolete” and “nonconforming”, they also require or strongly recommend (depending on element) that browsers continue supporting them, with the exception of nobr (which is well supported by browsers, with no signs of getting dropped).

(HTML5 is a draft specification. It does not “support” anything; browsers do. Specifications may require support, but that’s just a normative statement, about how things should be.)

If you can in fact use CSS at least in style attributes, then there are many more possibilities, though styling is then clumsy and limited.

Solution 3

CSS in a separate file may not be the answer but you may be able to include it in the head of the HTML file like so:

    <doctype HTML>
    <html>
    <head> <title>My title</title>
        <style>h1{
            color:red;
            font-size:20px;
    }
        </style>
    </head>
    <body><h1>My large text heading</h1>
     <script>alert("Hi , I'm in javascript inside the HTML File");</script>
    </body>
    </html>

That's the easiest way and by doing so the code is in all one place ,inside the head of the HTML file in a style tag and can be edited easily. FYI Javascript functions can be added by placing them inside a '<script >alert("Hi , I'm in javascript");</script>' tag like above HTML code shows.

Solution 4

You can also add <a href="thepagelink.html" style="text-decoration:none;"></a> This would remove the underline and any formatting on the link. You can then also add your own styling e.g <a href="thepagelink.html" style="text-decoration:none;" style="color: #07781C;"></a>

Share:
110,820
Samcfuchs
Author by

Samcfuchs

Updated on July 09, 2022

Comments

  • Samcfuchs
    Samcfuchs almost 2 years

    I would like to html code part of my tumblr page, but in the context, I can't add any css. Is there any way to format text size, font, color, etc. without using css? I looked at <font> tags but they don't seem to be supported in html5. Is there a workaround or tag that would do this for me?

    Thanks for all your help