/    Sign up×
Community /Pin to ProfileBookmark

CSS: external, embed, inline – how? Whether?

Dear All,

So far on my site (not yet open), I have – now only one!
external style sheet. As I reconsider, a few pages would
do better to have some CSS information embedded in the
heads of those documents. Those are the ones where I’m
doing things like illustrating my “hilarious errors.”
These are, in effect, one-time-only use, not to be
commonly applied on my site.

Because about four pages have the same style applied to
the main headings, I plan to embed that style definition
in the document head.

I have a second “hilarious error” page, where again, I
believe, I’d do best to embed the style information in the
head of the document.

So I’m looking at syntax for doing that. I found some
information at W3C, but I’m not quite clear on how to use
it, especially because also, I call the external style
sheet for the same document.

Here’s what I have ready to put in my pages where headings
are fixed, and therefore scroll down the page over the
content, when they “shouldn’t do that.”

(I solved that little one by positioning the heading
absolutely, which I do in about 22 individual pages
containing larger-size photos). By the way, that is the
only absolute positioning I’ve used on my site so far, and
I believe I don’t have any relative positioning specified
anywhere on the site. The different definitions here apply
because the headings are different sizes, and I adjusted
them in this odd way; just centering didn’t seem to do the
trick (probably has to do with various margin and padding
settings I have applied to the masthead, or banner).

Anyway, these are the definitions I will probably need on
these four pages where the headings are fixed, and
shouldn’t be.

In these examples, I’ve split the lines, but plan to have
them all on one line. (Trying to prevent horizontal
scrolling. here on the forum.)

[code]

.hed1fix {position: fixed; top: 15px; left: 100px; text-
align: center; z-index: 2; }

.hed1afix {position: fixed; top: 15px; left: 150px; text-
align: center; z-index: 2;}

.hed2fix {position: fixed; top: 15px; left: 200px; text-
align: center; z-index: 2;}

.hed3fix {position: fixed; top: 15px; left: 300px; text-
align: center; z-index: 2;}

[/code]

It’s possible that I only need one of those in each of the
four pages, and maybe, also, that I should put that
information inline instead of in the document head – but
for some reason, one I don’t understand, I feel reluctant
to put that information inline.

Any comments or suggestions on that?

Here’s how I’m calling the (external) CSS:

(example is from the first of four pages, all of which use
exactly the same declaration).

( I’m pressing Enter to prevent horizontal scrolling in
this thread, if I can, but this is all on one line in the
code.)

[code] <link rel=”stylesheet” href=”cwstrict.css”
type=”text/css”></head> [/code]

If I embed style information in the document head, where
do I put it in relation to that line calling the external
style sheet?

If it’s better to put it inline, doesn’t the syntax change
a bit? Maybe not; I guess the only difference is that you
put something like

[code]

<h2 style=”position: fixed; top: 15px; left: 100px; text-
align: center; z-index: 2;”>

[/code]

Would that be right?

At the moment, the code is in the (single! yay!) external
CSS file. My .html file, where I need the fixed headings,
looks like this:

[code]

<div class=”hed1afix”>

<h2>Who is Prancy? That is I!<br>Come Sing with Me

My Cat Song.</h2>

</div>

<h4>This is my Cat Song</h4>

[/code]

I can’t remember if HTML 4.01 Strict allows you to break a
heading with <br>; I have a feeling not, but I’ll attend
to that when I change the document from Transitional to
Strict. Though I havent’ figured out yet how to handle
that.

Awaiting your kind guidance, as always!

PS. I took this offline to edit it, because I seem
completley unable to prevent horizontal scrolling! Hope
doing it offline and then pasting will do the job; I did
find an error: “[code]” – cute, huh? Rotten vision
doesn’t help, argh!

P.P.S. With what I’m learning now, I can see that in time,
I can learn to consolidate style desgnations such as those
that come first in this post (thanks again to Fang for
helping me with that!)

P.P.P.S. It took me about six tries to present this post and prevent horizontal scrolling, but I figure, if I can’t present a post properly on the forum, how am I to present properly on my own web site! (setting character count to 58 (!) in NoteTab did the job, but I think I could go to 60, maybe 65 – NOT, apparently, 70!

Mon, 31 Jan 2005 14:08:12

to post a comment
CSS

13 Comments(s)

Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by CarolW [/i]

[B]<i>
</i>
.hed1fix {position: fixed; top: 15px; left: 100px; text-
align: center; z-index: 2; }

.hed1afix {position: fixed; top: 15px; left: 150px; text-
align: center; z-index: 2;}

.hed2fix {position: fixed; top: 15px; left: 200px; text-
align: center; z-index: 2;}

.hed3fix {position: fixed; top: 15px; left: 300px; text-
align: center; z-index: 2;}

[/B][/QUOTE]

This would be slightly more compact:

.hed1fix, .hed1afix, .hed2fix, .hed3fix {position: fixed; top: 15px; text-
align: center; z-index: 2;}

.hed1fix {left: 100px;}

.hed1afix {left: 150px;}

.hed2fix {left: 200px;}

.hed3fix {left: 300px;}
344 characters vs 203. Not a great savings in this case but good practice. I've got to go through my site as well and clean up stuff like that. ?
[i]Originally posted by CarolW [/i]

[B]<i>
</i>
&lt;h2 style="position: fixed; top: 15px; left: 100px; text-
align: center; z-index: 2;"&gt;

[/B][/QUOTE]
Since it is already defined in you css why not <h2 class="hed1fix"> ?
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by CarolW [/i]

[B]<i>
</i>
&lt;div class="hed1afix"&gt;

&lt;h2&gt;Who is Prancy? That is I!&lt;br&gt;Come Sing with Me

My Cat Song.&lt;/h2&gt;

&lt;/div&gt;

&lt;h4&gt;This is my Cat Song&lt;/h4&gt;

[/B][/QUOTE]
That's what they call diviitis. ?

Why use a div in there when this would do:&lt;h2 class="hed1afix"&gt;Who is Prancy? That is I!&lt;br /&gt;Come Sing with Me

My Cat Song.&lt;/h2&gt;

&lt;h4&gt;This is my Cat Song&lt;/h4&gt;

Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — I don't seem to be answering your question. I'm sorry. ?
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by CarolW [/i]

[B]So far on my site (not yet open), I have - now only one!

external style sheet. As I reconsider, a few pages would

do better to have some CSS information embedded in the

heads of those documents....These are, in effect, one-time-only use, not to be

commonly applied on my site...Because about four pages have the same style applied to

the main headings, I plan to embed that style definition

in the document head.[/B]
[/QUOTE]
That is what I do in my navigation when I also use it to show what page you are on:
&lt;style type="text/css"&gt;
#location a:visited {
background: #575;
color: #aaa;
}
&lt;/style&gt;
It goes along with the id in the navbar:&lt;ul&gt;
&lt;li id="secondarytop"&gt;&lt;a href="index.html" title="Blah blah'sHome page."&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li id="products"&gt;&lt;a href="products.html" title="Products page."&gt;Products&lt;/a&gt;&lt;/li&gt;
&lt;li id="location"&gt;&lt;a href="location.html" title="Map to Blah blah's."&gt;Location&lt;/a&gt;&lt;/li&gt;
&lt;li id="safety"&gt;&lt;a href="safety.html" title="Safety information."&gt;Safety&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


I've gone and forgotten what your question was now. *sigh*
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by Triumph [/i]

[B]I've gone and forgotten what your question was now. *sigh* [/B][/QUOTE]
OK, I think I've got it. I guess the answer would be there is not one "right" way. Unfortunately, there are thousands of wrong ways though. ?

There is nothing wrong with using an inline style if you'd like. Just don't let it get bloated like if you were using tables for layout. There is nothing wrong with using a style in the page head to go along with your external css page just don't make it redundant.

Did any of this answer any questions...I have no idea. :o


?

If I can suggest a book: [url=http://www.amazon.ca/exec/obidos/ASIN/0735712018/701-8041577-4304341]Designing with Web Standards[/url]
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by Triumph [/i]

[B]This would be slightly more compact:



.hed1fix, .hed1afix, .hed2fix, .hed3fix {position: fixed; top: 15px; text-
align: center; z-index: 2;}

.hed1fix {left: 100px;}

.hed1afix {left: 150px;}

.hed2fix {left: 200px;}

.hed3fix {left: 300px;}
[/B][/QUOTE]
Better yet, if these are all attached to and <h2> then this would be better:h2 {position: fixed; top: 15px; text-
align: center; z-index: 2;}
and then putting the left attribute in your page header if it is only used on a single page:&lt;style type="text/css"&gt;
h2 { left: 100px;}
&lt;/style&gt;
on the page that you need it to be like that.
Copy linkTweet thisAlerts:
@CarolWauthorFeb 01.2005 — [i]Originally posted by Triumph [/i]

[B]This would be slightly more compact:



.hed1fix, .hed1afix, .hed2fix, .hed3fix {position: fixed; top: 15px; text-
align: center; z-index: 2;}

.hed1fix {left: 100px;}

.hed1afix {left: 150px;}

.hed2fix {left: 200px;}

.hed3fix {left: 300px;}
344 characters vs 203. Not a great savings in this case but good practice. I've got to go through my site as well and clean up stuff like that. ?

Since it is already defined in you css why not <h2 class="hed1fix"> ? [/B][/QUOTE]


Oh, THANKS, Triumph! I'll play with this. Also, even though your suggested space-saving is a small saving, the principle shows, and I can learn from that.

Mon, 31 Jan 2005 17:10:50
Copy linkTweet thisAlerts:
@CarolWauthorFeb 01.2005 — Isn't Jeffrey Zeldman the man who runs A List Apart? I was just looking at that today. Looks like a great book. I don't have any money, but my library might have it, and if not, I might get it on interlibrary loan.

(I have my wayzzzzzzzzzzzz).

And yes, your replies are very helpful. I loved the remark about thousands of ways to do things wrong. I'm good at that <g>.

And your suggestions for how to cope with one embedded style statement, and one in the <h2> tag look good to me.

Mon, 31 Jan 2005 17:15:59
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — Oh no...someone's listening to me...someone save her! Quickly!!!




? ?
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by CarolW [/i]

[B]Isn't Jeffrey Zeldman the man who runs A List Apart? [/B][/QUOTE]
I don't know that he runs it but he contributes. His website is: http://zeldman.com where you can conveniently link back to A List Apart hundreds of times. ?
Copy linkTweet thisAlerts:
@ray326Feb 01.2005 — Isn't Jeffrey Zeldman the man who runs A List Apart? I was just looking at that today. Looks like a great book.[/QUOTE] I think it's a great book. Zeldman is smart and funny. But his book is much more WHY you should switch to "modern" web design. The second book in my sig is a really fantastic cookbook-how-to-element-by-element tutorial on practicing what Zeldman preaches.
Copy linkTweet thisAlerts:
@TriumphFeb 01.2005 — [i]Originally posted by ray326 [/i]

[B]I think it's a great book. Zeldman is smart and funny. But his book is much more WHY you should switch to "modern" web design. The second book in my sig is a really fantastic cookbook-how-to-element-by-element tutorial on practicing what Zeldman preaches. [/B][/QUOTE]
I'm going to have to add it to my wish list. ?
Copy linkTweet thisAlerts:
@CarolWauthorFeb 01.2005 — [i]Originally posted by ray326 [/i]

[B]I think it's a great book. Zeldman is smart and funny. But his book is much more WHY you should switch to "modern" web design. The second book in my sig is a really fantastic cookbook-how-to-element-by-element tutorial on practicing what Zeldman preaches. [/B][/QUOTE]


I've encountered some of Cederholm's work - I was entranced! And that cookbook-stuff is exactly what I need. My wish list grows <g>. Maybe my library will get it, if they don't already have it.

Castro, I'm not familiar with (ignoring Fidel).

Oops - drooling into my keyboard - worse than my cat!

Tue, 01 Feb 2005 06:44:15
×

Success!

Help @CarolW spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...